ASP.NET Core

Upgrade Guide User Guide Demos Support Forums Download
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class PdfImageExtractor - ASP.NETCore API Reference | Syncfusion

    Show / Hide Table of Contents

    Class PdfImageExtractor

    Inheritance
    System.Object
    PdfImageExtractor
    Namespace: Syncfusion.Pdf.Exporting
    Assembly: Syncfusion.Pdf.Imaging.Portable.dll
    Syntax
    public static class PdfImageExtractor : Object

    Methods

    ExtractImages(PdfPageBase)

    Extract the images from the PDF

    Declaration
    public static Image[] ExtractImages(this PdfPageBase page)
    Parameters
    Type Name Description
    PdfPageBase page
    Returns
    Type Description
    System.Drawing.Image[]

    returns the List of images

    Examples
     FileStream input = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read);
     PdfLoadedDocument loadedDocument = new PdfLoadedDocument(input);
     //Load first page.
     PdfPageBase pageBase = loadedDocument.Pages[0];
     //Extract images from first page.
     Image[] extractedImages = pageBase.ExtractImages();
     //close the document
    loadedDocument.Close(true);
     'Load PDF document.
     Dim input As New FileStream("Input.pdf", FileMode.Open, FileAccess.Read)
     Dim loadedDocument As New PdfLoadedDocument(input)
    'Load first page.
    Dim pageBase As PdfPageBase = loadedDocument.Pages(0)
    'Extract images from first page.
    Dim extractedImages As Image() = pageBase.ExtractImages()
    'close the document.
    loadedDocument.Close(True)

    GetImagesInfo(PdfPageBase)

    Gets the information about the extracted image from the PDF page

    Declaration
    public static PdfImageInfo[] GetImagesInfo(this PdfPageBase page)
    Parameters
    Type Name Description
    PdfPageBase page
    Returns
    Type Description
    PdfImageInfo[]
    Examples
    //Load PDF document.
    FileStream input = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read);
    PdfLoadedDocument document = new PdfLoadedDocument(input);
    //Gets ImageInfo from the first page.
    PdfImageInfo[] imageInfo = document.Pages[0].GetImagesInfo();
    //Gets the Image Boundary location.
    RectangleF imageBounds = imageInfo[0].Bounds;
    //Gets the Image.
    Image image = imageInfo[0].Image;
    //Gets the Image index.
    int imageIndex = imageInfo[0].Index;
    //Closing the PDF document.
    document.Close(true);
    'Load PDF document.
    Dim input As New FileStream("Input.pdf", FileMode.Open, FileAccess.Read)
    Dim document As New PdfLoadedDocument(input)
    'Gets ImageInfo from the first page.
    Dim imageInfo As PdfImageInfo() = document.Pages(0).GetImagesInfo()
    'Gets the Image Boundary location.
    Dim imageBounds As RectangleF = imageInfo(0).Bounds
    'Gets the Image.
    Dim image As Image = imageInfo(0).Image
    'Gets the Image index.
    Dim imageIndex As Integer = imageInfo(0).Index
    'Closing the PDF document.
    document.Close(True)
    See Also
    PdfDocument
    PdfPage

    ReplaceImage(PdfPageBase, Int32, PdfImage)

    Replace the Image at index's Position.

    Declaration
    public static void ReplaceImage(this PdfPageBase page, int index, PdfImage image)
    Parameters
    Type Name Description
    PdfPageBase page
    System.Int32 index

    index of an image

    PdfImage image

    The New Replace image

    Examples
     //Load the PDF document
     FileStream input = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read);
     PdfLoadedDocument doc = new PdfLoadedDocument(input);
     //Create an image instance
     PdfBitmap bmp = new PdfBitmap(new FileStream("Autumn Leaves.jpg", FileMode.Open, FileAccess.Read));
     //Replace the first image in the page.
     doc.Pages[0].ReplaceImage(0, bmp);
     MemoryStream stream = new MemoryStream();
     //Save the document
     doc.Save(stream);
     //Close the document
     doc.Close(true);
     'Load the PDF document
     Dim input As New FileStream("Input.pdf", FileMode.Open, FileAccess.Read)
     Dim doc As New PdfLoadedDocument(input)
     Dim input As New FileStream("Autumn Leaves.jpg", FileMode.Open, FileAccess.Read)
     'Create an image instance
     Dim bmp As New PdfBitmap(input)
     'Replace the first image in the page.
     doc.Pages(0).ReplaceImage(0, bmp)
     Dim stream As New MemoryStream()
     'Save the document
     doc.Save(stream)
     'Close the document
     doc.Close(True)
    Back to top Generated by DocFX
    Copyright © 2001 - 2021 Syncfusion Inc. All Rights Reserved