Click or drag to resize

PdfLoadOptions Class

Represents a class that stores loading options for Portable Document Format (PDF).
Inheritance Hierarchy

Namespace:  SautinSoft.Document
Assembly:  SautinSoft.Document (in SautinSoft.Document.dll) Version: 3.7.4.3 (3.7.4.3)
Syntax
public sealed class PdfLoadOptions : LoadOptions

The PdfLoadOptions type exposes the following members.

Constructors
  NameDescription
Public methodCode examplePdfLoadOptions
Initializes a new instance of the PdfLoadOptions class.
Top
Properties
  NameDescription
Public propertyConversionMode
Gets or sets PDF document conversion mode. Default value: Flowing.
Public propertyDetectTables
Gets or sets a value indicating whether to recreate tables or leave them as graphical lines. Default value: true.
Public propertyKeepCharScaleAndSpacing
Gets or sets a value indicating whether to keep the original char scaling and spacing or reset it to all symbols to 100%. Default value: true.
Public propertyOCRMode
Gets or sets OCR mode. Default value: Disabled.
Public propertyOptimizeImages
Gets or sets a value indicating whether to merge adjacent images into a one. Default value: false.
Public propertyCode examplePageCount
Gets or sets the number of pages to load. Default value: MaxValue.
Public propertyPageIndex
Gets or sets the 0-based index of the first page to load. Default value: 0.
Public propertyPassword
Gets or sets the password to open protected / encrypted PDF document. Default value: String.Empty.
Public propertyPreserveEmbeddedFonts
Gets or sets a value indicating whether to load embedded fonts from PDF and store them in document or skip it. Default value: false.
Public propertyPreserveGraphics
Gets or sets a value indicating whether to load vector graphics from PDF or skip it. Default value: true.
Public propertyPreserveImages
Gets or sets a value indicating whether to load images from PDF or skip them. Default value: true.
Public propertyPreserveUnsupportedFeatures
Gets or sets a value indicating whether to preserve file format features that are not directly supported.
(Inherited from LoadOptions.)
Public propertyRasterizeVectorGraphics
Gets or sets a value indicating whether to rasterize complex vector graphics or leave them as is. Default value: true.
Public propertySelectedPages
Gets or sets an array with pages to load (0-based index). Setting PageIndex or PageCount properties are overrides SelectedPages.
Public propertyShapeAnchoring
Gets or sets a value indicating whether shape's coordinates are anchored relative to paragraph or not. Default value: true.
Public propertyShapeGrouping
Gets or sets a value indicating whether to group the shapes or not. Default value: true.
Public propertyShowInvisibleText
Gets or sets a value indicating whether to load invisible text or skip it. Default value: false.
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Events
  NameDescription
Public eventNotifyPageProgress
Allows to define a progress indicator
Public eventOCR
This event arises during the component finds a scanned image in PDF document and supposes that the image may be recognized by OCR. Default value: null.
Top
Examples
Loads a PDF document into DocumentCore using C#
using System;
using System.IO;
using SautinSoft.Document;

namespace Example
{
    class Program
    {

        static void Main(string[] args)
        {
            LoadPDFFromFile();
            //LoadPDFFromStream();
        }

        /// <summary>
        /// Loads a PDF document into DocumentCore (dc) from a file.
        /// </summary>
        /// <remarks>
        /// Details: https://www.sautinsoft.com/products/document/examples/load-pdf-document-net-csharp-vb.php
        /// </remarks>
        static void LoadPDFFromFile()
        {
            string filePath = @"..\..\example.pdf";

            // The file format is detected automatically from the file extension: ".pdf".
            // But as shown in the example below, we can specify PdfLoadOptions as 2nd parameter
            // to explicitly set that a loadable document has PDF format.
            DocumentCore dc = DocumentCore.Load(filePath);

            if (dc != null)
                Console.WriteLine("Loaded successfully!");

            Console.ReadKey();            
        }

        /// <summary>
        /// Loads a PDF document into DocumentCore (dc) from a MemoryStream.
        /// </summary>
        /// <remarks>
        /// Details: https://www.sautinsoft.com/products/document/examples/load-pdf-document-net-csharp-vb.php
        /// </remarks>
        static void LoadPDFFromStream()
        {
            // Assume that we already have a PDF document as bytes array.
            byte[] fileBytes = File.ReadAllBytes(@"..\..\example.pdf");

            DocumentCore dc = null;

            // Create a MemoryStream
            using (MemoryStream ms = new MemoryStream(fileBytes))
            {
                // Specifying PdfLoadOptions we explicitly set that a loadable document is PDF.
                // Also we specified here to load only 1st page and
                // switched off the 'OptimizeImage' to not merge adjacent images into a one.
                PdfLoadOptions pdfLO = new PdfLoadOptions()
                {
                    PageCount = 1,
                    OptimizeImages = false
                };

                // Load a PDF document from the MemoryStream.
                dc = DocumentCore.Load(ms, new PdfLoadOptions());
            }
            if (dc != null)
                Console.WriteLine("Loaded successfully!");

            Console.ReadKey();            
        }
    }
}
Loads a PDF document into DocumentCore using VB.Net
Imports System
Imports System.IO
Imports SautinSoft.Document

Module Sample
    Sub Main()
        LoadPDFFromFile()
        'LoadPDFFromStream();
    End Sub

    ''' <summary>
    ''' Loads a PDF document into DocumentCore (dc) from a file.
    ''' </summary>
    ''' <remarks>
    ''' Details: https://www.sautinsoft.com/products/document/examples/load-pdf-document-net-csharp-vb.php
    ''' </remarks>
    Sub LoadPDFFromFile()
        Dim filePath As String = "..\example.pdf"

        ' The file format is detected automatically from the file extension: ".pdf".
        ' But as shown in the example below, we can specify PdfLoadOptions as 2nd parameter
        ' to explicitly set that a loadable document has PDF format.
        Dim dc As DocumentCore = DocumentCore.Load(filePath)

        If dc IsNot Nothing Then
            Console.WriteLine("Loaded successfully!")
        End If

        Console.ReadKey()        
    End Sub

    ''' <summary>
    ''' Loads a PDF document into DocumentCore (dc) from a MemoryStream.
    ''' </summary>
    ''' <remarks>
    ''' Details: https://www.sautinsoft.com/products/document/examples/load-pdf-document-net-csharp-vb.php
    ''' </remarks>
    Sub LoadPDFFromStream()
        ' Assume that we already have a PDF document as bytes array.
        Dim fileBytes() As Byte = File.ReadAllBytes("..\example.pdf")

        Dim dc As DocumentCore = Nothing

        ' Create a MemoryStream
        Using ms As New MemoryStream(fileBytes)
            ' Specifying PdfLoadOptions we explicitly set that a loadable document is PDF.
            ' Also we specified here to load only 1st page and
            ' switched off the 'OptimizeImage' to not merge adjacent images into a one.
            Dim pdfLO As New PdfLoadOptions() With {
                .PageCount = 1,
                .OptimizeImages = False
            }

            ' Load a PDF document from the MemoryStream.
            dc = DocumentCore.Load(ms, New PdfLoadOptions())
        End Using
        If dc IsNot Nothing Then
            Console.WriteLine("Loaded successfully!")
        End If

        Console.ReadKey()        
    End Sub
End Module
See Also