Two Pilots™    Home  |  Navigation  |  Site Map  |  Products  |  Download  |  Prices  |  For Partners  |  Support


All forums · Statistics · Search ·

Two Pilots forum / For software developers / I can't save pdf file in remote computer!
Author Message
Caesar
# Posted: 15 Jan 2007 04:33


I have created an Activex using Visual Studio 6.0 with a function to transform an HTML string into PDF (using the pilot .dll). I have tested this and it is working fine locally. I'm using Internet explorer 7.0. My computer is part of a local area network.

Now when I try to use the activex from a computer other the one I used for creating it, I'm not able to save the pdf file to the client's computer. I have made sure that in ie 7.0 I have enable the activex download.

I 'm wondering where the problem is coming from.

Caesar

Stanislav
Member
# Posted: 15 Jan 2007 06:14


Dear Caesar,

I think you need to store file on the server, and output the PDF download link in a browser, or using BinaryWrite send PDF output to the browser directly.

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

Caesar
# Posted: 15 Jan 2007 07:49


Dear Stanislav,

The issue is that I don't want to have file on the server that is why I'm using activex. I want the client to just click on a button and this prompts a dialog to allow him to save the the generated pdf file onto the client's computer.

Here is an extract from the source code of what I want to do.

' class module of the activex written in VB

Option Explicit
Public gdatServerStarted As Date
Private strHTMLString As String

Sub Main()
' Code to be executed when the component starts,
' in response to the first object request.
gdatServerStarted = Now
Debug.Print "Executing Sub Main"
End Sub

Public Property Let HtmlFilePath(ByVal vNewValue As String)
strHTMLString = vNewValue
End Property

Public Sub CreatePDF()

Form1.CommonDialog1.ShowSave

If Len(Form1.CommonDialog1.FileName) > 0 Then
Dim PDF As PDFDocument3
' create pdf library object
Set PDF = New PDFDocument3

' initialize PDF Engine
PDF.StartEngine "", ""

' set AutoLaunch flag to TRUE to automatically open the generated pdf generation
PDF.AutoLaunch = False

' PDF.FileName = "HTMLstringWithExternalImageToPDF_VBS.pdf"
PDF.FileName = Form1.CommonDialog1.FileName


' start document generation
PDF.BeginDoc

Dim HTML As Object
Set HTML = CreateObject("HTML2PDFAddon.HTML2PDF2")

' initialize HTML engine
HTML.StartHTMLEngine "", ""

' connect to PDF Creator Pilot instance
HTML.ConnectToPDFLibrary PDF

' load HTML string
' HTML.LoadHTMLString "<html><head><link href='styles.css' rel='stylesheet' type='text/css'></head><body><h1>Testing 1</h1><br> <h2>Testing 2</h2><br> <h3>Testing 1</h3><span class='green_1'>green_1</span><img src='http://localhost/ppp/logo.gif' border='0' /><br></body></html>", ""
HTML.LoadHTMLString strHTMLString, ""

' convert whole HTML document into PDF
HTML.ConvertAll

' disconnect from PDF Creator Pilot instance
HTML.DisconnectFromPDFLibrary

Set HTML = Nothing

' finalize PDF generation
PDF.EndDoc

End If

End Sub


' the htm file which allows me to call the activex from the browser

<HTML>
<HEAD>
<TITLE>PDFCreatorActiveX.CAB</TITLE>
<script language="javascript" type="text/javascript">

function SaveAsPDF()
{
// alert('1');
var obj = document.getElementById('PDFFile');
obj.HtmlFilePath = "<html><head><link href='http://localhost/ppp/styles.css' rel='stylesheet' type='text/css'></head><body><h1>Testing 1</h1><br> <h2>Testing 2</h2><br> <h3>Testing 1</h3><span class='green_1'>green_1</span><img src='http://localhost/ppp/logo.gif' border='0' /><br></body></html>";
obj.CreatePDF();
}

</script>
<alink href='styles.css' rel='stylesheet' type='text/css'>
</HEAD>
<BODY>
<OBJECT ID="PDFFile"
CLASSID="CLSID:15E25B03-3650-418A-BBB6-11D358085A3 D"
CODEBASE="PDFCreatorActiveX.CAB#version=1,0,0,0">
</OBJECT>
<p><input type="button" value="Save as PDF" onClick="SaveAsPDF();"></p>

<span class='green_1'>green_1</span><img src='logo.gif' border='0' />

</BODY>
</HTML>


Note
Currently I'm evaluating the htm2pdf dll which I intend to buy as soon as it solves my problem.

Caesar

Stanislav
Member
# Posted: 15 Jan 2007 09:45


Dear Caesar,

I recommend you to test BinaryImage property, it will create PDF in server memory, then you can transfer it to the user's browser.

I don't think that you'll be able to execute required code from IE ActiveX.

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

 

 

Powered by miniBB 2.0 RC7 © 2001-2004 Page creation time (sec.): 0.014

 

Page top