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.UWP.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()
Initializes a new instance of the PdfLoadedDocument class with the specified input file path.
Declaration
public PdfLoadedDocument()
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")
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
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
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
PageCount
Gets number of pages.
Declaration
public override int PageCount { get; }
Property Value
Type |
---|
System.Int32 |
Overrides
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)
Methods
add_DocumentSplitEvent(PdfLoadedDocument.PdfDocumentSplitEventHandler)
Declaration
public void add_DocumentSplitEvent(PdfLoadedDocument.PdfDocumentSplitEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
PdfLoadedDocument.PdfDocumentSplitEventHandler | value |
add_OnPdfPassword(PdfLoadedDocument.OnPdfPasswordEventHandler)
Declaration
public void add_OnPdfPassword(PdfLoadedDocument.OnPdfPasswordEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
PdfLoadedDocument.OnPdfPasswordEventHandler | value |
add_PdfAConversionProgress(PdfLoadedDocument.PdfAConversionProgressEventHandler)
Declaration
public void add_PdfAConversionProgress(PdfLoadedDocument.PdfAConversionProgressEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
PdfLoadedDocument.PdfAConversionProgressEventHandler | value |
add_RedactionProgress(PdfLoadedDocument.RedactionProgressEventHandler)
Declaration
public void add_RedactionProgress(PdfLoadedDocument.RedactionProgressEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
PdfLoadedDocument.RedactionProgressEventHandler | value |
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)
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()
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)
Finalize()
Releases unmanaged resources and performs other cleanup operations before the PdfLoadedDocument is reclaimed by garbage collection.
Declaration
protected override void Finalize()
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()
OpenAsync(Byte[])
Opens an existing Pdf document
Declaration
public Task<bool> OpenAsync(byte[] bytes)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | bytes | Pdf document in bytes |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | Task returning true if open succeeded |
OpenAsync(Byte[], String)
Opens an existing Pdf document
Declaration
public Task<bool> OpenAsync(byte[] bytes, string password)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | bytes | Pdf document in bytes |
System.String | password | Password for opening the document |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | Task returning true if open succeeded |
OpenAsync(Stream)
Opens an existing Pdf document
Declaration
public Task<bool> OpenAsync(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | Pdf document stream |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | Task returning true if open succeeded |
OpenAsync(Stream, String)
Opens an existing Pdf document
Declaration
public Task<bool> OpenAsync(Stream stream, string password)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | Pdf document stream |
System.String | password | Password for opening the document |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | Task returning true if open succeeded |
OpenAsync(StorageFile)
Opens an exiting Pdf document
Declaration
public Task<bool> OpenAsync(StorageFile stFile)
Parameters
Type | Name | Description |
---|---|---|
Windows.Storage.StorageFile | stFile | Storage File |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | Task returning true if open succeeded |
OpenAsync(StorageFile, String)
Opens an exising Pdf document
Declaration
public Task<bool> OpenAsync(StorageFile stFile, string password)
Parameters
Type | Name | Description |
---|---|---|
Windows.Storage.StorageFile | stFile | Storage File |
System.String | password | Password for opening the document |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | Task returning true if open succeeded |
remove_DocumentSplitEvent(PdfLoadedDocument.PdfDocumentSplitEventHandler)
Declaration
public void remove_DocumentSplitEvent(PdfLoadedDocument.PdfDocumentSplitEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
PdfLoadedDocument.PdfDocumentSplitEventHandler | value |
remove_OnPdfPassword(PdfLoadedDocument.OnPdfPasswordEventHandler)
Declaration
public void remove_OnPdfPassword(PdfLoadedDocument.OnPdfPasswordEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
PdfLoadedDocument.OnPdfPasswordEventHandler | value |
remove_PdfAConversionProgress(PdfLoadedDocument.PdfAConversionProgressEventHandler)
Declaration
public void remove_PdfAConversionProgress(PdfLoadedDocument.PdfAConversionProgressEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
PdfLoadedDocument.PdfAConversionProgressEventHandler | value |
remove_RedactionProgress(PdfLoadedDocument.RedactionProgressEventHandler)
Declaration
public void remove_RedactionProgress(PdfLoadedDocument.RedactionProgressEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
PdfLoadedDocument.RedactionProgressEventHandler | value |
Save()
Saves the modified document
Declaration
public Task<bool> Save()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> | Task returning true if open succeeded |
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)
SaveAsync(Stream)
Saves the document to the specified stream.
Declaration
public Task<bool> SaveAsync(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream. |
Returns
Type |
---|
System.Threading.Tasks.Task<System.Boolean> |
SplitByFixedNumber(Int32)
Declaration
public void SplitByFixedNumber(int numberToSplit)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | numberToSplit | Number to be split |
SplitByFixedNumber(Int32, PdfSplitOptions)
Declaration
public void SplitByFixedNumber(int numberToSplit, PdfSplitOptions splitOptions)
Parameters
Type | Name | Description |
---|---|---|
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(Int32[,])
Declaration
public void SplitByRanges(int[, ] ranges)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[,] | ranges | Ranges of page index values |
Remarks
Page range index starts with 0
SplitByRanges(Int32[,], PdfSplitOptions)
Declaration
public void SplitByRanges(int[, ] ranges, PdfSplitOptions splitOptions)
Parameters
Type | Name | Description |
---|---|---|
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
DocumentSplitEvent
The event is raised when the PDF document is split.
Declaration
public event PdfLoadedDocument.PdfDocumentSplitEventHandler DocumentSplitEvent
Event Type
Type |
---|
PdfLoadedDocument.PdfDocumentSplitEventHandler |
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