Printing HTML syntax to PDF file

If you are a VB developer and have questions about using our products from VB, here is the place to post them.
Post Reply
Tim
Posts: 5
Joined: Thu Jan 20 2005
Location: New Zealand

Printing HTML syntax to PDF file

Post by Tim » Thu Jan 20 2005

Hi,

This is the first time I've tried integrating the PDF converter into a VB 6 application and although it works, it isn't doing what I had hoped !

I've developed a small function which creates a HTML email and sends it - it's received by Outlook and looks fine. At the same time, I'm trying to send a copy of the email to the PDF file, which is working, but the content of the PDF is the actual HTML string that forms the original email.

Can I get the rendered HTML page into the PDF file as I had hoped ?

TIA

Tim

Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan » Mon Jan 24 2005

Hello,

The PDF Converter works like any printer. You will get as output what you send to the printer.

The Converter will not convert HTML code to HTML output, maybe this is why you are getting HTML code in the pdf file.

You can try to open the mail in Outlook and print it to the PDF Converter.

Hope this helps.

Tim
Posts: 5
Joined: Thu Jan 20 2005
Location: New Zealand

HTML -> PDF

Post by Tim » Mon Jan 24 2005

Thanks for the reply. I guessed it wouldn't convert the HTML string when it was passed to the printer :(

Is there a control in VB that allows me to render the HTML and print it as a web page ?

I've tried using the HTML2PDF executable - which works - but I get the normal header and footer text from the browser on the page i.e. 'Page x of x' at the top and the URL and date at the bottom. As the HTML is a report going to customers, I don't want this information !

Tim

Tim
Posts: 5
Joined: Thu Jan 20 2005
Location: New Zealand

HTML -> PDF

Post by Tim » Mon Jan 24 2005

OK, I've moved on...

I am getting some success with the HTML2PDF utility, whereby I'm creating individual HTML pages on my hard drive and then calling a SHELL session from VB and creating a concatenated PDF file by adding each HTML file to the PDF.

However, after about half a dozon or so loops through the program, I'm getting an error associated with memory. Thinking this was due to the looping, I added a 'DoEvents' following the shell and although I don't get the memory error anymore, the PDF file only contains about a dozen of the 40 or so HTML which I need added to it.

Any ideas on this ... ?

Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan » Tue Jan 25 2005

Hello,

Please try to add some time between the conversion of each HTML document to be sure that the first document has been converted before starting the conversion of the new one.

Are you working in a multithreading environment?

Hope this helps.

Tim
Posts: 5
Joined: Thu Jan 20 2005
Location: New Zealand

HTML -> PDF

Post by Tim » Tue Jan 25 2005

Thanks for confirming that I need a delay. This seems to be allowing more HTML files to be concatenated with the PDF, but still throws up a memory error after about 15 or so (even with a 30 second delay between calls to the HTML2PDF utility !)

If I write all the HTML files in one go, can I use the HTML2PDF utility and pass it a '*.html' to convert all HTML files into the same PDF ?

Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan » Wed Jan 26 2005

Hello,

If you create and store all your HTML files in one folder you can then use BatchConverter() of CDintf to convert all your documents to PDF using *.html.

To have all the html files concatenated in one pdf you need to add concatenate to your call of FileNameOptions.

If you need a sample code please let me know and I will post one here.

Tim
Posts: 5
Joined: Thu Jan 20 2005
Location: New Zealand

HTML -> PDF

Post by Tim » Wed Jan 26 2005

Thanks for the reply.

I've already tried using the 'batchconvert' function, but it displays the printer dialog box for each HTML file being converted. Therefore, this function is unuseable unless the printer dialog box can be suppressed. From other posts here, there are a lot of people who are affected by this when using the batchconvert feature.

I'm at a stage at the moment where I have to produce a HTML file and call the HTML2PDF utility to create the PDF for up to 15 files. I have a counter in my app. that rolls over when 15 is reached and a new PDF file is used for the next 15 HTML files. This continues until all the HTML files are printed, so I have a number of PDF files at the end of the process.

For my needs, this is satisfactory.

Unless you know of any fixes to the batchconvert issue, I think we can close this topic. Thanks for all your help.

(I've also emailed 'support' and have discovered that I'm out of the maintenance period, so I'll be renewing that now ...)

Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan » Thu Jan 27 2005

Hello Tim,

The below code convert documents to PDF using BatchConvert() without showing the SaveAs dialog box.

Code: Select all

Private Sub BatchConvert_Click()

'Create an instance of CDIntfEx
Public pdf As New CDIntfEx.CDIntfEx

pdf.DriverInit PrinterName
pdf.setlicensekey Licensee, Activation Code

' Set PDF Converter options and output file name
pdf.FileNameOptionsEx = 1 + 2   'NoPrompt + UseFileName
pdf.DefaultFileName = "c:\Temp\test.pdf"  'Temp should be an existing folder

' Batch print all files
pdf.BatchConvert "c:\Temp\*.htm"

End Sub

Post Reply