Problem with CreateGdPictureImageFromByteArray in version 8

Discussions about image processing and document imaging.
Post Reply
rbgolfin
Posts: 16
Joined: Wed Jun 03, 2009 3:10 pm

Problem with CreateGdPictureImageFromByteArray in version 8

Post by rbgolfin » Mon Sep 12, 2011 7:39 pm

Below is the code I was using in version 7.4 to load a PDF image from a byte array and convert it to a multipage tiff and save it to a file. Version 8 does not have the PdfRenderPageToGdPictureImage method so this doesn't work anymore. I tried using int intPDFImageID = moGdPictureImaging.CreateGdPictureImageFromByteArray(oByte) but the image id always comes back 0. GdViewer1.DisplayFromByteArray(ref oByte) loads the same image just fine but it won't load using moGdPictureImaging.CreateGdPictureImageFromByteArray(oByte). Any help is appreciated.


int intTiffImageID = 0;
GdViewer1.DisplayFromByteArray(ref oByte);
moGdPictureImaging.TiffOpenMultiPageForWrite(true);
for (int i = 1; i <= GdViewer1.PageCount; i++)
{
int intPDFImageID = 0 = GdViewer1.PdfRenderPageToGdPictureImage(300, i);
moGdPictureImaging.ConvertTo1Bpp(intPDFImageID);
if (intTiffImageID == 0)
{
intTiffImageID = moGdPictureImaging.TiffCreateMultiPageFromGdPictureImage(intPDFImageID);
}
else
{
moGdPictureImaging.TiffAppendPageFromGdPictureImage(intTiffImageID, intPDFImageID);
}
moGdPictureImaging.ReleaseGdPictureImage(intPDFImageID);
}
Last edited by rbgolfin on Mon Sep 12, 2011 9:50 pm, edited 1 time in total.

rbgolfin
Posts: 16
Joined: Wed Jun 03, 2009 3:10 pm

Re: Problem with CreateGdPictureImageFromByteArray in versio

Post by rbgolfin » Mon Sep 12, 2011 9:48 pm

I was able to get it working by creating a stream from the byte array and loading that into a GDPicture.GDPicturePDF object. Below is my code. There is still a problem with moGdPictureImaging.CreateGdPictureImageFromByteArray(oByte) that you may want to look into.

int intTiffImageID = 0;

MemoryStream stream = new MemoryStream(oByte);

GdPicture.GdPicturePDF oPDF = new GdPicturePDF();
oPDF.LoadFromStream(stream);

moGdPictureImaging.TiffOpenMultiPageForWrite(true);
for (int i = 1; i <= oPDF.GetPageCount(); i++)
{
oPDF.SelectPage(i);
int intPDFImageID = oPDF.RenderPageToGdPictureImage(300, false);
moGdPictureImaging.ConvertTo1Bpp(intPDFImageID);
if (intTiffImageID == 0)
{
intTiffImageID = moGdPictureImaging.TiffCreateMultiPageFromGdPictureImage(intPDFImageID);
}
else
{
moGdPictureImaging.TiffAppendPageFromGdPictureImage(intTiffImageID, intPDFImageID);
}
moGdPictureImaging.ReleaseGdPictureImage(intPDFImageID);
}

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest