Add PDF to Existing Multipage TIFF

Discussions about PDF management.
Post Reply
rbgolfin
Posts: 16
Joined: Wed Jun 03, 2009 3:10 pm

Add PDF to Existing Multipage TIFF

Post by rbgolfin » Sat Jan 09, 2010 7:56 am

I am trying to add a PDF image (Loaded into a Byte Array) to an existing Tiff Image. When done I still just have the original Tiff image without the new pages added. I have verified that the Byte array is loaded correctly and the GdViewer shows 1 in page count after oGdViewer.DisplayFromByteArray. What am I doing wrong? I am running version 6.5.3. Here is my code:

Code: Select all

                //Use GDPicture to Convert the PDF to Tiff
                int intTiffImageID = 0;
                oGdViewer.DisplayFromByteArray(ref oByte);

                oGdPictureImaging.TiffOpenMultiPageForWrite(true);

               intTiffImageID = oGdPictureImaging.TiffCreateMultiPageFromFile(strTiffFilePath);

               for (int i = 1; i <= oGdViewer.PageCount; i++)
                {
                    int intPDFImageID = oGdViewer.PdfRenderPageToGdPictureImage(300, i);
                    oGdPictureImaging.ConvertTo1Bpp(intPDFImageID);
                    oGdPictureImaging.TiffAddToMultiPageFile(intTiffImageID, intPDFImageID);
                    oGdPictureImaging.ReleaseGdPictureImage(intPDFImageID);
                 }
                oGdPictureImaging.TiffCloseMultiPageFile(intTiffImageID);
                oGdPictureImaging.ReleaseGdPictureImage(intTiffImageID);
                oGdViewer.CloseDocument();
            }

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Add PDF to Existing Multipage TIFF

Post by Loïc » Sat Jan 09, 2010 11:54 am

Hi,

Please try this code instead:


//Use GDPicture to Convert the PDF to Tiff
int intTiffImageID = 0;
oGdViewer.DisplayFromByteArray(ref oByte);

oGdPictureImaging.TiffOpenMultiPageForWrite(true);

intTiffImageID = oGdPictureImaging.TiffCreateMultiPageFromFile(strTiffFilePath);

for (int i = 1; i <= oGdViewer.PageCount; i++)
{
int intPDFImageID = oGdViewer.PdfRenderPageToGdPictureImage(300, i);
oGdPictureImaging.ConvertTo1Bpp(intPDFImageID);
oGdPictureImaging.TiffAppendPageFromGdPictureImage(intTiffImageID, intPDFImageID);
oGdPictureImaging.ReleaseGdPictureImage(intPDFImageID);
}
oGdPictureImaging.TiffSaveMultiPageToFile(TiffImageID, "output.tif", TiffCompression.TiffCompressionCCITT4);

oGdPictureImaging.ReleaseGdPictureImage(intTiffImageID);
oGdViewer.CloseDocument();
}

Let me know if you have other problem.

Kind regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest