Class PdfLoadedDocument
Represents a PdfLoadedDocument. You can use this class to load or modify an existing PDF document
Implements
Inherited Members
Namespace: Syncfusion.Pdf.Parsing
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfLoadedDocument : PdfDocumentBase, IDisposable
Examples
// Loads an existing document
PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf");
lDoc.Save("Output.pdf");
lDoc.Close(true);
' Loads an existing document
Dim lDoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
lDoc.Save("Output.pdf")
lDoc.Close(True)
Constructors
PdfLoadedDocument(Byte[])
Initializes a new instance of the PdfLoadedDocument class with the specified byte array.
Declaration
public PdfLoadedDocument(byte[] file)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | file | The array of bytes containing the PDF document to load. |
Examples
Stream file2 = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read, FileShare.Read);
// Create a byte array of file stream length
byte[] pdfData = new byte[file2.Length];
//Read block of bytes from stream into the byte array
file2.Read(pdfData,0,System.Convert.ToInt32(pdfData.Length));
// Load the byte array
PdfLoadedDocument doc = new PdfLoadedDocument(pdfData);
doc.Save("Output.pdf");
doc.Close(true);
Dim file2 As Stream = New FileStream("sample.pdf", FileMode.Open, FileAccess.Read, FileShare.Read)
' Create a byte array of file stream length
Dim pdfData() As Byte = New Byte(file2.Length){}
'Read block of bytes From stream Into the Byte array
file2.Read(pdfData,0,System.Convert.ToInt32(pdfData.Length))
' Load the byte array
Dim doc As PdfLoadedDocument = New PdfLoadedDocument(pdfData)
doc.Save("Output.pdf")
doc.Close(True)
PdfLoadedDocument(Byte[], Boolean)
Initializes a new instance of the PdfLoadedDocument class with specified byte array and repair document.
Declaration
public PdfLoadedDocument(byte[] file, bool openAndRepair)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | file | The array of bytes containing the PDF document to load. |
System.Boolean | openAndRepair | True to repair the document to prevent document corruption |
Remarks
This constructor loads the document and also repairs the wrong offsets. The repairing engine is not capable of fixing all kinds of corruption and the process may delay the loading time depending on the type of issue.
Examples
Stream file2 = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read, FileShare.Read);
// Create a byte array of file stream length
byte[] pdfData = new byte[file2.Length];
//Read block of bytes from stream into the byte array
file2.Read(pdfData,0,System.Convert.ToInt32(pdfData.Length));
// Load the byte array
PdfLoadedDocument doc = new PdfLoadedDocument(pdfData, true);
doc.Save("Output.pdf");
doc.Close(true);
Dim file2 As Stream = New FileStream("Input.pdf", FileMode.Open, FileAccess.Read, FileShare.Read)
' Create a byte array of file stream length
Dim pdfData() As Byte = New Byte(file2.Length){}
'Read block of bytes From stream Into the Byte array
file2.Read(pdfData,0,System.Convert.ToInt32(pdfData.Length))
' Load the byte array
Dim doc As PdfLoadedDocument = New PdfLoadedDocument(pdfData, True)
doc.Save("Output.pdf")
doc.Close(True)
PdfLoadedDocument(Byte[], String)
Initializes a new instance of the PdfLoadedDocument class with the specified byte array and password.
Declaration
public PdfLoadedDocument(byte[] file, string password)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | file | The array of bytes containing the PDF document to load. |
System.String | password | The password (user or owner) of the encrypted document. |
Examples
Stream file2 = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read, FileShare.Read);
// Create a byte array of file stream length
byte[] pdfData = new byte[file2.Length];
//Read block of bytes from stream into the byte array
file2.Read(pdfData,0,System.Convert.ToInt32(pdfData.Length));
// Load the byte array
PdfLoadedDocument doc = new PdfLoadedDocument(pdfData,"password");
doc.Save("Output.pdf");
doc.Close(true);
Dim file2 As Stream = New FileStream("Input.pdf", FileMode.Open, FileAccess.Read, FileShare.Read)
' Create a byte array of file stream length
Dim pdfData() As Byte = New Byte(file2.Length){}
'Read block of bytes From stream Into the Byte array
file2.Read(pdfData,0,System.Convert.ToInt32(pdfData.Length))
' Load the byte array
Dim doc As PdfLoadedDocument = New PdfLoadedDocument(pdfData,"password")
doc.Save("Output.pdf")
doc.Close(True)
PdfLoadedDocument(Byte[], String, Boolean)
Initializes a new instance of the PdfLoadedDocument class.
Declaration
public PdfLoadedDocument(byte[] file, string password, bool openAndRepair)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | file | The array of bytes containing the PDF document to load. |
System.String | password | The password (user or owner) of the encrypted document. |
System.Boolean | openAndRepair | True to repair the document to prevent document corruption |
Remarks
This constructor loads the document and also repairs the wrong offsets. The repairing engine is not capable of fixing all kinds of corruption and the process may delay the loading time depending on the type of issue.
Examples
Stream file2 = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read, FileShare.Read);
// Create a byte array of file stream length
byte[] pdfData = new byte[file2.Length];
//Read block of bytes from stream into the byte array
file2.Read(pdfData,0,System.Convert.ToInt32(pdfData.Length));
// Load the byte array
PdfLoadedDocument doc = new PdfLoadedDocument(pdfData,"password",true);
doc.Save("Output.pdf");
doc.Close(true);
Dim file2 As Stream = New FileStream("Input.pdf", FileMode.Open, FileAccess.Read, FileShare.Read)
' Create a byte array of file stream length
Dim pdfData() As Byte = New Byte(file2.Length){}
'Read block of bytes From stream Into the Byte array
file2.Read(pdfData,0,System.Convert.ToInt32(pdfData.Length))
' Load the byte array
Dim doc As PdfLoadedDocument = New PdfLoadedDocument(pdfData,"password",True)
doc.Save("Output.pdf")
doc.Close(True)
PdfLoadedDocument(Stream)
Initializes a new instance of the PdfLoadedDocument class with the specified stream.
Declaration
public PdfLoadedDocument(Stream file)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | file | The stream containing the PDF document to load. |
Examples
Stream file2 = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read, FileShare.Read);
// Load the stream
PdfLoadedDocument doc = new PdfLoadedDocument(file2);
doc.Save("Output.pdf");
doc.Close(true);
Dim file2 As Stream = New FileStream("Input.pdf", FileMode.Open, FileAccess.Read, FileShare.Read)
' Load the stream
Dim doc As PdfLoadedDocument = New PdfLoadedDocument(file2)
doc.Save("Output.pdf")
doc.Close(True)
PdfLoadedDocument(Stream, Boolean)
Initializes a new instance of the PdfLoadedDocument class.
Declaration
public PdfLoadedDocument(Stream file, bool openAndRepair)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | file | The stream containing the PDF document to load |
System.Boolean | openAndRepair | True to repair the document to prevent document corruption. |
Remarks
This constructor loads the document and also repairs the wrong offsets. The repairing engine is not capable of fixing all kinds of corruption and the process may delay the loading time depending on the type of issue.
Examples
Stream file2 = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read, FileShare.Read);
// Load the stream
PdfLoadedDocument doc = new PdfLoadedDocument(file2, true);
doc.Save("Output.pdf");
doc.Close(true);
Dim file2 As Stream = New FileStream("Input.pdf", FileMode.Open, FileAccess.Read, FileShare.Read)
' Load the stream
Dim doc As PdfLoadedDocument = New PdfLoadedDocument(file2, True)
doc.Save("Output.pdf")
doc.Close(True)
PdfLoadedDocument(Stream, String)
Initializes a new instance of the PdfLoadedDocument class.
Declaration
public PdfLoadedDocument(Stream file, string password)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | file | The stream containing the PDF document to load. |
System.String | password | The password (user or owner) of the encrypted document. |
Examples
Stream file2 = new FileStream("sample.pdf", FileMode.Open, FileAccess.Read, FileShare.Read);
// Load the stream
PdfLoadedDocument doc = new PdfLoadedDocument(file2, "password");
doc.Save("Samplepdf.pdf");
Dim file2 As Stream = New FileStream("sample.pdf", FileMode.Open, FileAccess.Read, FileShare.Read)
' Load the stream
Dim doc As PdfLoadedDocument = New PdfLoadedDocument(file2, "password")
doc.Save("Samplepdf.pdf")
PdfLoadedDocument(Stream, String, Boolean)
Initializes a new instance of the PdfLoadedDocument class.
Declaration
public PdfLoadedDocument(Stream file, string password, bool openAndRepair)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | file | The stream containing the PDF document to load. |
System.String | password | The password (user or owner) of the encrypted document. |
System.Boolean | openAndRepair |
Examples
Stream file2 = new FileStream("sample.pdf", FileMode.Open, FileAccess.Read, FileShare.Read);
// Load the stream
PdfLoadedDocument doc = new PdfLoadedDocument(file2, "password", true);
doc.Save("Samplepdf.pdf");
Dim file2 As Stream = New FileStream("sample.pdf", FileMode.Open, FileAccess.Read, FileShare.Read)
' Load the stream
Dim doc As PdfLoadedDocument = New PdfLoadedDocument(file2, "password", True)
doc.Save("Samplepdf.pdf")
PdfLoadedDocument(String)
Declaration
public PdfLoadedDocument(string filename)
Parameters
Type | Name | Description |
---|---|---|
System.String | filename | A relative or absolute path for the file. |
Remarks
This constructor is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight
Examples
// Loads an existing PDF Document
PdfLoadedDocument doc = new PdfLoadedDocument("Input.pdf");
// Save the document to a disk
doc.Save("Output.pdf");
doc.Close(true);
' Loads an existing PDF Document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
' Save the document to a disk
doc.Save("Output.pdf")
doc.Close(True)
See Also
PdfLoadedDocument(String, Boolean)
Initializes a new instance of the PdfLoadedDocument class with the specified input file path and repair document
Declaration
public PdfLoadedDocument(string filename, bool openAndRepair)
Parameters
Type | Name | Description |
---|---|---|
System.String | filename | A relative or absolute path for the file. |
System.Boolean | openAndRepair | True to repair the document to prevent document corruption |
Remarks
This constructor loads the document and also repairs the wrong offsets. The repairing engine is not capable of fixing all kinds of corruption and the process may delay the loading time depending on the type of issue. This constructor is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
// Loads an existing PDF Document
PdfLoadedDocument doc = new PdfLoadedDocument("Input.pdf", true);
// Save the document to a disk
doc.Save("Output.pdf");
doc.Close(true);
' Loads an existing PDF Document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf", True)
' Save the document to a disk
doc.Save("Output.pdf")
doc.Close(True)
See Also
PdfLoadedDocument(String, String)
Initializes a new instance of the PdfLoadedDocument class with the specified input file path and password
Declaration
public PdfLoadedDocument(string filename, string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | filename | A relative or absolute path for the file. |
System.String | password | The password (user or owner) of the encrypted document to open. |
Remarks
This constructor is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight
Examples
// Load the PDF document with password.
PdfLoadedDocument doc = new PdfLoadedDocument("Input.pdf","password");
doc.Save("Output.pdf");
doc.Close(true);
' Load the PDF document with password.
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf", "password")
doc.Save("Output.pdf")
doc.Close(True)
PdfLoadedDocument(String, String, Boolean)
Initializes a new instance of the PdfLoadedDocument class with the specified password and repair document.
Declaration
public PdfLoadedDocument(string filename, string password, bool openAndRepair)
Parameters
Type | Name | Description |
---|---|---|
System.String | filename | A relative or absolute path for the file. |
System.String | password | The password (user or owner) of the encrypted document to open. |
System.Boolean | openAndRepair | True to repair the document to prevent document corruption |
Remarks
This constructor loads the document and also repairs the wrong offsets. The repairing engine is not capable of fixing all kinds of corruption and the process may delay the loading time depending on the type of issue. This constructor is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
// Load the PDF document with password.
PdfLoadedDocument doc = new PdfLoadedDocument("Input.pdf", "password", true);
doc.Save("Output.pdf");
doc.Close(true);
' Load the PDF document with password.
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf", "password", True)
doc.Save("Output.pdf")
doc.Close(True)
Properties
Actions
Gets the actions to be performed when the document is opened/closed.
Declaration
public PdfDocumentActions Actions { get; }
Property Value
Type |
---|
PdfDocumentActions |
Remarks
This property has impact on javascript actions only.
Examples
//Load a PDF document
PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf");
//Load and change new javascript action to the document
ldoc.Actions.AfterOpen = new PdfJavaScriptAction("app.alert(\"Content Changed!\")");
//Save the document
ldoc.Save("Output.pdf");
//Close the document
ldoc.Close(true);
'Load a PDF document.
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
'Load and change new javascript action to the document.
ldoc.Actions.AfterOpen = new PdfJavaScriptAction("app.alert(\"Content Changed!\")")
'Save the document
ldoc.Save("Output.pdf")
'Close the document
ldoc.Close(True)
Attachments
Gets the list of attachments embedded in the document.
Declaration
public PdfAttachmentCollection Attachments { get; }
Property Value
Type |
---|
PdfAttachmentCollection |
Examples
// Loads an existing document
PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf");
// Gets the collection of attachments embedded in the document.
PdfAttachmentCollection collection = lDoc.Attachments;
// Creating an attachment
PdfAttachment attachment = new PdfAttachment("logo.jpeg");
attachment.FileName = "Syncfusion Logo";
// Adding attachments to an existing document
collection.Add(attachment);
lDoc.Save("Output.pdf");
lDoc.Close(true);
' Loads an existing document
Dim lDoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
' Gets the collection of attachments displayed on a PDF page.
Dim collection As PdfAttachmentCollection = lDoc.Attachments
' Creating an attachment
Dim attachment As PdfAttachment = New PdfAttachment("logo.jpeg")
attachment.FileName = "Syncfusion Logo"
' Adding attachments to an existing document
collection.Add(attachment)
lDoc.Save("Output.pdf")
lDoc.Close(True)
See Also
Bookmarks
Gets the list of bookmarks in the PDF document.
Declaration
public override PdfBookmarkBase Bookmarks { get; }
Property Value
Type |
---|
PdfBookmarkBase |
Overrides
Examples
// Loads an existing document
PdfLoadedDocument lDoc = new PdfLoadedDocument("sourceDoc.pdf");
// Reading bookmark collection from an existing document
PdfBookmarkBase bm = lDoc.Bookmarks;
// Creates a new bookmark
PdfBookmark newbm = bm.Add("Chapter1");
newbm.Color = Color.DarkBlue;
newbm.TextStyle = PdfTextStyle.Bold;
newbm.Destination = new PdfDestination( lDoc.Pages[0]);
lDoc.Save("BookMark.pdf");
' Loads an existing document
Dim lDoc As PdfLoadedDocument = New PdfLoadedDocument("sourceDoc.pdf")
' Reading bookmark collection from an existing document
Dim bm As PdfBookmarkBase = lDoc.Bookmarks
' Creates a new bookmark
Dim newbm As PdfBookmark = bm.Add("Chapter1")
newbm.Color = Color.DarkBlue
newbm.TextStyle = PdfTextStyle.Bold
newbm.Destination = New PdfDestination(lDoc.Pages(0))
lDoc.Save("BookMark.pdf")
See Also
ColorSpace
Gets or sets the color space of the document. This property can be used to create PDF document in RGB, Grayscale or CMYK color spaces. By default the document uses RGB color space.
Declaration
public PdfColorSpace ColorSpace { get; set; }
Property Value
Type |
---|
PdfColorSpace |
Remarks
This property has impact on the new created pages only.
Examples
// Loads an existing document
PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf");
// Sets the documents colorSpace as GrayScale
lDoc.ColorSpace = PdfColorSpace.GrayScale;
lDoc.Save("Output.pdf");
lDoc.Close(true);
' Loads an existing document
Dim lDoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
'Sets the documents colorSpace as GrayScale
lDoc.ColorSpace = PdfColorSpace.GrayScale
lDoc.Save("Output.pdf")
lDoc.Close(True)
See Also
CompressionOptions
Gets or sets the compression options.
Declaration
public PdfCompressionOptions CompressionOptions { get; set; }
Property Value
Type |
---|
PdfCompressionOptions |
Examples
//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("input.pdf");
//Create new compression options instance.
dfCompressionOptions options = new PdfCompressionOptions();
//Set image compression.
options.CompressImages = true;
//Set image quality.
options.ImageQuality = 50;
//Optimize font.
options.OptimizeFont = true;
//Optimize page contents.
options.OptimizePageContents = true;
//Remove metadata information.
options.RemoveMetadata = true;
//Set compression options.
doc.CompressionOptions = options;
//Save and close the PDF document.
doc.Save("output.pdf");
doc.Close(true);
'Load an existing document
Dim doc As New PdfLoadedDocument("input.pdf")
'Create new compression options instance.
Dim options As New PdfCompressionOptions()
'Set image compression.
options.CompressImages = True
'Set image quality.
options.ImageQuality = 50
'Optimize font.
options.OptimizeFont = True
'Optimize page contents.
options.OptimizePageContents = True
'Remove metadata information.
options.RemoveMetadata = True
'Set compression options.
doc.CompressionOptions = options
'Save and close the PDF document.
doc.Save("output.pdf")
doc.Close(True)
Conformance
Gets the conformance level applied to the loaded document.
Declaration
public PdfConformanceLevel Conformance { get; set; }
Property Value
Type |
---|
PdfConformanceLevel |
Remarks
Returns only levels supported by PdfConformanceLevel enum, otherwise None. This method is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
//Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("input.pdf");
//Get the confirmation level.
PdfConformanceLevel level = document.Conformance;
//Close the document.
document.Close(true);
'Load an existing document
Dim document As New PdfLoadedDocument("input.pdf")
'Get the confirmation level.
Dim level As PdfConformanceLevel = document.Conformance
'Close the document.
document.Close(True)
See Also
DocumentInformation
Gets the document's information such as documents title, keywords, subject etc.,
Declaration
public override PdfDocumentInformation DocumentInformation { get; }
Property Value
Type |
---|
PdfDocumentInformation |
Overrides
Examples
//Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("input.pdf");
//Get the document information.
PdfDocumentInformation inform = document.DocumentInformation;
//Get author of the document.
string author = inform.Author;
MemoryStream stream = new MemoryStream();
//Save the document.
document.Save(stream);
//Close the document.
document.Close(true);
'Load an existing document
Dim document As New PdfLoadedDocument("input.pdf")
'Get the document information.
Dim inform As PdfDocumentInformation = document.DocumentInformation
'Get author of the document.
Dim author As String = inform.Author
Dim stream As New MemoryStream()
'Save the document.
document.Save(stream)
'Close the document.
document.Close(True)
DocumentSecureStore
Access the Document Security Store (DSS) details.
Declaration
public PdfDocumentSecureStore DocumentSecureStore { get; }
Property Value
Type |
---|
PdfDocumentSecureStore |
Examples
//Load the existing PDF document.
PdfLoadedDocument ldoc = new PdfLoadedDocument(fileStream);
//Get the document secure store.
PdfDocumentSecureStore dss = ldoc.DocumentSecureStore;
// Close the document
document.Close(true);
Form
Gets the PDF form fields included in the document.
Declaration
public PdfLoadedForm Form { get; }
Property Value
Type |
---|
PdfLoadedForm |
Examples
// Load the PDF form
PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf");
// Gets the form from the existing document
PdfLoadedForm form = lDoc.Form;
// Reading field element
PdfLoadedTextBoxField textField = form[0] as PdfLoadedTextBoxField;
textField.Text = "Syncfusion";
lDoc.Save("Output.pdf");
lDoc.Close(true);
' Loads an existing document
Dim lDoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
' Gets the form from the existing document
Dim form As PdfLoadedForm = lDoc.Form
' Reading field element
Dim textField As PdfLoadedTextBoxField = TryCast(form(0), PdfLoadedTextBoxField)
textField.Text = "Syncfusion"
lDoc.Save("Output.pdf")
lDoc.Close(True)
See Also
ImageExportSettings
Gets the instance of the class.
Declaration
public ImageExportSettings ImageExportSettings { get; }
Property Value
Type |
---|
ImageExportSettings |
IsAllFontsEmbedded
Gets a value that indicates whether the document fonts are embedded or not. .
Declaration
public bool IsAllFontsEmbedded { get; }
Property Value
Type |
---|
System.Boolean |
Examples
//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("input.pdf");
//Get extended feature enabled
bool isAllFontsEmbedded = doc.IsAllFontsEmbedded;
//Save and close the PDF document.
doc.Save("output.pdf");
doc.Close(true);
'Load an existing document
Dim doc As New PdfLoadedDocument("input.pdf")
'Get extended feature enabled.
Dim isAllFontsEmbedded As Boolean = doc.IsAllFontsEmbedded
doc.Save("output.pdf")
doc.Close(true)
IsEncrypted
Gets whether the document is encrypted or not.
Declaration
public bool IsEncrypted { get; }
Property Value
Type |
---|
System.Boolean |
Examples
//Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("input.pdf");
//Gets whether the document is encrypted?
bool isEncrypted = document.IsEncrypted;
MemoryStream stream = new MemoryStream();
//Save the document.
document.Save(stream);
//Close the document.
document.Close(true);
'Load an existing document
Dim document As New PdfLoadedDocument("input.pdf")
'Gets whether the document is encrypted?
Dim isEncrypted As Boolean = document.IsEncrypted
Dim stream As New MemoryStream()
'Save the document.
document.Save(stream)
'Close the document.
document.Close(True)
IsExtendedFeatureEnabled
Returns true, when the PDF document has extended features enabled, otherwise it returns false.
Declaration
public bool IsExtendedFeatureEnabled { get; }
Property Value
Type |
---|
System.Boolean |
Examples
//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("input.pdf");
//Get extended feature enabled
bool extendedFeature = doc.IsExtendedFeatureEnabled;
//Save and close the PDF document.
doc.Save("output.pdf");
doc.Close(true);
'Load an existing document
Dim doc As New PdfLoadedDocument("input.pdf")
'Get extended feature enabled.
Dim extendedFeature As Boolean = doc.IsExtendedFeatureEnabled
doc.Save("output.pdf")
doc.Close(true)
IsLinearized
Gets whether the document is linearized or not
Declaration
public bool IsLinearized { get; }
Property Value
Type |
---|
System.Boolean |
Examples
//Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("input.pdf");
//Get the document is linearisze.
bool linearizedDocument = document.IsLinearized;
//Close the document.
document.Close(true);
'Load an existing document
Dim document As New PdfLoadedDocument("input.pdf")
'Get the document is linearisze.
Dim linearizedDocument As Boolean = document.IsLinearized
'Close the document.
document.Close(True)
IsPortfolio
Gets whether the document has portfolio content or not
Declaration
public bool IsPortfolio { get; }
Property Value
Type |
---|
System.Boolean |
Examples
//Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("input.pdf");
//Check portfolio
bool portfolio = document.IsPortfolio;
//Close the document.
document.Close(true);
'Load an existing document
Dim document As New PdfLoadedDocument("input.pdf")
'Check portfolio
Dim portfolio As Boolean = document.IsPortfolio
'Close the document.
document.Close(True)
LoadedPageLabel
Gests or sets the PdfPageLabel for the loaded PDF document page number.
Declaration
public PdfPageLabel LoadedPageLabel { get; set; }
Property Value
Type |
---|
PdfPageLabel |
Examples
// Loads an existing document
PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf");
// Create page label with upper case roman letters and starts with 1
PdfPageLabel label = new PdfPageLabel();
label.NumberStyle = PdfNumberStyle.UpperRoman;
label.StartNumber = 1;
lDoc.LoadedPageLabel = label;
lDoc.Save("Output.pdf");
lDoc.Close(true);
' Loads an existing document
Dim lDoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
' Create page label with upper case roman letters and starts with 1
Dim label As PdfPageLabel = New PdfPageLabel()
label.NumberStyle = PdfNumberStyle.UpperRoman
label.StartNumber = 1
lDoc.LoadedPageLabel = label
lDoc.Save("Output.pdf")
lDoc.Close(True)
See Also
NamedDestinationCollection
Gets the list of named destinations in the PDF document.
Declaration
public PdfNamedDestinationCollection NamedDestinationCollection { get; }
Property Value
Type |
---|
PdfNamedDestinationCollection |
Examples
// Loads an existing document
PdfLoadedDocument lDoc = new PdfLoadedDocument("sourceDoc.pdf");
// Reading named destination collection from an existing document
PdfNamedDestinationCollection destinationCollection = lDoc.NamedDestinationCollection;
// Creates a new named destination
PdfNamedDestination newNamedDestination = new PdfNamedDestination("Chapter1");
newNamedDestination.Destination = new PdfDestination( lDoc.Pages[0]);
destinationCollection.Add(newNamedDestination);
lDoc.Save("NamedDestination.pdf");
' Loads an existing document
Dim lDoc As PdfLoadedDocument = New PdfLoadedDocument("sourceDoc.pdf")
' Reading named destination collection from an existing document
Dim destinationCollection As PdfNamedDestinationCollection = lDoc.NamedDestinationCollection
' Creates a new named destination
Dim newNamedDestination As PdfNamedDestination = New PdfNamedDestination("Chapter1")
newNamedDestination.Destination = New PdfDestination(lDoc.Pages(0))
destinationCollection.Add(newNamedDestination)
lDoc.Save("NamedDestination.pdf")
See Also
Pages
Gets the document's collection of pages.
Declaration
public PdfLoadedPageCollection Pages { get; }
Property Value
Type |
---|
PdfLoadedPageCollection |
Examples
// Loads an existing document
PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf");
// Reading page collection from an existing document
PdfLoadedPageCollection pageCollection = lDoc.Pages;
//Creates a new page
pageCollection.Add();
lDoc.Save("Output.pdf");
lDoc.Close(true);
' Loads an existing document
Dim lDoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
' Reading page collection from an existing document
Dim pageCollection As PdfLoadedPageCollection = lDoc.Pages
' Create a page
pageCollection.Add()
lDoc.Save("Output.pdf")
lDoc.Close(True)
See Also
PdfPageTemplates
Gets the list of PdfPageTemplateCollection in the PDF document.
Declaration
public PdfPageTemplateCollection PdfPageTemplates { get; }
Property Value
Type |
---|
PdfPageTemplateCollection |
Examples
// Loads an existing PDF Document
PdfLoadedDocument loadedDocument = new PdfLoadedDocument("input.pdf");
//Get the first page of the document
PdfPageBase page = loadedDocument.Pages[0];
//Create a page template
PdfPageTemplate pageTemplate = new PdfPageTemplate(page);
//Sets the PdfPageTemplate name
pageTemplate.Name = "pageTemplate";
//Sets the PdfPageTemplate is visible
pageTemplate.IsVisible = true;
//Adds the page template
loadedDocument.PdfPageTemplates.Add(pageTemplate);
//Save the document
loadedDocument.Save("output.pdf");
//Close the document
loadedDocument.Close(true);
'Loads an existing PDF Document
Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("input.pdf")
'Get the first page of the document
Dim page As PdfPageBase = loadedDocument.Pages(0)
'Create a page template
Dim pageTemplate As PdfPageTemplate = New PdfPageTemplate(page)
'Sets the PdfPageTemplate name
pageTemplate.Name = "pageTemplate"
'Sets the PdfPageTemplate is visible
pageTemplate.IsVisible = True
'Adds the page template
loadedDocument.PdfPageTemplates.Add(pageTemplate)
'Save the document
loadedDocument.Save("output.pdf")
'Close the document
loadedDocument.Close(True)
PortfolioInformation
Gets or set the portfolio information associated with this document
Declaration
public PdfPortfolioInformation PortfolioInformation { get; set; }
Property Value
Type |
---|
PdfPortfolioInformation |
Examples
//Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("input.pdf");
//Create a new portfolio
document.PortfolioInformation = new PdfPortfolioInformation();
//set the view mode of the portfolio
document.PortfolioInformation.ViewMode = PdfPortfolioViewMode.Tile;
//Create the attachment
PdfAttachment pdfFile = new PdfAttachment("CorporateBrochure.pdf");
pdfFile.FileName = "CorporateBrochure.pdf";
//Set the startup document to view
document.PortfolioInformation.StartupDocument = pdfFile;
//Add the attachment to the document
document.Attachments.Add(pdfFile);
//Save and close the PDF document.
document.Save("output.pdf");
document.Close(true);
'Load an existing document
Dim document As New PdfLoadedDocument("input.pdf")
'Create a new portfolio
document.PortfolioInformation = New PdfPortfolioInformation()
'set the view mode of the portfolio
document.PortfolioInformation.ViewMode = PdfPortfolioViewMode.Tile
'Create the attachment
Dim pdfFile As New PdfAttachment("CorporateBrochure.pdf")
pdfFile.FileName = "CorporateBrochure.pdf"
'Set the startup document to view
document.PortfolioInformation.StartupDocument = pdfFile
'Add the attachment to the document
document.Attachments.Add(pdfFile)
'Save and close the PDF document.
document.Save("output.pdf")
document.Close(True)
See Also
Revisions
Gets an array of PdfRevision objects representing the revisions of the loaded PDF document.
Declaration
public PdfRevision[] Revisions { get; }
Property Value
Type |
---|
PdfRevision[] |
Examples
//Loads an existing document
PdfLoadedDocument document = new PdfLoadedDocument(filename);
//Gets the revisions of the document
PdfRevision[] revisions = document.Revisions;
foreach(PdfRevision rev in revisions)
{
//Gets the revision start position
long startPosition = rev.StartPosition;
}
//Load the existing signature field
PdfLoadedSignatureField field = document.Form.Fields[0] as PdfLoadedSignatureField;
//Gets the revision index of the signature
int revisionIndex = field.Revision;
// Close the document
document.Close(true);
'Loads an existing document
Dim document As PdfLoadedDocument = New PdfLoadedDocument(filename)
'Gets the revisions of the document
Dim revisions() As PdfRevision = document.Revisions
For Each rev As PdfRevision In revisions
'Gets the revision start position
Dim startPosition As Long = rev.StartPosition
Next
'Load the existing signature field
Dim field As PdfLoadedSignatureField = CType(document.Form.Fields(0),PdfLoadedSignatureField)
'Gets the revision index of the signature
Dim revisionIndex As Integer = field.Revision
' Close the document
document.Close(true)
StructureElement
Gets the root structure element of the loaded PDF document. The structure element represents the top-level structure element in the document's logical structure hierarchy.
Declaration
public PdfStructureElement StructureElement { get; }
Property Value
Type |
---|
PdfStructureElement |
Remarks
The logical structure hierarchy is an optional feature of PDF documents that allows authors to tag content with structural information, making the document more accessible and easier to navigate for users with disabilities. The root structure element is the top-level element in this hierarchy, and all other structure elements are descendants of it.
Examples
FileStream fileStream = File.OpenRead("TaggedPDF.pdf");
//Load existing PDF document.
PdfLoadedDocument document = new PdfLoadedDocument(fileStream);
//Get the structure element root from document.
PdfStructureElement rootElement = document.StructureElement;
//Get the first page from the document.
PdfLoadedPage loadedPage = document.Pages[0] as PdfLoadedPage;
//Get the structure elements associated with the page.
PdfStructureElement[] pageElements = loadedPage.StrutureElements;
//Get the first element from the page.
PdfStructureElement element = pageElements[0];
//Get the element properties.
string abbrevation = element.Abbrevation;
string ActualText = element.ActualText;
string AlternateText = element.AlternateText;
string Language = element.Language;
int Order = element.Order;
PdfTagType TagType = element.TagType;
string Title = element.Title;
ScopeType scope = element.Scope;
//Gets the parent and child for first element.
PdfStructureElement parent = element.Parent;
//Gets the child elements for the element.
PdfStructureElement[] child = element.ChildElements;
//Gets the page bounds for the element.
RectangleF bounds = element.Bounds;
//Save the document.
MemoryStream stream = new MemoryStream();
document.Save(stream);
document.Close(true);
Dim fileStream As FileStream = File.OpenRead("TaggedPDF.pdf")
//Load existing PDF document.
Dim document As PdfLoadedDocument = New PdfLoadedDocument(fileStream)
//Get the structure element root from document.
Dim rootElement As PdfStructureElement = document.StructureElement
//Get the first page from the document.
Dim loadedPage As PdfLoadedPage = CType(document.Pages(0),PdfLoadedPage)
//Get the structure elements associated with the page.
Dim pageElements() As PdfStructureElement = loadedPage.StrutureElements
//Get the first element from the page.
Dim element As PdfStructureElement = pageElements(0)
//Get the element properties.
Dim abbrevation As String = element.Abbrevation
Dim ActualText As String = element.ActualText
Dim AlternateText As String = element.AlternateText
Dim Language As String = element.Language
Dim Order As Integer = element.Order
Dim TagType As PdfTagType = element.TagType
Dim Title As String = element.Title
Dim scope As ScopeType = element.Scope
//Gets the parent and child for first element.
Dim parent As PdfStructureElement = element.Parent
//Gets the child elements for the element.
Dim child() As PdfStructureElement = element.ChildElements
//Gets the page bounds for the element.
Dim bounds As RectangleF = element.Bounds
//Save the document.
Dim stream As MemoryStream = New MemoryStream
document.Save(stream)
document.Close(true)
UsedFonts
Gets the fonts which are available in the PDF document.
Declaration
public PdfUsedFont[] UsedFonts { get; }
Property Value
Type | Description |
---|---|
PdfUsedFont[] | Retruns the fonts which are used in the PDF document. |
Remarks
This method is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight
Examples
//Load the existing PDF document
PdfLoadedDocument ldoc = new PdfLoadedDocument("input.pdf");
//Get the use fonts
PdfUsedFont[] fonts = ldoc.UsedFonts;
List<string> usedFontNames = new List<string>();
//Get the used font Names
foreach(PdfUsedFont font in fonts)
usedFontNames.Add(font.Name);
//Close the document
ldoc.Close(true);
'Load the existing PDF document
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("input.pdf")
'Get the use fonts
Dim fonts() As PdfUsedFont = ldoc.UsedFonts
Dim usedFontNames As List(Of String) = New List(Of String)
'Get the used font Names
For Each font As PdfUsedFont In fonts
usedFontNames.Add(font.Name)
Next
'Close the document
ldoc.Close(True)
Methods
Clone()
Creates a shallow copy of the current document.
Declaration
public object Clone()
Returns
Type |
---|
System.Object |
Examples
//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceDoc.pdf");
// Clone the existing the document
PdfLoadedDocument doc1 = doc.Clone() as PdfLoadedDocument;
// Save the cloned document to a disk
doc1.Save("ClonedPDF.pdf");
doc1.Close(true);
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceDoc.pdf")
' Clone the existing the document
Dim doc1 As PdfLoadedDocument = TryCast(doc.Clone(), PdfLoadedDocument)
' Save the cloned document to a disk
doc1.Save("ClonedPDF.pdf")
doc1.Close(True)
Close(Boolean)
Releases all the resources allocated by this PDF document
Declaration
public override void Close(bool completely)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | completely | if set to |
Overrides
Examples
//Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("input.pdf");
MemoryStream stream = new MemoryStream();
//Save the document.
document.Save(stream);
//Close the document.
document.Close(true);
'Load an existing document
Dim document As New PdfLoadedDocument("input.pdf")
Dim stream As New MemoryStream()
'Save the document.
document.Save(stream)
'Close the document.
document.Close(True)
ConvertToPDFA(PdfConformanceLevel)
Convert the existing PDF document to PDF/A document.
Declaration
public void ConvertToPDFA(PdfConformanceLevel conformanceLevel)
Parameters
Type | Name | Description |
---|---|---|
PdfConformanceLevel | conformanceLevel |
Examples
//Load an existing PDF document
PdfLoadedDocument doc = new PdfLoadedDocument("Input.pdf");
//Sample level Font event handling
doc.SubstituteFont += LoadedDocument_SubstituteFont;
//Convert loaded document to PDF/A document
doc.ConvertToPDFA(PdfConformanceLevel.Pdf_A1B);
//Save the document
doc.Save("Output.pdf");
//Close the document
doc.Close(true);
'Load an existing PDF document
Dim doc As New PdfLoadedDocument("Input.pdf")
doc.SubstituteFont += LoadedDocument_SubstituteFont
'Convert loaded document to PDF/A document
doc.ConvertToPDFA(PdfConformanceLevel.Pdf_A1B)
'Save the document
doc.Save("Output.pdf")
'Close the document.
doc.Close(True)
CreateAttachment()
Creates a PDF attachments to the loaded document
Declaration
public PdfAttachmentCollection CreateAttachment()
Returns
Type | Description |
---|---|
PdfAttachmentCollection | The collection of attachments in the loaded document. |
Examples
//Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("input.pdf");
//Create attachment collection.
PdfAttachmentCollection collection = document.CreateAttachment();
PdfAttachment attachment = new PdfAttachment("Attachment1.pdf", File.ReadAllBytes("input.pdf"));
//Add the attachment to the attachment collection.
collection.Add(attachment);
//Save the document.
document.Save("output.pdf");
//Close the document.
document.Close(true);
'Load an existing document
Dim document As New PdfLoadedDocument("input.pdf")
'Create attachment collection.
Dim collection As PdfAttachmentCollection = document.CreateAttachment()
Dim attachment As New PdfAttachment("Attachment1.pdf", File.ReadAllBytes("input.pdf"))
'Add the attachment to the attachment collection.
collection.Add(attachment)
'Save the document.
document.Save("output.pdf")
'Close the document.
document.Close(True)
CreateBookmarkRoot()
Creates a bookmarks collection to the loaded document.
Declaration
public PdfBookmarkBase CreateBookmarkRoot()
Returns
Type | Description |
---|---|
PdfBookmarkBase | The collection of bookmarks in the loaded document. |
Examples
//Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("input.pdf");
//Create bookmark.
PdfBookmarkBase bookmark = document.CreateBookmarkRoot();
bookmark.Add("Page1");
//Save the document.
document.Save("output.pdf");
//Close the document.
document.Close(true);
'Load an existing document
Dim document As New PdfLoadedDocument("input.pdf")
'Create bookmark.
Dim bookmark As PdfBookmarkBase = document.CreateBookmarkRoot()
bookmark.Add("Page1")
'Save the document.
document.Save("output.pdf")
'Close the document.
document.Close(True)
CreateForm()
Creates a new form to the loaded document
Declaration
public void CreateForm()
Examples
//Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("input.pdf");
//Create form.
document.CreateForm();
//Create new text box field.
PdfTextBoxField field = new PdfTextBoxField(document.Pages[0], "textBox1");
field.Bounds = new RectangleF(0, 0, 100, 30);
field.Text = "Text Box";
//Add fields to form.
document.Form.Fields.Add(field);
//Save the document.
document.Save("output.pdf");
//Close the document.
document.Close(true);
'Load an existing document
Dim document As New PdfLoadedDocument("input.pdf")
'Create form.
document.CreateForm()
'Create new text box field.
Dim field As New PdfTextBoxField(document.Pages(0), "textBox1")
field.Bounds = New RectangleF(0, 0, 100, 30)
field.Text = "Text Box"
'Add fields to form.
document.Form.Fields.Add(field)
'Save the document.
document.Save("output.pdf")
'Close the document.
document.Close(True)
Dispose()
Release all the resource used by the document instance
Declaration
public void Dispose()
Examples
//Load an existing document
PdfLoadedDocument doc = new PdfLoadedDocument("SourceDoc.pdf");
//Creates a new page and adds it as the last page of the document
PdfPageBase page = doc.Pages.Add();
//Create Pdf graphics for the page
PdfGraphics g = page.Graphics;
//Create a solid brush
PdfBrush brush = new PdfSolidBrush(Color.Black);
float fontSize = 8f;
//Set the font
PdfFont font = new PdfStandardFont(PdfFontFamily.TimesRoman, fontSize);
//Draw the text
g.DrawString("HelloWorld", font, brush, new RectangleF(47.835f, 236.835f, 564.165f, 553.937f));
doc.Save("Dispose.pdf");
// Dispose the object
doc.Dispose();
'Load an existing document
Dim doc As PdfLoadedDocument = New PdfLoadedDocument("SourceDoc.pdf")
'Create a page
Dim page As PdfPageBase = doc.Pages.Add()
'Create Pdf graphics for the page
Dim g As PdfGraphics = page.Graphics
'Create a solid brush
Dim brush As PdfBrush = New PdfSolidBrush(Color.Black)
Dim fontSize As Single = 8f
'Set the font
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.TimesRoman, fontSize)
'Draw the text
g.DrawString("HelloWorld", font, brush, New RectangleF(47.835f, 236.835f, 564.165f, 553.937f))
doc.Save("Dispose.pdf")
' Dispose the object
doc.Dispose()
EmbedFonts()
Embed all the non-embedded fonts to the PDF document.
Declaration
public void EmbedFonts()
Remarks
It will use a default font like Microsoft San Serif, if the required font is not available on the system.
Examples
//Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("input.pdf");
if (!loadedDocument.IsAllFontsEmbedded)
{
loadedDocument.EmbedFont();
}
//Save the document.
document.Save("output.pdf");
//Close the document.
document.Close(true);
'Load an existing document
Dim document As New PdfLoadedDocument("input.pdf")
If Not loadedDocument.IsAllFontsEmbedded Then
loadedDocument.EmbedFont()
End If
'Save the document.
document.Save("output.pdf")
'Close the document.
document.Close(True)
ExportAnnotations(Stream, AnnotationDataFormat)
Exports the annotation data.
Declaration
public bool ExportAnnotations(Stream stream, AnnotationDataFormat format)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | Output file stream. |
AnnotationDataFormat | format | Exporting data format. |
Returns
Type | Description |
---|---|
System.Boolean | Returns whether the annotation data is exported or not |
Examples
//Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf");
//Initialize an instance of MemoryStream
MemoryStream stream = new MemoryStream();
//Export annotation data into the memory stream
document.ExportAnnotations(stream, AnnotationDataFormat.Fdf);
//Close and dispose the document
document.Close(true);
document.Dispose();
'Load an existing document
Dim document As New PdfLoadedDocument("Input.pdf")
'Initialize an instance of MemoryStream
Dim stream As New MemoryStream()
'Export annotation data into the memory stream
document.ExportAnnotations(stream, AnnotationDataFormat.Fdf)
'Close and dispose the document
document.Close(true)
document.Dispose()
ExportAnnotations(Stream, AnnotationDataFormat, PdfExportAnnotationCollection)
Exports the annotation data.
Declaration
public bool ExportAnnotations(Stream stream, AnnotationDataFormat format, PdfExportAnnotationCollection collection)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | Output file stream. |
AnnotationDataFormat | format | Exporting data format. |
PdfExportAnnotationCollection | collection | Annotation collection to export. |
Returns
Type | Description |
---|---|
System.Boolean | Returns whether the annotation data is exported or not |
Examples
//Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf");
//Initialize an object for export annotation collection
PdfExportAnnotationCollection collection = new PdfExportAnnotationCollection();
//Get the first page from the document
PdfLoadedPage page = document.Pages[0] as PdfLoadedPage;
//Add loaded annotations into the export annotation collection
collection.Add(page.Annotations[0] as PdfLoadedAnnotation);
collection.Add(page.Annotations[1] as PdfLoadedAnnotation);
//Initialize an instance of MemoryStream
MemoryStream stream = new MemoryStream();
//Export selected annotation's data into FDF/XFDF format
document.ExportAnnotations(stream, AnnotationDataFormat.Fdf, collection);
//Close and dispose the document
document.Close(true);
document.Dispose();
'Load an existing document
Dim document As New PdfLoadedDocument("Input.pdf")
'Initialize an object for export annotation collection
Dim collection As New PdfExportAnnotationCollection()
'Get the first page from the document
Dim page As PdfLoadedPage = TryCast(document.Pages(0), PdfLoadedPage)
'Add loaded annotations into the export annotation collection
collection.Add(TryCast(page.Annotations[0], PdfLoadedAnnotation))
collection.Add(TryCast(page.Annotations[1], PdfLoadedAnnotation))
'Initialize an instance of MemoryStream
Dim stream As New MemoryStream()
'Export selected annotation's data into FDF/XFDF format
document.ExportAnnotations(stream, AnnotationDataFormat.Fdf, collection)
'Close and dispose the document
document.Close(true)
document.Dispose()
ExportAnnotations(Stream, AnnotationDataFormat, String)
Exports the annotation data.
Declaration
public bool ExportAnnotations(Stream stream, AnnotationDataFormat format, string targetFilePath)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | Output file stream. |
AnnotationDataFormat | format | Exporting data format. |
System.String | targetFilePath | Target file name or path. |
Returns
Type | Description |
---|---|
System.Boolean | Returns whether the annotation data is exported or not |
Examples
//Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf");
//Initialize an instance of MemoryStream
MemoryStream stream = new MemoryStream();
//Export annotation data into the memory stream
document.ExportAnnotations(stream, AnnotationDataFormat.Fdf, "Annotation.pdf");
//Close and dispose the document
document.Close(true);
document.Dispose();
'Load an existing document
Dim document As New PdfLoadedDocument("Input.pdf")
'Initialize an instance of MemoryStream
Dim stream As New MemoryStream()
'Export annotation data into the memory stream
document.ExportAnnotations(stream, AnnotationDataFormat.Fdf, "Annotation.pdf")
'Close and dispose the document
document.Close(true)
document.Dispose()
ExportAnnotations(Stream, AnnotationDataFormat, String, PdfExportAnnotationCollection)
Exports the annotation data.
Declaration
public bool ExportAnnotations(Stream stream, AnnotationDataFormat format, string targetFilePath, PdfExportAnnotationCollection collection)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | Output file stream. |
AnnotationDataFormat | format | Exporting data format. |
System.String | targetFilePath | Target file name or path. |
PdfExportAnnotationCollection | collection | Annotation collection to export. |
Returns
Type | Description |
---|---|
System.Boolean | Returns whether the annotation data is exported or not |
Examples
//Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf");
//Initialize an object for export annotation collection
PdfExportAnnotationCollection collection = new PdfExportAnnotationCollection();
//Get the first page from the document
PdfLoadedPage page = document.Pages[0] as PdfLoadedPage;
//Add loaded annotations into the export annotation collection
collection.Add(page.Annotations[0] as PdfLoadedAnnotation);
collection.Add(page.Annotations[1] as PdfLoadedAnnotation);
//Initialize an instance of MemoryStream
MemoryStream stream = new MemoryStream();
//Export selected annotation's data into FDF/XFDF/Json format
document.ExportAnnotations(stream, AnnotationDataFormat.Fdf, "Annotation.pdf", collection);
//Close and dispose the document
document.Close(true);
document.Dispose();
'Load an existing document
Dim document As New PdfLoadedDocument("Input.pdf")
'Initialize an object for export annotation collection
Dim collection As New PdfExportAnnotationCollection()
'Get the first page from the document
Dim page As PdfLoadedPage = TryCast(document.Pages(0), PdfLoadedPage)
'Add loaded annotations into the export annotation collection
collection.Add(TryCast(page.Annotations[0], PdfLoadedAnnotation))
collection.Add(TryCast(page.Annotations[1], PdfLoadedAnnotation))
'Initialize an instance of MemoryStream
Dim stream As New MemoryStream()
'Export selected annotation's data into FDF/XFDF format
document.ExportAnnotations(stream, AnnotationDataFormat.Fdf, "Annotation.pdf", collection)
'Close and dispose the document
document.Close(true)
document.Dispose()
ExportAnnotations(Stream, PdfAnnotationExportSettings)
Export the annotations to a stream with the specified AnnotationExportSettings.
Declaration
public bool ExportAnnotations(Stream stream, PdfAnnotationExportSettings settings)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | |
PdfAnnotationExportSettings | settings |
Returns
Type |
---|
System.Boolean |
Examples
//Loads an existing PDF Document
PdfLoadedDocument lDoc = new PdfLoadedDocument(@"...\...\Input.pdf");
//Class that represents the annotation export settings.
PdfAnnotationExportSettings settings = new PdfAnnotationExportSettings();
PdfLoadedAnnotationType[] annotType = { PdfLoadedAnnotationType.RectangleAnnotation, PdfLoadedAnnotationType.RubberStampAnnotation,PdfLoadedAnnotationType.FreeTextAnnotation };
//It Specifies the format to export annotation data.
settings.DataFormat = AnnotationDataFormat.Fdf
//Set the array of annotation types that needs to be exported.
settings.AnnotationTypes = annotType;
//Gets or sets the flag to export the annotations with appearance.
settings.ExportAppearance = true;
//Creating the stream object
MemoryStream memstream = new MemoryStream();
//Export the annotations to a stream with the specified AnnotationExportSettings.
lDoc.ExportAnnotations(memstream, settings);
//Close the document
lDoc.Close(true);
'Loads an existing PDF Document
Dim lDoc As PdfLoadedDocument = New PdfLoadedDocument("...\...\Input.pdf")
'Class that represents the annotation export settings.
Dim settings As PdfAnnotationExportSettings = New PdfAnnotationExportSettings()
'It Specifies the format to export annotation data.
settings.DataFormat = AnnotationDataFormat.Fdf
'Export annotations to a file with specified PdfAnnotationExportSettings.
Dim annotType As PdfLoadedAnnotationType() = {PdfLoadedAnnotationType.FreeTextAnnotation, PdfLoadedAnnotationType.CircleAnnotation}
'Set the array of annotation types that needs to be exported.
settings.AnnotationTypes = annotType;
'Gets or sets the flag to export the annotations with appearance.
settings.ExportAppearance = true;
'Creating the stream object
MemoryStream memstream = new MemoryStream();
'Export the annotations to a stream with the specified AnnotationExportSettings.
lDoc.ExportAnnotations(memstream, settings)
'Close the document
lDoc.Close(True)
ExportAnnotations(String, AnnotationDataFormat)
Exports the annotation data.
Declaration
public bool ExportAnnotations(string fileName, AnnotationDataFormat format)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | Output file name. |
AnnotationDataFormat | format | Exporting data format. |
Returns
Type | Description |
---|---|
System.Boolean | Returns whether the annotation data is exported or not |
Examples
//Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf");
//Export annotation data into FDF/XFDF format
document.ExportAnnotations("Annotations.fdf", AnnotationDataFormat.Fdf);
//Close and dispose the document
document.Close(true);
document.Dispose();
'Load an existing document
Dim document As New PdfLoadedDocument("Input.pdf")
'Export annotation data into FDF/XFDF format
document.ExportAnnotations("Annotations.fdf", AnnotationDataFormat.Fdf)
'Close and dispose the document
document.Close(true)
document.Dispose()
ExportAnnotations(String, AnnotationDataFormat, PdfExportAnnotationCollection)
Exports the annotation data.
Declaration
public bool ExportAnnotations(string fileName, AnnotationDataFormat format, PdfExportAnnotationCollection collection)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | Output file name. |
AnnotationDataFormat | format | Exporting data format. |
PdfExportAnnotationCollection | collection | Annotation collection to export. |
Returns
Type | Description |
---|---|
System.Boolean | Returns whether the annotation data is exported or not |
Examples
//Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf");
//Initialize an object for export annotation collection
PdfExportAnnotationCollection collection = new PdfExportAnnotationCollection();
//Get the first page from the document
PdfLoadedPage page = document.Pages[0] as PdfLoadedPage;
//Add loaded annotations into the export annotation collection
collection.Add(page.Annotations[0] as PdfLoadedAnnotation);
collection.Add(page.Annotations[1] as PdfLoadedAnnotation);
//Export selected annotation's data into FDF/XFDF format
document.ExportAnnotations("Annotations.fdf", AnnotationDataFormat.Fdf, collection);
//Close and dispose the document
document.Close(true);
document.Dispose();
'Load an existing document
Dim document As New PdfLoadedDocument("Input.pdf")
'Initialize an object for export annotation collection
Dim collection As New PdfExportAnnotationCollection()
'Get the first page from the document
Dim page As PdfLoadedPage = TryCast(document.Pages(0), PdfLoadedPage)
'Add loaded annotations into the export annotation collection
collection.Add(TryCast(page.Annotations[0], PdfLoadedAnnotation))
collection.Add(TryCast(page.Annotations[1], PdfLoadedAnnotation))
'Export selected annotation's data into FDF/XFDF format
document.ExportAnnotations("Annotations.fdf", AnnotationDataFormat.Fdf, collection)
'Close and dispose the document
document.Close(true)
document.Dispose()
ExportAnnotations(String, AnnotationDataFormat, String)
Exports the annotation data.
Declaration
public bool ExportAnnotations(string fileName, AnnotationDataFormat format, string targetFilePath)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | Output file name. |
AnnotationDataFormat | format | Exporting data format. |
System.String | targetFilePath | Target file name or path. |
Returns
Type | Description |
---|---|
System.Boolean | Returns whether the annotation data is exported or not |
Examples
//Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf");
//Export annotation data into FDF/XFDF format
document.ExportAnnotations("Annotations.fdf", AnnotationDataFormat.Fdf, "Annotation.Pdf");
//Close and dispose the document
document.Close(true);
document.Dispose();
'Load an existing document
Dim document As New PdfLoadedDocument("Input.pdf")
'Export annotation data into FDF/XFDF format
document.ExportAnnotations("Annotations.fdf", AnnotationDataFormat.Fdf, "Annotation.Pdf")
'Close and dispose the document
document.Close(true)
document.Dispose()
ExportAnnotations(String, AnnotationDataFormat, String, PdfExportAnnotationCollection)
Exports the annotation data.
Declaration
public bool ExportAnnotations(string fileName, AnnotationDataFormat format, string targetFilePath, PdfExportAnnotationCollection collection)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | Output file name. |
AnnotationDataFormat | format | Exporting data format. |
System.String | targetFilePath | Target file name or path. |
PdfExportAnnotationCollection | collection | Annotation collection to export. |
Returns
Type | Description |
---|---|
System.Boolean | Returns whether the annotation data is exported or not |
Examples
//Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf");
//Initialize an object for export annotation collection
PdfExportAnnotationCollection collection = new PdfExportAnnotationCollection();
//Get the first page from the document
PdfLoadedPage page = document.Pages[0] as PdfLoadedPage;
//Add loaded annotations into the export annotation collection
collection.Add(page.Annotations[0] as PdfLoadedAnnotation);
collection.Add(page.Annotations[1] as PdfLoadedAnnotation);
//Export selected annotation's data into FDF/XFDF format
document.ExportAnnotations("Annotations.fdf", AnnotationDataFormat.Fdf, "Annotation.pdf", collection);
//Close and dispose the document
document.Close(true);
document.Dispose();
'Load an existing document
Dim document As New PdfLoadedDocument("Input.pdf")
'Initialize an object for export annotation collection
Dim collection As New PdfExportAnnotationCollection()
'Get the first page from the document
Dim page As PdfLoadedPage = TryCast(document.Pages(0), PdfLoadedPage)
'Add loaded annotations into the export annotation collection
collection.Add(TryCast(page.Annotations[0], PdfLoadedAnnotation))
collection.Add(TryCast(page.Annotations[1], PdfLoadedAnnotation))
'Export selected annotation's data into FDF/XFDF format
document.ExportAnnotations("Annotations.fdf", AnnotationDataFormat.Fdf, "Annotation.pdf", collection)
'Close and dispose the document
document.Close(true)
document.Dispose()
ExportAnnotations(String, PdfAnnotationExportSettings)
Export the annotations to a file with the specified PdfAnnotationExportSettings.
Declaration
public bool ExportAnnotations(string fileName, PdfAnnotationExportSettings settings)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | |
PdfAnnotationExportSettings | settings |
Returns
Type |
---|
System.Boolean |
Examples
//Loads an existing PDF Document
PdfLoadedDocument lDoc = new PdfLoadedDocument(@"...\...\Input.pdf");
//Class that represents the annotation export settings.
PdfAnnotationExportSettings settings = new PdfAnnotationExportSettings();
PdfLoadedAnnotationType[] annotType = { PdfLoadedAnnotationType.RectangleAnnotation, PdfLoadedAnnotationType.RubberStampAnnotation,PdfLoadedAnnotationType.FreeTextAnnotation };
//It Specifies the format to export annotation data.
settings.DataFormat = AnnotationDataFormat.Fdf
//Set the array of annotation types that needs to be exported.
settings.AnnotationTypes = annotType;
//Gets or sets the flag to export the annotations with appearance.
settings.ExportAppearance = true;
//Export the annotations to a file with the specified PdfAnnotationExportSettings.
lDoc.ExportAnnotations("Annotation.FDF", settings);
//Close the document
lDoc.Close(true);
'Loads an existing PDF Document
Dim lDoc As PdfLoadedDocument = New PdfLoadedDocument("...\...\Input.pdf")
'Class that represents the annotation export settings.
Dim settings As PdfAnnotationExportSettings = New PdfAnnotationExportSettings()
'It Specifies the format to export annotation data.
settings.DataFormat = AnnotationDataFormat.Fdf
Dim annotType As PdfLoadedAnnotationType() = {PdfLoadedAnnotationType.FreeTextAnnotation, PdfLoadedAnnotationType.CircleAnnotation}
'Set the array of annotation types that needs to be exported.
settings.AnnotationTypes = annotType;
'Export annotations to a file with specified PdfAnnotationExportSettings.
'Gets or sets the flag to export the annotations with appearance.
settings.ExportAppearance = true;
'Export the annotations to a file with the specified PdfAnnotationExportSettings.
lDoc.ExportAnnotations(Annotation.FDF, settings)
'Close the document
lDoc.Close(True)
ExportAsImage(Int32)
Exports the specified page as Image
Declaration
public Bitmap ExportAsImage(int pageIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pageIndex | The page index to be converted into image |
Returns
Type | Description |
---|---|
System.Drawing.Bitmap | Returns the specified page as Image |
ExportAsImage(Int32, ImageExportSettings)
Exports the specified page as Image
Declaration
public Bitmap ExportAsImage(int pageIndex, ImageExportSettings exportSettings)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pageIndex | The page index to be converted into image |
ImageExportSettings | exportSettings |
Returns
Type | Description |
---|---|
System.Drawing.Bitmap | Returns the specified page as Image |
ExportAsImage(Int32, SizeF, Boolean)
Exports the specified page as Image
Declaration
public Bitmap ExportAsImage(int pageIndex, SizeF customSize, bool keepAspectRatio)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pageIndex | The page index to be converted into image |
System.Drawing.SizeF | customSize | The custom size of the converted image |
System.Boolean | keepAspectRatio | Whether need to maintain the pdf page size |
Returns
Type |
---|
System.Drawing.Bitmap |
ExportAsImage(Int32, SizeF, Single, Single, Boolean)
Exports the specified page as Image
Declaration
public Bitmap ExportAsImage(int pageIndex, SizeF customSize, float dpiX, float dpiY, bool keepAspectRatio)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pageIndex | The page index to be converted into image |
System.Drawing.SizeF | customSize | The custom size of the converted image |
System.Single | dpiX | The horizontal DPI of the resultant image. |
System.Single | dpiY | The vertical DPI of the resultant image. |
System.Boolean | keepAspectRatio | Whether need to maintain the pdf page size |
Returns
Type |
---|
System.Drawing.Bitmap |
ExportAsImage(Int32, Int32)
Exports the specified pages as Images
Declaration
public Bitmap[] ExportAsImage(int startIndex, int endIndex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | startIndex | The starting page index |
System.Int32 | endIndex | The ending page index |
Returns
Type | Description |
---|---|
System.Drawing.Bitmap[] | Returns the specified pages as Images |
ExportAsImage(Int32, Int32, ImageExportSettings)
Exports the specified pages as Images
Declaration
public Bitmap[] ExportAsImage(int startIndex, int endIndex, ImageExportSettings exportSettings)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | startIndex | The starting page index |
System.Int32 | endIndex | The ending page index |
ImageExportSettings | exportSettings | exportSettings used to set image export properties |
Returns
Type |
---|
System.Drawing.Bitmap[] |
ExportAsImage(Int32, Int32, SizeF, Boolean)
Exports the specified pages as Images
Declaration
public Bitmap[] ExportAsImage(int startIndex, int endIndex, SizeF customSize, bool keepAspectRatio)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | startIndex | The starting page index |
System.Int32 | endIndex | The ending page index |
System.Drawing.SizeF | customSize | The custom size of the converted image |
System.Boolean | keepAspectRatio | Whether need to maintain the pdf page size |
Returns
Type | Description |
---|---|
System.Drawing.Bitmap[] | Returns the specified pages as images with custom size |
ExportAsImage(Int32, Int32, SizeF, Single, Single, Boolean)
Exports the specified pages as Images
Declaration
public Bitmap[] ExportAsImage(int startIndex, int endIndex, SizeF customSize, float dpiX, float dpiY, bool keepAspectRatio)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | startIndex | The starting page index |
System.Int32 | endIndex | The ending page index |
System.Drawing.SizeF | customSize | The custom size of the converted image |
System.Single | dpiX | The horizontal DPI of the resultant image. |
System.Single | dpiY | The vertical DPI of the resultant image. |
System.Boolean | keepAspectRatio | Whether need to maintain the pdf page size |
Returns
Type | Description |
---|---|
System.Drawing.Bitmap[] | Returns the specified pages as images with custom size and resolution |
ExportAsImage(Int32, Int32, Single, Single)
Exports the specified pages as Images with respect to dpi specified.
Declaration
public Bitmap[] ExportAsImage(int startIndex, int endIndex, float dpiX, float dpiY)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | startIndex | The starting page index |
System.Int32 | endIndex | |
System.Single | dpiX | The horizontal DPI of the resultant image. |
System.Single | dpiY | The vertical DPI of the resultant image. |
Returns
Type | Description |
---|---|
System.Drawing.Bitmap[] | Returns the specified pages as Images with custom resolution |
ExportAsImage(Int32, Single, Single)
Exports the specified page as Image with respect to dpi specified.
Declaration
public Bitmap ExportAsImage(int pageIndex, float dpiX, float dpiY)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | pageIndex | The page index to be converted into image |
System.Single | dpiX | The horizontal DPI of the resultant image. |
System.Single | dpiY | The vertical DPI of the resultant image. |
Returns
Type | Description |
---|---|
System.Drawing.Bitmap | Returns the specified page as Image with custom resolution |
Finalize()
Releases unmanaged resources and performs other cleanup operations before the PdfLoadedDocument is reclaimed by garbage collection.
Declaration
protected void Finalize()
FindText(List<String>, out TextSearchResultCollection)
Returns the TextSearchResultCollection instance which contains collection of MatchedItemCollection
Declaration
public bool FindText(List<string> searchItems, out TextSearchResultCollection searchResult)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<System.String> | searchItems | List of items to be searched. |
TextSearchResultCollection | searchResult | Instance of TextSearchResultCollection |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if found any match |
FindText(List<String>, out TextSearchResultCollection, Boolean)
Returns the TextSearchResultCollection instance which contains collection of MatchedItemCollection
Declaration
public bool FindText(List<string> searchItems, out TextSearchResultCollection searchResult, bool enableMultiThreading)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<System.String> | searchItems | List of items to be searched. |
TextSearchResultCollection | searchResult | Instance of TextSearchResultCollection |
System.Boolean | enableMultiThreading | If true,then the text search will be performed asynchronously |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if found any match |
FindText(List<String>, Int32, out List<MatchedItem>)
Returns the information of the matched texts in a specific page
Declaration
public bool FindText(List<string> searchItems, int pageIndex, out List<MatchedItem> searchResults)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<System.String> | searchItems | The List of items to be searched. |
System.Int32 | pageIndex | The specified page index |
System.Collections.Generic.List<MatchedItem> | searchResults | Holds the information of the matched texts |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if found any match |
FindText(List<String>, Int32, TextSearchOptions, out List<MatchedItem>)
Returns the information of the matched texts in a specific page.
Declaration
public bool FindText(List<string> searchItems, int pageIndex, TextSearchOptions textSearchOption, out List<MatchedItem> searchResults)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<System.String> | searchItems | List of items to be searched. |
System.Int32 | pageIndex | The specified page index |
TextSearchOptions | textSearchOption | Search option to find the texts |
System.Collections.Generic.List<MatchedItem> | searchResults | Holds the information of the matched texts. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if found any match |
FindText(List<String>, TextSearchOptions, out TextSearchResultCollection)
Returns the dictionary of page number and list of captured terms in the PDF document.
Declaration
public bool FindText(List<string> searchItems, TextSearchOptions textSearchOption, out TextSearchResultCollection searchResult)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<System.String> | searchItems | List of items to be searched. |
TextSearchOptions | textSearchOption | Search option to find the texts |
TextSearchResultCollection | searchResult |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if found any match |
FindText(List<String>, TextSearchOptions, out TextSearchResultCollection, Boolean)
Returns the dictionary of page number and list of captured terms in the PDF document.
Declaration
public bool FindText(List<string> searchItems, TextSearchOptions textSearchOption, out TextSearchResultCollection searchResult, bool enableMultiThreading)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<System.String> | searchItems | List of items to be searched. |
TextSearchOptions | textSearchOption | Search option to find the texts |
TextSearchResultCollection | searchResult | |
System.Boolean | enableMultiThreading | If true,then the text search will be performed asynchronously |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if found any match |
FindText(List<TextSearchItem>, out TextSearchResultCollection)
Returns the dictionary of page number and list of text search items in the PDF document.
Declaration
public bool FindText(List<TextSearchItem> searchItems, out TextSearchResultCollection searchResult)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<TextSearchItem> | searchItems | List of items to be searched. |
TextSearchResultCollection | searchResult |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if found any match |
FindText(List<TextSearchItem>, out TextSearchResultCollection, Boolean)
Returns the dictionary of page number and list of text search items in the PDF document.
Declaration
public bool FindText(List<TextSearchItem> searchItems, out TextSearchResultCollection searchResult, bool enableMultiThreading)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<TextSearchItem> | searchItems | List of items to be searched. |
TextSearchResultCollection | searchResult | |
System.Boolean | enableMultiThreading | If true,then the text search will be performed asynchronously |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if found any match |
FindText(List<TextSearchItem>, Int32, out List<MatchedItem>)
Returns the information of the matched texts in a specific page
Declaration
public bool FindText(List<TextSearchItem> searchItems, int pageIndex, out List<MatchedItem> searchResults)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.List<TextSearchItem> | searchItems | The List of items to be searched. |
System.Int32 | pageIndex | The specified page index |
System.Collections.Generic.List<MatchedItem> | searchResults | Holds the information of the matched texts |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if found any match |
FindText(String, out Dictionary<Int32, List<RectangleF>>)
Returns the page number and rectangle positions of the text matches
Declaration
public bool FindText(string text, out Dictionary<int, List<RectangleF>> matchRect)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to be searched |
System.Collections.Generic.Dictionary<System.Int32, System.Collections.Generic.List<System.Drawing.RectangleF>> | matchRect | Holds the page number and rectangle positions of the text matches |
Returns
Type |
---|
System.Boolean |
FindText(String, Int32, out List<RectangleF>)
Returns rectangle positions of the text matches for specific page
Declaration
public bool FindText(string text, int index, out List<RectangleF> matchRect)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text to be searched |
System.Int32 | index | The specified page index |
System.Collections.Generic.List<System.Drawing.RectangleF> | matchRect | Holds the rectangle positions of the text matches |
Returns
Type |
---|
System.Boolean |
FlattenAnnotations()
Flatten all annotations in the PDF document
Declaration
public void FlattenAnnotations()
FlattenAnnotations(Boolean)
Flatten all annotations in the PDF document with popups.
Declaration
public void FlattenAnnotations(bool flattenPopups)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | flattenPopups |
ImportAnnotations(Stream, AnnotationDataFormat)
Imports the annotation data from FDF/XFDF/Json stream.
Declaration
public void ImportAnnotations(Stream stream, AnnotationDataFormat format)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | FDF/XFDF stream. |
AnnotationDataFormat | format | Importing data format. |
Examples
//Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf");
//Import annotation data from FDF stream
Stream stream = new FileStream("Annotations.fdf", FileMode.Open, FileAccess.Read, FileShare.Read);
document.ImportAnnotations(stream, AnnotationDataFormat.Fdf);
//Save and close the document
document.Save("Output.pdf");
document.Close(true);
//dispose the document
document.Dispose();
'Load an existing document
Dim document As New PdfLoadedDocument("Input.pdf")
'Import annotation data from FDF stream
Dim stream As Stream = New FileStream("Annotations.fdf", FileMode.Open, FileAccess.Read, FileShare.Read)
document.ImportAnnotations(stream, AnnotationDataFormat.Fdf)
Save and close the document
'Close and dispose the document
document.Save("Output.pdf")
document.Close(true)
//dispose the document
document.Dispose()
ImportAnnotations(String, AnnotationDataFormat)
Imports the annotation data from FDF/XFDF/Json file.
Declaration
public void ImportAnnotations(string fileName, AnnotationDataFormat format)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | FDF/XFDF file name. |
AnnotationDataFormat | format | Importing data format. |
Examples
//Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf");
//Import annotation data from FDF file
document.ImportAnnotations("Annotations.fdf", AnnotationDataFormat.Fdf);
//Save and close the document
document.Save("Output.pdf");
document.Close(true);
//dispose the document
document.Dispose();
'Load an existing document
Dim document As New PdfLoadedDocument("Input.pdf")
'Import annotation data from FDF file
document.ImportAnnotations("Annotations.fdf", AnnotationDataFormat.Fdf)
Save and close the document
'Close and dispose the document
document.Save("Output.pdf")
document.Close(true)
//dispose the document
document.Dispose()
Redact()
Redact the contents from PDF document.
Declaration
public List<PdfRedactionResult> Redact()
Returns
Type | Description |
---|---|
System.Collections.Generic.List<PdfRedactionResult> | This method returns a list of redaction results. |
Examples
// Load the existing PDF document
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream);
// Create a redaction object
PdfRedaction redaction = new PdfRedaction(new RectangleF(343, 167, 100, 25), Color.Black);
// Add redaction object into redaction collection of loaded page
page.AddRedaction(redaction);
List<PdfRedactionResult> signatureValidationErrors = loadedDocument.Redact();
//Creating the stream object
MemoryStream stream = new MemoryStream();
// Save the document into stream.
loadedDocument.Save(stream);
// Close the documents.
loadedDocument.Close(true);
' Load the existing PDF document
Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument(docStream)
' Create a redaction object
Dim redaction As PdfRedaction = New PdfRedaction(New RectangleF(343, 167, 100, 25), Color.Black)
' Add redaction object into redaction collection of loaded page
page.AddRedaction(redaction)
Dim redactionResult As List(Of PdfRedactionResult) = loadedDocument.Redact()
'Creating the stream object
Dim stream As MemoryStream = New MemoryStream()
' Save the document into stream.
loadedDocument.Save(stream)
' Close the document.
loadedDocument.Close(True)
RemoveConformance()
Remove all the conformance from the PDF document.
Declaration
public void RemoveConformance()
Examples
//Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("input.pdf");
// Remove PDF/A information.
document.RemoveConformance();
//Save a document
document.Save("output.pdf");
//Close the document.
document.Close(true);
'Load an existing document
Dim document As New PdfLoadedDocument("input.pdf")
'Remove PDF/A information.
document.RemoveConformance()
'Save a document
document.Save("output.pdf")
'Close the document.
document.Close(True)
Save()
Saves the document into the same stream or file.
Declaration
public void Save()
Examples
// Loads an existing document
PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf");
ldoc.FileStructure.Version = PdfVersion.Version1_6;
// Save the changes in the same document.
ldoc.Save();
ldoc.Close(true);
' Loads an existing document
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
ldoc.FileStructure.Version = PdfVersion.Version1_6
' Save the changes in the same document.
ldoc.Save()
ldoc.Close(True)
See Also
Save(Stream)
Saves the PDF document to the specified stream.
Declaration
public override void Save(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream where to save the PDF document. |
Overrides
Examples
//Load an existing document
PdfLoadedDocument document = new PdfLoadedDocument("input.pdf");
MemoryStream stream = new MemoryStream();
//Save the document.
document.Save(stream);
//Close the document.
document.Close(true);
'Load an existing document
Dim document As New PdfLoadedDocument("input.pdf")
Dim stream As New MemoryStream()
'Save the document.
document.Save(stream)
'Close the document.
document.Close(True)
Split(String)
Splits a PDF document into individual pages.
Declaration
public void Split(string destFilePattern)
Parameters
Type | Name | Description |
---|---|---|
System.String | destFilePattern | The name of the individual destination pages. |
Remarks
This method splits a PDF document to individual pages. Each page is named using destFilePattern parameter after which a numeric index is appended. This method is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
// Loads an existing document
PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf");
// Splits the source document
ldoc.Split("Output.pdf");
ldoc.Close(true);
' Loads an existing document
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
' Splits the source document
ldoc.Split("Output.pdf")
ldoc.Close(True)
See Also
Split(String, PdfSplitOptions)
Splits a PDF document into individual pages with PdfSplitOptions.
Declaration
public void Split(string destFilePattern, PdfSplitOptions splitOptions)
Parameters
Type | Name | Description |
---|---|---|
System.String | destFilePattern | The name of the individual destination pages. |
PdfSplitOptions | splitOptions | Customize the split PDF |
Remarks
This method splits a PDF document to individual pages. Each page is named using destFilePattern parameter after which a numeric index is appended. This method is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
// Loads an existing document
PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf");
PdfSplitOptions splitOptions = new PdfSplitOptions();
splitOptions.SplitTags = true;
// Splits the source document
ldoc.Split("Output.pdf", splitOptions);
ldoc.Close(true);
' Loads an existing document
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
Dim splitOptions As PdfSplitOptions = New PdfSplitOptions
splitOptions.SplitTags = true
' Splits the source document
ldoc.Split("Output.pdf", splitOptions)
ldoc.Close(true)
See Also
Split(String, Int32)
Splits a PDF document into individual pages
Declaration
public void Split(string destFilePattern, int startNumber)
Parameters
Type | Name | Description |
---|---|---|
System.String | destFilePattern | The name of the individual destination pages |
System.Int32 | startNumber | The number that is use as a start point for the page numbering. |
Remarks
This method splits a PDF document to individual pages. Each page is named using destFilePattern parameter after which a numeric index is appended.
Examples
// Loads an existing document
PdfLoadedDocument ldoc = new PdfLoadedDocument("Form.pdf");
// Splits the source document
ldoc.Split("pdfDoc.pdf", 1);
ldoc.Close(true);
' Loads an existing document
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("Form.pdf")
' Splits the source document
ldoc.Split("pdfDoc.pdf", 1)
ldoc.Close(True)
Split(String, Int32, PdfSplitOptions)
Splits a PDF document into individual pages with PdfSplitOptions.
Declaration
public void Split(string destFilePattern, int startNumber, PdfSplitOptions splitOptions)
Parameters
Type | Name | Description |
---|---|---|
System.String | destFilePattern | The name of the individual destination pages |
System.Int32 | startNumber | The number that is use as a start Customize the split PDF point for the page numbering. |
PdfSplitOptions | splitOptions |
Remarks
This method splits a PDF document to individual pages. Each page is named using destFilePattern parameter after which a numeric index is appended.
Examples
// Loads an existing document
PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf");
PdfSplitOptions splitOptions = new PdfSplitOptions();
splitOptions.SplitTags = true;
// Splits the source document
ldoc.Split("Output.pdf",1, splitOptions);
ldoc.Close(true);
' Loads an existing document
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
Dim splitOptions As PdfSplitOptions = New PdfSplitOptions
splitOptions.SplitTags = true
' Splits the source document
ldoc.Split("Output.pdf",1, splitOptions)
ldoc.Close(true)
See Also
SplitByFixedNumber(String, Int32)
Declaration
public void SplitByFixedNumber(string destFilePattern, int numberToSplit)
Parameters
Type | Name | Description |
---|---|---|
System.String | destFilePattern | |
System.Int32 | numberToSplit | Number to be split |
SplitByFixedNumber(String, Int32, PdfSplitOptions)
Declaration
public void SplitByFixedNumber(string destFilePattern, int numberToSplit, PdfSplitOptions splitOptions)
Parameters
Type | Name | Description |
---|---|---|
System.String | destFilePattern | |
System.Int32 | numberToSplit | Number to be split |
PdfSplitOptions | splitOptions | Customize the split PDF |
Examples
// Loads an existing document
PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf");
PdfSplitOptions splitOptions = new PdfSplitOptions();
splitOptions.SplitTags = true;
// Splits the source document
ldoc.SplitByFixedNumber("Output.pdf", 1, splitOptions);
ldoc.Close(true);
' Loads an existing document
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
Dim splitOptions As PdfSplitOptions = New PdfSplitOptions
splitOptions.SplitTags = true
' Splits the source document
ldoc.SplitByFixedNumber("Output.pdf", 1, splitOptions)
ldoc.Close(true)
See Also
SplitByRanges(String, Int32[,])
Declaration
public void SplitByRanges(string destFilePattern, int[, ] ranges)
Parameters
Type | Name | Description |
---|---|---|
System.String | destFilePattern | |
System.Int32[,] | ranges | Ranges of page index values |
Remarks
Page range index starts with 0
SplitByRanges(String, Int32[,], PdfSplitOptions)
Declaration
public void SplitByRanges(string destFilePattern, int[, ] ranges, PdfSplitOptions splitOptions)
Parameters
Type | Name | Description |
---|---|---|
System.String | destFilePattern | |
System.Int32[,] | ranges | Ranges of page index values |
PdfSplitOptions | splitOptions | Customize the split PDF |
Remarks
Page range index starts with 0
Examples
// Loads an existing document
PdfLoadedDocument ldoc = new PdfLoadedDocument("Input.pdf");
PdfSplitOptions splitOptions = new PdfSplitOptions();
splitOptions.SplitTags = true;
// Splits the source document
ldoc.SplitByRanges("Output.pdf", new int[,] { { 0, 5 }, { 5, 10 } }, splitOptions);
ldoc.Close(true);
' Loads an existing document
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("Input.pdf")
Dim splitOptions As PdfSplitOptions = New PdfSplitOptions
splitOptions.SplitTags = true
' Splits the source document
ldoc.SplitByRanges("Output.pdf", New Integer(,) {{2, 5}, {8, 10}}, splitOptions)
ldoc.Close(true)
See Also
Events
OnPdfPassword
The event raised on Pdf password.
Declaration
public event PdfLoadedDocument.OnPdfPasswordEventHandler OnPdfPassword
Event Type
Type |
---|
PdfLoadedDocument.OnPdfPasswordEventHandler |
Examples
// Creates a new document
PdfLoadedDocument lDoc = new PdfLoadedDocument("Input.pdf");
// Subscribe the On pdf password event
lDoc.OnPdfPassword += LDoc_OnPdfPassword;
//Access the attachments
PdfAttachmentCollection attachment=lDoc.Attachments;
//Save the document
lDoc.save("Ouput.pdf");
// On Pdf Password event handler
void LDoc_OnPdfPassword(object sender, OnPdfPasswordEventArgs args)
{
args.UserPassword = "syncfusion";
}
PdfAConversionProgress
The event raised while starting PDF/A conversion progress.
Declaration
public event PdfLoadedDocument.PdfAConversionProgressEventHandler PdfAConversionProgress
Event Type
Type |
---|
PdfLoadedDocument.PdfAConversionProgressEventHandler |
Examples
PdfLoadedDocument document = new PdfLoadedDocument("input.pdf");
//Set the conformance level.
loadedDocument.Conformance = PdfConformanceLevel.Pdf_A1B;
document.PdfAConversionProgress += pdfAConversion_TrackProgress;
//Save the document
document.Save("output.pdf");
document.Close(true);
// Event handler for Track redaction process
void pdfAConversion_TrackProgress(object sender, PdfAConversionProgressEventArgs arguments)
{
MessageBox.Show(String.Format("Pdf/A conversion Process " + arguments.Progress + " % completed");
}
Dim document As PdfLoadedDocument = New PdfLoadedDocument("input.pdf")
'Set the conformance level.
loadedDocument.Conformance = PdfConformanceLevel.Pdf_A1B
document.PdfAConversionProgress += pdfAConversion_TrackProgress
'Save the document
document.Save("output.pdf")
document.Close(True)
'Event handler for Track redaction process
Private Sub pdfAConversion_TrackProgress(ByVal sender As Object, ByVal arguments As PdfAConversionProgressEventArgs)
MessageBox.Show(String.Format("Pdf/A conversion Process " + arguments.Progress + " % completed"))
End Sub
RedactionProgress
The event raised while starting redaction progress.
Declaration
public event PdfLoadedDocument.RedactionProgressEventHandler RedactionProgress
Event Type
Type |
---|
PdfLoadedDocument.RedactionProgressEventHandler |
Examples
PdfLoadedDocument document = new PdfLoadedDocument("input.pdf");
// Get first page from the document
PdfLoadedPage page = document.Pages[0] as PdfLoadedPage;
PdfRedaction redaction = new PdfRedaction(new RectangleF(37, 94, 50, 10), System.Drawing.Color.Black);
//Adds redaction to the loaded page
page.Redactions.Add(redaction);
document.RedactionProgress += redaction_TrackProgress;
//Save the document
document.Save("output.pdf");
document.Close(true);
// Event handler for Track redaction process
void redaction_TrackProgress(object sender, RedactionProgressEventArgs arguments)
{
MessageBox.Show(String.Format("Redaction Process " + arguments.Progress + " % completed"));
}
Dim document As PdfLoadedDocument = New PdfLoadedDocument("input.pdf")
'Get first page from the document
Dim page As PdfLoadedPage = document.Pages(0) as PdfLoadedPage
Dim redaction As PdfRedaction = New PdfRedaction(New RectangleF(37,94,50,10),System.Drawing.Color.Black)
'Adds redaction to the loaded page
page.Redactions.Add(redaction)
document.RedactionProgress += redaction_TrackProgress
'Save the document
document.Save("output.pdf")
document.Close(True)
'Event handler for Track redaction process
Private Sub redaction_TrackProgress(ByVal sender As Object, ByVal arguments As RedactionProgressEventArgs)
MessageBox.Show(String.Format("Redaction Process " + arguments.Progress + " % completed"))
End Sub