Pdf |
The PdfLoadOptions type exposes the following members.
Name | Description | |
---|---|---|
PdfLoadOptions | Initializes a new instance of the PdfLoadOptions class. |
Name | Description | |
---|---|---|
AllowGraphicHyperlinks | Gets or sets a value indicating whether to allow graphic hyperlinks. Default value: false. | |
ConversionMode | Gets or sets PDF document conversion mode. Default value: Flowing. | |
DefaultFont | Gets or sets the default font name used for measuring insignificant whitespace characters. Default value: Calibri. | |
DetectShadowChar | Returns or sets the mode indicating whether to fix character shadows. Default value: Auto. Auto: Quick shadow check. It practically doesn't slow down the conversion process. Disabled: Don't check for character shadows. It doesn't slow down the conversion process. It doesn't guarantee the correct rendering of character shadows. Enabled: Full shadow check. The conversion process can be significantly slowed down. | |
DetectTables | Gets or sets a value indicating whether to recreate tables or leave them as graphical lines. Default value: false. | |
KeepCharScaleAndSpacing | 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. | |
OCROptions | Gets and sets options to enable and adjust OCR (optical character recognition). | |
OptimizeImages | Gets or sets a value indicating whether to merge adjacent images into a one. Default value: true. | |
PageCount | Gets or sets the number of pages to load. Default value: MaxValue. | |
PageIndex | Gets or sets the 0-based index of the first page to load. Default value: 0. | |
Password | Gets or sets the password to open protected / encrypted PDF document. Default value: String.Empty. | |
PreserveEmbeddedFonts | Gets or sets a mode indicating whether to load embedded fonts from PDF and store them in document or skip them and use similar. Default value: Auto. | |
PreserveGraphics | Gets or sets a value indicating whether to load vector graphics from PDF or skip it. Default value: true. | |
PreserveImages | Gets or sets a value indicating whether to load images from PDF or skip them. Default value: true. | |
RasterizeVectorGraphics | Gets or sets a value indicating whether to rasterize complex vector graphics or leave them as is. Default value: true. | |
SelectedPages | Gets or sets an array with pages to load (0-based index). Setting PageIndex or PageCount properties are overrides SelectedPages. | |
ShapeAnchoring | Gets or sets a value indicating whether shape's coordinates are anchored relative to paragraph or not. Default value: true. | |
ShapeGrouping | Gets or sets a value indicating whether to group the shapes or not. Default value: true. | |
ShowInvisibleText | Gets or sets a value indicating whether to load invisible text or skip it. Default value: false. |
Name | Description | |
---|---|---|
NotifyPageProgress | Allows to define a progress indicator |
See Developer Guide: Load a PDF document into DocumentCore (dc) from a file
using System; using System.IO; using SautinSoft.Document; namespace Example { class Program { static void Main(string[] args) { // Get your free 100-day key here: // https://sautinsoft.com/start-for-free/ LoadPDFFromFile(); //LoadPDFFromStream(); } /// <summary> /// Loads a PDF document into DocumentCore (dc) from a file. /// </summary> /// <remarks> /// Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/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/help/net/developer-guide/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 pdfStream = new MemoryStream(fileBytes)) { // Specifying PdfLoadOptions we explicitly set that a loadable document is PDF. PdfLoadOptions pdfLO = new PdfLoadOptions() { // 'false' - means to load vector graphics as is. Don't transform it to raster images. RasterizeVectorGraphics = false, // The PDF format doesn't have real tables, in fact it's a set of orthogonal graphic lines. // In case of 'true' the component will detect and recreate tables from graphic lines. DetectTables = false, // 'Disabled' - Never load embedded fonts in PDF. Use the fonts with the same name installed at the system or similar by font metrics. // 'Enabled' - Always load embedded fonts in PDF. // 'Auto' - Load only embedded fonts missing in the system. In other case, use the system fonts. PreserveEmbeddedFonts = PropertyState.Auto, // Load only the 1st page from the document. PageIndex = 0, PageCount = 1 }; // Load a PDF document from the MemoryStream. dc = DocumentCore.Load(pdfStream, new PdfLoadOptions()); } if (dc != null) Console.WriteLine("Loaded successfully!"); Console.ReadKey(); } } }
Imports System Imports System.IO Imports SautinSoft.Document Module Sample Sub Main() LoadPDFFromFile() 'LoadPDFFromStream() End Sub ''' Get your free 100-day key here: ''' https://sautinsoft.com/start-for-free/ ''' <summary> ''' Loads a PDF document into DocumentCore (dc) from a file. ''' </summary> ''' <remarks> ''' Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/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/help/net/developer-guide/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 pdfStream As New MemoryStream(fileBytes) ' Specifying PdfLoadOptions we explicitly set that a loadable document is PDF. Dim pdfLO As New PdfLoadOptions() With pdfLO .RasterizeVectorGraphics = False .DetectTables = False ' 'Disabled' - Never load embedded fonts in PDF. Use the fonts with the same name installed at the system or similar by font metrics. ' 'Enabled' - Always load embedded fonts in PDF. ' 'Auto' - Load only embedded fonts missing in the system. In other case, use the system fonts. .PreserveEmbeddedFonts = PropertyState.Auto .PageIndex = 0 .PageCount = 1 End With ' RasterizeVectorGraphics = False ' This means to load vector graphics as is. Don't transform it to raster images. ' DetectTables = False ' This means don't detect tables. ' The PDF format doesn't have real tables, in fact it's a set of orthogonal graphic lines. ' Set it to 'True' and the component will detect and recreate tables from graphic lines. ' Load a PDF document from the MemoryStream. dc = DocumentCore.Load(pdfStream, New PdfLoadOptions()) End Using If dc IsNot Nothing Then Console.WriteLine("Loaded successfully!") End If Console.ReadKey() End Sub End Module