Do you own a Debenu Quick PDF Library 12/11/10/9/8/7? Upgrade to Debenu Quick PDF Library 13!

Foxit Quick PDF Library

Frequently Asked Question:

Return to FAQ Index

Problems Writing Multipage Tiff to PDF

Question

I am new to using Quick PDF in VB6 and am using the trial version with the plan of buying the full version.

I am attempting to read a multipage .tiff image and write it to a multipage .pdf file. The .pdf file creates but only contains the last page of my multipage image.

Dim intheight As Integer
Dim intNumPages As Integer
Dim i As Integer
Dim QP
Set QP = CreateObject("QuickPDFAX0719.PDFLibrary")

blnLicenseOkay = False
If QP.UnlockKey("j54g75ru43q3n14qr5wu9r36y") = 1 Then
blnLicenseOkay = True
End If
If blnLicenseOkay = False Then
Exit Sub
End If
'Getting Path/Name of Multipage Tif
strBaseFileName = getDataPath & rs.Item("filename")
intNumPages = QP.GetImagePageCount(strBaseFileName)
If intNumPages > 1 Then 
For i = 1 To intNumPages
Call QP.AddImageFromFile(strBaseFileName, i)
intwidth = QP.ImageWidth()
intheight = QP.ImageHeight()
Call QP.SetPageDimensions(intwidth, intheight)
Call QP.DrawImage(0, intheight, intwidth, intheight)
Next i
'strfiletocreate is the path/file of pdf being created
Call QP.SaveToFile(strFileToCreate)
Answer

The problem is that you're taking each page from the TIFF image and drawing it onto a single page in a PDF. That is why the last page in the TIFF image is the only page you see in the PDF. All of the previously drawn images are being overwritten.

In your for loop after you've made the call to DrawImage you need to then call the NewPage function to add a new page, so that the next image will be added to a new page.

Alternatively, you could calculate the number of required pages in advance and then use the NewPages function to create x number of new pages and then you would just have to select which page you wish to draw the image on during the loop.


© 2015 Debenu & Foxit. All rights reserved. AboutBuyContactBlogNewsletterSupportFAQProduct UpdatesForum