Error processing SSI file
LEADTOOLS PDF (Leadtools.Pdf assembly)

Show in webframe

DecodeImage Method






String that specifies the PDF image object number to decode.
Decodes the specified PDF image object embedded in this PDFDocument.
Syntax
public RasterImage DecodeImage( 
   string imageObjectNumber
)
'Declaration
 
Public Function DecodeImage( _
   ByVal imageObjectNumber As String _
) As RasterImage
'Usage
 
Dim instance As PDFDocument
Dim imageObjectNumber As String
Dim value As RasterImage
 
value = instance.DecodeImage(imageObjectNumber)
public RasterImage decodeImage(String imageObjectNumber)
public:
RasterImage^ DecodeImage( 
   String^ imageObjectNumber
) 

Parameters

imageObjectNumber
String that specifies the PDF image object number to decode.

Return Value

Example
Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Controls
Imports Leadtools.Pdf
Imports Leadtools.Svg
Imports Leadtools.WinForms

<TestMethod> _
Public Sub PDFDocumentDecodeImageExample()
  Dim sourceFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.pdf")
  Dim destinationFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "LEAD_pdfDecodeImage.tif")
  Using document As PDFDocument = New PDFDocument(sourceFileName)
    document.Resolution = 200

    ' Parse the objects in all pages
    document.ParsePages(PDFParsePagesOptions.Objects, 1, -1)

    Dim codecs As RasterCodecs = New RasterCodecs()
    For Each page As PDFDocumentPage In document.Pages
       If Not page.Objects Is Nothing AndAlso page.Objects.Count > 0 Then
         For Each obj As PDFObject In page.Objects
           If obj.ObjectType = PDFObjectType.Image Then
             Using image As RasterImage = document.DecodeImage(obj.ImageObjectNumber)
                codecs.Save(image, destinationFileName, RasterImageFormat.TifLzw, image.BitsPerPixel, 1, 1, -1, CodecsSavePageMode.Append)
             End Using
           End If
         Next obj
       End If
    Next page

    codecs.Dispose()
  End Using
End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Controls;
using Leadtools.Pdf;
using Leadtools.Svg;
using Leadtools.WinForms;

[TestMethod]
public void PDFDocumentDecodeImageExample()
{
   string sourceFileName = Path.Combine(LEAD_VARS.ImagesDir, @"Leadtools.pdf");
   string destinationFileName = Path.Combine(LEAD_VARS.ImagesDir, @"LEAD_pdfDecodeImage.tif");
   using (PDFDocument document = new PDFDocument(sourceFileName))
   {
      document.Resolution = 200;

      // Parse the objects in all pages
      document.ParsePages(PDFParsePagesOptions.Objects, 1, -1);

      RasterCodecs codecs = new RasterCodecs();
      foreach (PDFDocumentPage page in document.Pages)
         if (page.Objects != null && page.Objects.Count > 0)
            foreach (PDFObject obj in page.Objects)
               if (obj.ObjectType == PDFObjectType.Image)
                  using (RasterImage image = document.DecodeImage(obj.ImageObjectNumber))
                     codecs.Save(image, destinationFileName, RasterImageFormat.TifLzw, image.BitsPerPixel, 1, 1, -1, CodecsSavePageMode.Append);

      codecs.Dispose();
   }
}

static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Requirements

Target Platforms

See Also

Reference

PDFDocument Class
PDFDocument Members

Error processing SSI file
   Leadtools.Pdf requires a PDF Pro, Pro Suite, Document, or Medical license and unlock key. For more information, refer to: LEADTOOLS Toolkit Features