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!
Multiple Images into PDF |
Post Reply |
Author | |
dblwizard
Beginner Joined: 25 Jan 08 Location: United States Status: Offline Points: 6 |
Post Options
Thanks(0)
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 |
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
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 |
|
dblwizard
Beginner Joined: 25 Jan 08 Location: United States Status: Offline Points: 6 |
Post Options
Thanks(0)
|
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 |
|
dblwizard
Beginner Joined: 25 Jan 08 Location: United States Status: Offline Points: 6 |
Post Options
Thanks(0)
|
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 |
|
dblwizard
Beginner Joined: 25 Jan 08 Location: United States Status: Offline Points: 6 |
Post Options
Thanks(0)
|
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 |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store