One imageid from multipage PDF

Discussions about PDF management.
Post Reply
mdelbene
Posts: 31
Joined: Wed May 11, 2011 10:03 am

One imageid from multipage PDF

Post by mdelbene » Thu Jul 21, 2011 5:23 pm

Hi all!
I need to load a PDF file, then create a GdPictureImage and display the image in a GdViewer.

I use the newest GdPicturePDF and I'll write the following code:

Code: Select all

int imageId = 0;
if (gdPDF.LoadFromFile(filePath, false) == GdPictureStatus.OK)
	imageId = gdPDF.RenderPageToGdPictureImage(200, false);
if (imageId > 0)
	GdViewerArea.DisplayFromGdPictureImage(imageId);

So I have some problems when the file has more than one page, because only the first page is loaded in the GdViewer.

I tried to loop all the pages of PDF, but I don't understand if I can obtain only one imageId.

Please anyone can help me?

Thanks a lot.
Michela

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

Re: One imageid from multipage PDF

Post by Loïc » Fri Jul 22, 2011 11:36 am

Hi Michela !

If I understand you want to convert a multipage PDF to a multipage Bitmap in order to display in GdViewer right ?

In this case what you have to do is to convert to multipage PDF to a multipage tiff that will be manageable through one unique image identifier.

Here an example:

Code: Select all

      Dim oGdPictureImaging As New GdPictureImaging
      Dim oGdPicturePDF As New GdPicturePDF
      oGdPicturePDF.LoadFromFile("c:\mypdf.pdf", False)
      Dim tiff_id As Integer

      For i As Integer = 1 To oGdPicturePDF.GetPageCount
         oGdPicturePDF.SelectPage(i)
         Dim raster_page As Integer = oGdPicturePDF.RenderPageToGdPictureImage(200, False)
         If i = 1 Then
            tiff_id = oGdPictureImaging.TiffCreateMultiPageFromGdPictureImage(raster_page)
         Else
            oGdPictureImaging.TiffAppendPageFromGdPictureImage(tiff_id, raster_page)
         End If
         oGdPictureImaging.ReleaseGdPictureImage(raster_page)
      Next
      oGdPicturePDF.CloseDocument()

      GdViewer1.DisplayFromGdPictureImage(tiff_id)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest