Page 1 of 1

How to create multiple page PDF from multiple images

Posted: Wed Jul 02, 2008 10:01 am
by irab
Hi Loïc!

Can you show a sample code?

Thanks,
Irab

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

Posted: Wed Jul 02, 2008 1:18 pm
by irab
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

Re: How to create multiple page PDF from multiple images

Posted: Thu Jul 03, 2008 10:28 am
by Loïc
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

Re: How to create multiple page PDF from multiple images

Posted: Fri Aug 29, 2008 9:48 am
by MasterTom
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?

Re: How to create multiple page PDF from multiple images

Posted: Fri Aug 29, 2008 10:10 am
by Loïc
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

Re: How to create multiple page PDF from multiple images

Posted: Fri Aug 29, 2008 11:39 am
by MasterTom
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!

Re: How to create multiple page PDF from multiple images

Posted: Fri Aug 29, 2008 11:42 am
by Loïc
Ah Yes !

I didn't seen that!

Best regards,

Loïc