Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Multiple Images into PDF
  FAQ FAQ  Forum Search   Register Register  Login Login

Multiple Images into PDF

 Post Reply Post Reply
Author
Message
dblwizard View Drop Down
Beginner
Beginner
Avatar

Joined: 25 Jan 08
Location: United States
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote dblwizard Quote  Post ReplyReply Direct Link To This Post Topic: Multiple Images into PDF
    Posted: 25 Jan 08 at 3:40AM
Howdy All,

I am trying to add multiple tiff images to a single PDF.  I have been able to use the AddImageFromFile to add a single image to a PDF but can not seem to make it work for multiple.  Can somebody point me in the right direction?  I am using version 5.22.0.145 with vb6.

   Set objQPDF = New iSED.QuickPDF
   lRC = objQPDF.CompressImages(1)
  
   For i = LBound(asFileNamesTiffA) To UBound(asFileNamesTiffA)
     
      If i = LBound(asFileNamesTiffA) Then
         lRC = objQPDF.NewDocument
      Else
         lRC = objQPDF.NewPage
         lRC = objQPDF.SelectPage(lRC)
      End If
     
      lRC = objQPDF.AddImageFromFile(asFileNamesTiffA(i), 0)
     
      If lRC <> 0 Then
         objQPDF.SetMeasurementUnits (2)
         objQPDF.SetOrigin (1)
         dHeight = objQPDF.ImageHeight / objQPDF.ImageVerticalResolution
         dWidth = objQPDF.ImageWidth / objQPDF.ImageHorizontalResolution
         lRC = objQPDF.SetPageDimensions(dWidth, dHeight)
         lRC = objQPDF.FitImage(0, 0, dWidth, dHeight, 1, 1, 0)
         lRC = objQPDF.CompressContent()
      End If
     
   Next i

Thanks

dbl
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 25 Jan 08 at 4:20AM
Hi!

If you use
lRC = objQPDF.AddImageFromFile(asFileNamesTiffA(i), 0)
you'll get only the first image... 'cause you set a fix "0".

If you're using tiff-files you should use something similar to:
tiffmax = GetImagePageCount(tiff-filename)
to see how many images are in your tiff.
Then you can initiate a new loop to add each internal image.
It should look similar to this non-language-syntax:
for i1 = 1 to filemax
//Create a new pdf-document...
if it's a tiff-file
tiffmax = GetImagePageCount(filename(i1))
for i2 = 1 to tiffmax
//Create a new pdf-document or a new page...
AddImageFromFile(filename(i1),i2)
next i2
endif
if it's no tiff-file
AddImageFromFile(filename(i1),0)
endif
next i1


Best regards,
Ingo
Back to Top
dblwizard View Drop Down
Beginner
Beginner
Avatar

Joined: 25 Jan 08
Location: United States
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote dblwizard Quote  Post ReplyReply Direct Link To This Post Posted: 25 Jan 08 at 10:14AM
Howdy,

Sorry I didn't make  it clear what I am doing.  The asFileNamesTiffA is an array of single page tiffs.  So what I am trying to do is load one page from each file into the PDF.

That is why I only have the one loop.  The code I have there works the first time through the loop but the second time through the loop AddImageFromFile returns 0.  I have even changed the order of the files in the array to make sure their wasn't really a problem with the Tiff file that its trying to load the second time threw.

Does that clarify things a little bit?

Thanks

dbl
Back to Top
dblwizard View Drop Down
Beginner
Beginner
Avatar

Joined: 25 Jan 08
Location: United States
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote dblwizard Quote  Post ReplyReply Direct Link To This Post Posted: 25 Jan 08 at 10:54AM
Howdy again,

I have done a little more research and found some odd things.  This code works for v4.42.1.1 when adding a single page.  Blank pages are added for each additional page but the AddFileFromTiff returns 0.

With v5.22.0.145 I get the same behavior in code but the resulting image gives a "Insufficient data for an image" and the file has 3 blank pages in it.

Thanks

dbl
Back to Top
dblwizard View Drop Down
Beginner
Beginner
Avatar

Joined: 25 Jan 08
Location: United States
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote dblwizard Quote  Post ReplyReply Direct Link To This Post Posted: 05 Feb 08 at 2:39AM
Ok, do I feel stupid.  The reason that the above code did not work was because the array of filename that I had a leading space on all of the filenames after the first one.  Thus the first file was processed fine but anything after that got an error.

So just note that you can't pass in a file name with a leading space on it.

Thanks

dbl
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store