Table of Contents

Class PdfLoadedDocument

Namespace
Syncfusion.Pdf.Parsing
Assembly
Syncfusion.Pdf.Portable.dll

Represents a PdfLoadedDocument. You can use this class to load or modify an existing PDF document

public class PdfLoadedDocument : PdfDocumentBase, IDisposable
Inheritance
PdfLoadedDocument
Implements
Inherited Members

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()

Initializes a new instance of the PdfLoadedDocument class with the specified input file path.

public PdfLoadedDocument()
See Also

PdfLoadedDocument(byte[])

Initializes a new instance of the PdfLoadedDocument class with the specified byte array.

public PdfLoadedDocument(byte[] file)

Parameters

file byte[]

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)
See Also

PdfLoadedDocument(byte[], bool)

Initializes a new instance of the PdfLoadedDocument class with specified byte array and repair document.

public PdfLoadedDocument(byte[] file, bool openAndRepair)

Parameters

file byte[]

The array of bytes containing the PDF document to load.

openAndRepair bool

True to repair the document to prevent document corruption

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)

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.

See Also

PdfLoadedDocument(byte[], string)

Initializes a new instance of the PdfLoadedDocument class with the specified byte array and password.

public PdfLoadedDocument(byte[] file, string password)

Parameters

file byte[]

The array of bytes containing the PDF document to load.

password string

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)
See Also

PdfLoadedDocument(byte[], string, bool)

Initializes a new instance of the PdfLoadedDocument class.

public PdfLoadedDocument(byte[] file, string password, bool openAndRepair)

Parameters

file byte[]

The array of bytes containing the PDF document to load.

password string

The password (user or owner) of the encrypted document.

openAndRepair bool

True to repair the document to prevent document corruption

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)

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.

See Also

PdfLoadedDocument(Stream)

Initializes a new instance of the PdfLoadedDocument class with the specified stream.

public PdfLoadedDocument(Stream file)

Parameters

file Stream

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)
See Also

PdfLoadedDocument(Stream, bool)

Initializes a new instance of the PdfLoadedDocument class.

public PdfLoadedDocument(Stream file, bool openAndRepair)

Parameters

file Stream

The stream containing the PDF document to load

openAndRepair bool

True to repair the document to prevent document corruption.

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)

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.

See Also

PdfLoadedDocument(Stream, string)

Initializes a new instance of the PdfLoadedDocument class.

public PdfLoadedDocument(Stream file, string password)

Parameters

file Stream

The stream containing the PDF document to load.

password string

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")
See Also

PdfLoadedDocument(Stream, string, bool)

Initializes a new instance of the PdfLoadedDocument class.

public PdfLoadedDocument(Stream file, string password, bool openAndRepair)

Parameters

file Stream

The stream containing the PDF document to load.

password string

The password (user or owner) of the encrypted document.

openAndRepair bool

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")
See Also

Properties

Actions

Gets the actions to be performed when the document is opened/closed.

public PdfDocumentActions Actions { get; }

Property Value

PdfDocumentActions

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)

Remarks

This property has impact on javascript actions only.

See Also

Attachments

Gets the list of attachments embedded in the document.

public PdfAttachmentCollection Attachments { get; }

Property Value

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.

public override PdfBookmarkBase Bookmarks { get; }

Property Value

PdfBookmarkBase

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.

public PdfColorSpace ColorSpace { get; set; }

Property Value

PdfColorSpace

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)

Remarks

This property has impact on the new created pages only.

See Also

Conformance

Gets the conformance level applied to the loaded document.

public PdfConformanceLevel Conformance { get; set; }

Property Value

PdfConformanceLevel

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)

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.

See Also

DocumentInformation

Gets the document's information such as documents title, keywords, subject etc.,

public override PdfDocumentInformation DocumentInformation { get; }

Property Value

PdfDocumentInformation

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)
See Also

DocumentSecureStore

Access the Document Security Store (DSS) details.

public PdfDocumentSecureStore DocumentSecureStore { get; }

Property Value

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);
See Also

Form

Gets the PDF form fields included in the document.

public PdfLoadedForm Form { get; }

Property Value

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

IsEncrypted

Gets whether the document is encrypted or not.

public bool IsEncrypted { get; }

Property Value

bool

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)
See Also

IsExtendedFeatureEnabled

Returns true, when the PDF document has extended features enabled, otherwise it returns false.

public bool IsExtendedFeatureEnabled { get; }

Property Value

bool

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)
See Also

IsLinearized

Gets whether the document is linearized or not

public bool IsLinearized { get; }

Property Value

bool

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)
See Also

IsPortfolio

Gets whether the document has portfolio content or not

public bool IsPortfolio { get; }

Property Value

bool

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)
See Also

LoadedPageLabel

Gests or sets the PdfPageLabel for the loaded PDF document page number.

public PdfPageLabel LoadedPageLabel { get; set; }

Property Value

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.

public PdfNamedDestinationCollection NamedDestinationCollection { get; }

Property Value

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

PageCount

Gets number of pages.

public override int PageCount { get; }

Property Value

int
See Also

Pages

Gets the document's collection of pages.

public PdfLoadedPageCollection Pages { get; }

Property Value

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.

public PdfPageTemplateCollection PdfPageTemplates { get; }

Property Value

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)
See Also

PortfolioInformation

Gets or set the portfolio information associated with this document

public PdfPortfolioInformation PortfolioInformation { get; set; }

Property Value

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.

public PdfRevision[] Revisions { get; }

Property Value

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)
See Also

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.

public PdfStructureElement StructureElement { get; }

Property Value

PdfStructureElement

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)

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.

See Also

Methods

Clone()

Creates a shallow copy of the current document.

public object Clone()

Returns

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)
See Also

Close(bool)

Releases all the resources allocated by this PDF document

public override void Close(bool completely)

Parameters

completely bool

if set to true the document should close its stream as well.

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)
See Also

CreateAttachment()

Creates a PDF attachments to the loaded document

public PdfAttachmentCollection CreateAttachment()

Returns

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)
See Also

CreateBookmarkRoot()

Creates a bookmarks collection to the loaded document.

public PdfBookmarkBase CreateBookmarkRoot()

Returns

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)
See Also

CreateForm()

Creates a new form to the loaded document

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)
See Also

Dispose()

Release all the resource used by the document instance

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()
See Also

ExportAnnotations(Stream, AnnotationDataFormat)

Exports the annotation data.

public bool ExportAnnotations(Stream stream, AnnotationDataFormat format)

Parameters

stream Stream

Output file stream.

format AnnotationDataFormat

Exporting data format.

Returns

bool

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()
See Also

ExportAnnotations(Stream, AnnotationDataFormat, PdfExportAnnotationCollection)

Exports the annotation data.

public bool ExportAnnotations(Stream stream, AnnotationDataFormat format, PdfExportAnnotationCollection collection)

Parameters

stream Stream

Output file stream.

format AnnotationDataFormat

Exporting data format.

collection PdfExportAnnotationCollection

Annotation collection to export.

Returns

bool

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()
See Also

ExportAnnotations(Stream, AnnotationDataFormat, string)

Exports the annotation data.

public bool ExportAnnotations(Stream stream, AnnotationDataFormat format, string targetFilePath)

Parameters

stream Stream

Output file stream.

format AnnotationDataFormat

Exporting data format.

targetFilePath string

Target file name or path.

Returns

bool

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()
See Also

ExportAnnotations(Stream, AnnotationDataFormat, string, PdfExportAnnotationCollection)

Exports the annotation data.

public bool ExportAnnotations(Stream stream, AnnotationDataFormat format, string targetFilePath, PdfExportAnnotationCollection collection)

Parameters

stream Stream

Output file stream.

format AnnotationDataFormat

Exporting data format.

targetFilePath string

Target file name or path.

collection PdfExportAnnotationCollection

Annotation collection to export.

Returns

bool

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()
See Also

ExportAnnotations(Stream, PdfAnnotationExportSettings)

Export the annotations to a stream with the specified AnnotationExportSettings.

public bool ExportAnnotations(Stream stream, PdfAnnotationExportSettings settings)

Parameters

stream Stream
settings PdfAnnotationExportSettings

Returns

bool

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)
See Also

~PdfLoadedDocument()

Releases unmanaged resources and performs other cleanup operations before the PdfLoadedDocument is reclaimed by garbage collection.

protected ~PdfLoadedDocument()
See Also

FindText(List<string>, out TextSearchResultCollection)

Returns the TextSearchResultCollection instance which contains collection of MatchedItemCollection

public bool FindText(List<string> searchItems, out TextSearchResultCollection searchResult)

Parameters

searchItems List<string>

List of items to be searched.

searchResult TextSearchResultCollection

Instance of TextSearchResultCollection

Returns

bool

Returns true if found any match

See Also

FindText(List<string>, out TextSearchResultCollection, bool)

Returns the TextSearchResultCollection instance which contains collection of MatchedItemCollection

public bool FindText(List<string> searchItems, out TextSearchResultCollection searchResult, bool enableMultiThreading)

Parameters

searchItems List<string>

List of items to be searched.

searchResult TextSearchResultCollection

Instance of TextSearchResultCollection

enableMultiThreading bool

If true,then the text search will be performed asynchronously

Returns

bool

Returns true if found any match

See Also

FindText(List<string>, int, out List<MatchedItem>)

Returns the information of the matched texts in a specific page

public bool FindText(List<string> searchItems, int pageIndex, out List<MatchedItem> searchResults)

Parameters

searchItems List<string>

The List of items to be searched.

pageIndex int

The specified page index

searchResults List<MatchedItem>

Holds the information of the matched texts

Returns

bool

Returns true if found any match

See Also

FindText(List<string>, int, TextSearchOptions, out List<MatchedItem>)

Returns the information of the matched texts in a specific page.

public bool FindText(List<string> searchItems, int pageIndex, TextSearchOptions textSearchOption, out List<MatchedItem> searchResults)

Parameters

searchItems List<string>

List of items to be searched.

pageIndex int

The specified page index

textSearchOption TextSearchOptions

Search option to find the texts

searchResults List<MatchedItem>

Holds the information of the matched texts.

Returns

bool

Returns true if found any match

See Also

FindText(List<string>, TextSearchOptions, out TextSearchResultCollection)

Returns the dictionary of page number and list of captured terms in the PDF document.

public bool FindText(List<string> searchItems, TextSearchOptions textSearchOption, out TextSearchResultCollection searchResult)

Parameters

searchItems List<string>

List of items to be searched.

textSearchOption TextSearchOptions

Search option to find the texts

searchResult TextSearchResultCollection

Returns

bool

Returns true if found any match

See Also

FindText(List<string>, TextSearchOptions, out TextSearchResultCollection, bool)

Returns the dictionary of page number and list of captured terms in the PDF document.

public bool FindText(List<string> searchItems, TextSearchOptions textSearchOption, out TextSearchResultCollection searchResult, bool enableMultiThreading)

Parameters

searchItems List<string>

List of items to be searched.

textSearchOption TextSearchOptions

Search option to find the texts

searchResult TextSearchResultCollection
enableMultiThreading bool

If true,then the text search will be performed asynchronously

Returns

bool

Returns true if found any match

See Also

FindText(List<TextSearchItem>, out TextSearchResultCollection)

Returns the dictionary of page number and list of text search items in the PDF document.

public bool FindText(List<TextSearchItem> searchItems, out TextSearchResultCollection searchResult)

Parameters

searchItems List<TextSearchItem>

List of items to be searched.

searchResult TextSearchResultCollection

Returns

bool

Returns true if found any match

See Also

FindText(List<TextSearchItem>, out TextSearchResultCollection, bool)

Returns the dictionary of page number and list of text search items in the PDF document.

public bool FindText(List<TextSearchItem> searchItems, out TextSearchResultCollection searchResult, bool enableMultiThreading)

Parameters

searchItems List<TextSearchItem>

List of items to be searched.

searchResult TextSearchResultCollection
enableMultiThreading bool

If true,then the text search will be performed asynchronously

Returns

bool

Returns true if found any match

See Also

FindText(List<TextSearchItem>, int, out List<MatchedItem>)

Returns the information of the matched texts in a specific page

public bool FindText(List<TextSearchItem> searchItems, int pageIndex, out List<MatchedItem> searchResults)

Parameters

searchItems List<TextSearchItem>

The List of items to be searched.

pageIndex int

The specified page index

searchResults List<MatchedItem>

Holds the information of the matched texts

Returns

bool

Returns true if found any match

See Also

FindText(string, out Dictionary<int, List<RectangleF>>)

Returns the page number and rectangle positions of the text matches

public bool FindText(string text, out Dictionary<int, List<RectangleF>> matchRect)

Parameters

text string

The text to be searched

matchRect Dictionary<int, List<RectangleF>>

Holds the page number and rectangle positions of the text matches

Returns

bool
See Also

FindText(string, int, out List<RectangleF>)

Returns rectangle positions of the text matches for specific page

public bool FindText(string text, int index, out List<RectangleF> matchRect)

Parameters

text string

The text to be searched

index int

The specified page index

matchRect List<RectangleF>

