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


All forums · Statistics · Search ·

Two Pilots forum / For software developers / Need of ASP Assistance
Author Message
Anonymous
# Posted: 20 Dec 2005 12:01


Hi,

I am evaluating html2pdf products. I have installed pdf pilot creator and the html2pdf add on. I can run the windows app(vbs) to test the html2pdf functionality and it converts a html to a pdf doc. I want to recreate the same functionality in an asp or in asp.net.
I have had no sucess in doing so. Please can someone post an asp page or asp.net page which gets a html page and then returns the user a pdf doc.

pl tell me the solution urgently
Thanks in advance

Stanislav
# Posted: 20 Dec 2005 15:02


Hello,

Here is asp example for PDF Creator Pilot
http://www.colorpilot.com/pdfsample_asp.html
and asp.net
http://www.colorpilot.com/pdfsample_aspnet.html
and here is example for HTML2PDF Add-on
http://www.colorpilot.com/pdfsample_html2pdf_vbscript.html
You can use examples to create asp script.

Something like this:

Private Sub Page_Load( ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click

Dim PDF ' PDF object

Dim Size As Long

Dim PDFImage As System.Array

' create pdf library object

PDF = CreateObject("PDFCreatorPilot2.piPDFDocument")

' initialize PDF Engine

PDF.StartEngine("demo@demo", "demo")

' set GenerateInMemoryFile generation flag to TRUE so keep PDF ' only in the memory

PDF.GenerateInMemoryFile = True

' start document generation

PDF.BeginDoc()

Set HTML = CreateObject("HTML2PDFAddon.HTML2PDF")

' initialize HTML engine

HTML.StartHTMLEngine("","")

' connect to PDF Creator Pilot instance

HTML.ConnectToPDFLibrary(PDF)

' load HTML file into HTML renderer

HTML.LoadFromString("<HTML><BODY><H1>Hello, HTML2PDF!</H1></BODY></HTML>", "")

' convert whole HTML document into PDF

HTML.ConvertAll()

' disconnect from PDF Creator Pilot instance

HTML.DisconnectFromPDFLibrary()

HTML = Nothing

' finalize document generation

PDF.EndDoc() ' clear the output stream

' get size of generated in-memory pdf file

Size = PDF.MemoryFileSize

' create new buffer with size equal to generated pdf file

Dim PDFBuffer( CInt (Size)) As Byte

' get in-memory pdf file as byte stream

PDFImage = PDF.BinaryImage

' copy byte stream into buffer

Array.Copy(PDFImage, PDFBuffer, Size)

' clear http output

Response.Clear()

' set the content type to PDF

Response.ContentType = "application/pdf"

' add content type header

Response.AddHeader("Content-Type", "application/pdf")

' set the content disposition

Response.AddHeader("Content-Disposition", "inline;filename=form.pdf")

' write the buffer with pdf file to the output

Response.BinaryWrite(PDFBuffer)

Response.End()

' disconnect from library

PDF = Nothing

End Sub

Thank you very much !

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

 

 

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

 

Page top