Page 1 of 1

Create Multi-Page Tiff Stream from Multi-Page PDF Stream

Posted: Tue Oct 26, 2010 10:53 pm
by cjsavas
hi, I am currently evaluating this product and would like to see a sample where you load a muli-page PDF Stream, and convert to a Multi-Page TIFF stream. Currently I am able to convert a multi-page PDF to a multi-page TIFF but I have to physically save the TIFF to the file system.

Thank you.

Re: Create Multi-Page Tiff Stream from Multi-Page PDF Stream

Posted: Thu Oct 28, 2010 12:19 pm
by Loïc
Hi,

here the sample, hope this helps !

Code: Select all

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
      Dim oGdPictureImaging As New GdPicture.GdPictureImaging
      Dim MultiTiffID As Integer

      oGdPictureImaging.SetLicenseNumber("XXX")

      Dim PdfID As Integer = oGdPictureImaging.PdfReaderLoadFromFile("c:\test.pdf")

      If PdfID <> 0 Then
         For i As Integer = 1 To oGdPictureImaging.PdfReaderGetPageCount(PdfID)
            If oGdPictureImaging.GetStat = GdPicture.GdPictureStatus.OK Then
               oGdPictureImaging.PdfReaderSelectPage(PdfID, i)
               Dim RasterizedPageID As Integer = oGdPictureImaging.PdfReaderRenderPageToGdPictureImage(PdfID, 200, True) '200 DPI, can be changed.

               If i = 1 Then
                  MultiTiffID = oGdPictureImaging.TiffCreateMultiPageFromGdPictureImage(RasterizedPageID)
               Else
                  oGdPictureImaging.TiffAppendPageFromGdPictureImage(MultiTiffID, RasterizedPageID)
               End If
               oGdPictureImaging.ReleaseGdPictureImage(RasterizedPageID)
            End If
         Next

         Dim strm As New IO.MemoryStream
         oGdPictureImaging.SaveAsStream(MultiTiffID, strm, GdPicture.DocumentFormat.DocumentFormatTIFF, 65536)
         oGdPictureImaging.ReleaseGdPictureImage(MultiTiffID)
         oGdPictureImaging.PdfReaderCloseDocument(PdfID)
      End If
   End Sub