Holds the rectangle positions of the text matches

Returns

bool
See Also

FlattenAnnotations()

Flatten all annotations in the PDF document

public void FlattenAnnotations()
See Also

FlattenAnnotations(bool)

Flatten all annotations in the PDF document with popups.

public void FlattenAnnotations(bool flattenPopups)

Parameters

flattenPopups bool
See Also

ImportAnnotations(Stream, AnnotationDataFormat)

Imports the annotation data from FDF/XFDF/Json stream.

public void ImportAnnotations(Stream stream, AnnotationDataFormat format)

Parameters

stream Stream

FDF/XFDF stream.

format AnnotationDataFormat

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()
See Also

RemoveConformance()

Remove all the conformance from the PDF document.

public void RemoveConformance()

Examples

This method will not remove the PDF/X, PDF/VT, and PDF/E conformances.

//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)
See Also

Save(Stream)

Saves the PDF document to the specified stream.

public override void Save(Stream stream)

Parameters

stream Stream

The stream where to save the PDF document.

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)
See Also

SplitByFixedNumber(int)

public void SplitByFixedNumber(int numberToSplit)

Parameters

numberToSplit int

Number to be split

See Also

SplitByFixedNumber(int, PdfSplitOptions)

public void SplitByFixedNumber(int numberToSplit, PdfSplitOptions splitOptions)

Parameters

numberToSplit int

Number to be split

splitOptions PdfSplitOptions

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(int[,])

public void SplitByRanges(int[,] ranges)

Parameters

ranges int[,]

Ranges of page index values

Remarks

Page range index starts with 0

See Also

SplitByRanges(int[,], PdfSplitOptions)

public void SplitByRanges(int[,] ranges, PdfSplitOptions splitOptions)

Parameters

ranges int[,]

Ranges of page index values

splitOptions PdfSplitOptions

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.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)

Remarks

Page range index starts with 0

See Also

Events

DocumentSplitEvent

The event is raised when the PDF document is split.

public event PdfLoadedDocument.PdfDocumentSplitEventHandler DocumentSplitEvent

Event Type

PdfLoadedDocument.PdfDocumentSplitEventHandler
See Also

OnPdfPassword

The event raised on Pdf password.

public event PdfLoadedDocument.OnPdfPasswordEventHandler OnPdfPassword

Event 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";
}
See Also

PdfAConversionProgress

The event raised while starting PDF/A conversion progress.

public event PdfLoadedDocument.PdfAConversionProgressEventHandler PdfAConversionProgress

Event 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
See Also

RedactionProgress

The event raised while starting redaction progress.

public event PdfLoadedDocument.RedactionProgressEventHandler RedactionProgress

Event 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
See Also

SubstituteFont

The event raised on Substituting the Pdf font.

public event PdfLoadedDocument.PdfFontEventHandler SubstituteFont

Event Type

PdfLoadedDocument.PdfFontEventHandler

Examples

FileStream docStream = new FileStream(@"Input.pdf", FileMode.Open, FileAccess.Read);
PdfLoadedDocument doc = new PdfLoadedDocument(docStream);
PdfLoadedTextBoxField textBoxField = doc.Form.Fields[0] as PdfLoadedTextBoxField;
doc.Form.SetDefaultAppearance(false);  
doc.SubstituteFont += Doc_SubstituteFont;
TextBoxField.Text = "syncfusion";      
Save(doc, "Output.pdf");
Close the document
doc.Close(true);
Update Pdf Font event handler
void Doc_SubstituteFont(object sender, PdfFontEventArgs args)
{
  string fontName = args.FontName
 //Create the type face. 
  SKTypeface typeface = SKTypeface.FromFamilyName(fontName, SkiaSharp.SKFontStyleWeight.Light, SkiaSharp.SKFontStyleWidth.Normal, SkiaSharp.SKFontStyleSlant.Upright);
   //Create stream assest using type face. 
  SKStreamAsset typeFaceStream = typeface.OpenStream();
  MemoryStream memoryStream = null;


  typeFaceStream


  typeFaceStream.Length
  0


  {
     //Create fontData from type face stream. 
     byte[] fontData = new byte[typeFaceStream.Length - 1];
     typeFaceStream.Read(fontData, typeFaceStream.Length);
     typeFaceStream.Dispose();
     //Create the new memory stream from font data. 
    memoryStream = new MemoryStream(fontData);
  }
//set the font stream to the event args. 
  args.FontStream = memoryStream;
}
See Also

See Also