Home | About us | Overview | Softwares - Downloads | Evaluate | Order | Support | old forums | Contact | F.A.Q. | Documentations | Search | Sitemap

How to create multiple page PDF from multiple images

Example requests & Code samples for GdPicture ActiveX.

How to create multiple page PDF from multiple images

Postby irab on Wed Jul 02, 2008 11:01 am

Hi Loïc!

Can you show a sample code?

Thanks,
Irab
irab
 
Posts: 4
Joined: Thu Jun 26, 2008 10:21 am

Re: How to create multiple page PDF from same PNG files

Postby irab on Wed Jul 02, 2008 2:18 pm

Hi

It is a possible way to create multiple page PDF from some files:

Code: Select all
        nImageID = imiPDF.TiffCreateMultiPageFromFile("file1.jpg")
        imiPDF.TiffAppendPageFromFile(nImageID, "file2.jpg")
        imiPDF.TiffAppendPageFromFile(nImageID, "file3.jpg")
        imiPDF.CreateImageFromFile("multipage_tif.tif")
        Call imiPDF.PdfCreateFromMultipageTIFF(nImageID, "multipage.pdf")
        imiPDF.CloseImage(nImageID)


How can I do it else simplier?

Regards,
Irab
irab
 
Posts: 4
Joined: Thu Jun 26, 2008 10:21 am

Re: How to create multiple page PDF from multiple images

Postby Loïc on Thu Jul 03, 2008 11:28 am

Hi,

You can optimize your code like that:


Code: Select all
  Dim nCpt As Long
  Dim nImageCount As Long
 
  Imaging1.PdfNewPdf ("multipage.pdf")
 
  Imaging1.PdfAddImageFromFile ("image1.jpg")
  Imaging1.PdfAddImageFromFile ("image2.jpg")
  Imaging1.PdfAddImageFromFile ("image3.jpg")
  nImageCount = 3
 
 
  For nCpt = 1 To nImageCount
      Call Imaging1.PdfSetPageDimensions(Imaging1.PdfGetImageWidth(nCpt), Imaging1.PdfGetImageHeight(nCpt))
      Call Imaging1.PdfNewPage
      Call Imaging1.PdfDrawImage(nCpt, 0, 0, Imaging1.PdfGetImageWidth(nCpt), Imaging1.PdfGetImageHeight(nCpt))
      Call Imaging1.PdfEndPage
  Next nCpt
 
  Imaging1.PdfSavePdf


Best regards,

Loïc
User avatar
Loïc
Site Admin
 
Posts: 1195
Joined: Tue Oct 17, 2006 11:48 pm
Location: France

Re: How to create multiple page PDF from multiple images

Postby MasterTom on Fri Aug 29, 2008 10:48 am

Hi there...

I'm using the following in my (C#) project...

Code: Select all
oImaging.PdfNewPdf(sFileName,...);
if (File.Exists(...) == true)
{
  oImaging.PdfAddImageFromFile(...);
  iCount += 1;
}
sImageCounter = iCount.ToString();
for (var i = 1; i < iCount; i++)
{
  oImaging.PdfSetCompressionLevel(8);
  oImaging.PdfSetPageDimensions(oImaging.PdfGetImageWidth(i), oImaging.PdfGetImageHeight(i));
  oImaging.PdfNewPage();
  oImaging.PdfDrawImage(i, 0, 0, oImaging.PdfGetImageWidth(i), oImaging.PdfGetImageHeight(i));
  oImaging.PdfEndPage();
}
oImaging.PdfSavePdf();


But I'm only ending up with single page pfd files...
I know 'iCount' is 2 or 3 sometimes... so I guess there must be else going wrong...

Any ideas?
MasterTom
 
Posts: 3
Joined: Fri Aug 01, 2008 10:18 am

Re: How to create multiple page PDF from multiple images

Postby Loïc on Fri Aug 29, 2008 11:10 am

Hi,

Your code seems to be good.

Are you using the last edition ? I fixed a problem with image management in a previous release.

Best regards,

Loïc Carrère
User avatar
Loïc
Site Admin
 
Posts: 1195
Joined: Tue Oct 17, 2006 11:48 pm
Location: France

Re: How to create multiple page PDF from multiple images

Postby MasterTom on Fri Aug 29, 2008 12:39 pm

Ok... using 1.6.0.0 now.
But my problem was caused by the following line:
for (var i = 1; i < iCount; i++)

which should've been:
for (var i = 1; i <= iCount; i++)

Still... thanks for the reply Loïc!
MasterTom
 
Posts: 3
Joined: Fri Aug 01, 2008 10:18 am

Re: How to create multiple page PDF from multiple images

Postby Loïc on Fri Aug 29, 2008 12:42 pm

Ah Yes !

I didn't seen that!

Best regards,

Loïc
User avatar
Loïc
Site Admin
 
Posts: 1195
Joined: Tue Oct 17, 2006 11:48 pm
Location: France


Return to Example requests & Code samples

Who is online

Users browsing this forum: No registered users and 0 guests

cron