Extract a bitmap embedded into the selected page of a PDF to a new GdPicture Image.
public int PdfReaderExtractImage( int hPdf, int ImageNo );
Public Function PdfReaderExtractImage( ByVal hPdf As Integer, ByVal ImageNo As Integer ) As Integer
|
Parameters |
Description |
|
hPdf |
A PDF handle returned by the PdfReaderLoadFromFile or the PdfReaderLoadFromStream function. |
|
ImageNo |
The number of the bitmap in the page. Must be a value between 1 and PdfReaderGetImageCount. |
0: The image could not created. Use the GetStat() function to determine the reason this function failed.
Non-zero: GdPicture Image Identifier. The created image.
Extracting all bitmap of a PDF to a multipage TIFF
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim oGdPictureImaging As New GdPictureImaging oGdPictureImaging.SetLicenseNumber("XXX") 'Replace XXX by a valid demo or commercial KEY Dim ImageNo As Integer = 0 'Number of extracted bitmaps Dim TiffID As Integer = 0 'the multipage TIFF document ID Dim hPDF As Integer = oGdPictureImaging.PdfReaderLoadFromFile("c:input.pdf") Dim Status As GdPictureStatus = oGdPictureImaging.GetStat If oGdPictureImaging.GetStat = GdPictureStatus.OK Then For i As Integer = 1 To oGdPictureImaging.PdfReaderGetPageCount(hPDF) If Status = GdPictureStatus.OK Then If oGdPictureImaging.PdfReaderSelectPage(hPDF, i) Then For j As Integer = 1 To oGdPictureImaging.PdfReaderGetImageCount(hPDF) If Status = GdPictureStatus.OK Then Dim ImageID As Integer = oGdPictureImaging.PdfReaderExtractImage(hPDF, j) Status = oGdPictureImaging.GetStat If Status = GdPictureStatus.OK Then ImageNo += 1 If ImageNo = 1 Then 'Start the Multipage tiff document TiffID = ImageID Status = oGdPictureImaging.TiffSaveAsMultiPageFile(TiffID, "c:output.tif", TiffCompression.TiffCompressionAUTO) Else 'Add image to multipage tiff document Status = oGdPictureImaging.TiffAddToMultiPageFile(TiffID, ImageID) oGdPictureImaging.ReleaseGdPictureImage(ImageID) End If End If End If Next Else MsgBox("Error selecting page: " + Str(i)) Status = oGdPictureImaging.GetStat End If End If Next oGdPictureImaging.PdfReaderCloseDocument(hPDF) Else MsgBox("Can't open PDF") End If If TiffID <> 0 Then oGdPictureImaging.TiffCloseMultiPageFile(TiffID) If Status = GdPictureStatus.OK Then MsgBox("operation done with success !") Else MsgBox("an error occurred") End If End Sub
|
What do you think about this topic? Send feedback!
|
|
Copyright (c) 2009-2011 www.gdpicture.com. All rights reserved.
|