Class Document

Class Document

Namespace: Aspose.Pdf
Assembly: Aspose.PDF.dll

Class representing PDF document

public sealed class Document : IDisposable

Inheritance

objectDocument

Implements

IDisposable

Inherited Members

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Constructors

Document(Stream)

Initialize new Document instance from the input stream.

public Document(Stream input)

Parameters

input Stream

Stream with pdf document.

Document(Stream, string, bool)

Initialize new Document instance from the input stream.

public Document(Stream input, string password, bool isManagedStream)

Parameters

input Stream

Stream with pdf document.

password string

User or owner password.

isManagedStream bool

if set to true inner stream is closed before exit; otherwise, is not.

Document(Stream, bool)

Initialize new Document instance from the input stream.

public Document(Stream input, bool isManagedStream)

Parameters

input Stream

Stream with pdf document.

isManagedStream bool

if set to true inner stream is closed before exit; otherwise, is not.

Document(string)

Just init Document using filename. The same as Aspose.Pdf.Document.#ctor(System.IO.Stream).

public Document(string filename)

Parameters

filename string

The name of the pdf document file.

Document(Stream, string)

Initialize new Document instance from the input stream.

public Document(Stream input, string password)

Parameters

input Stream

Input stream object, corresponding pdf is password protected.

password string

User or owner password.

Document()

Initializes empty document.

public Document()

Document(string, string)

Initializes new instance of the Aspose.Pdf.Document class for working with encrypted document.

public Document(string filename, string password)

Parameters

filename string

Document file name.

password string

User or owner password.

Document(string, string, bool)

Initializes new instance of the Aspose.Pdf.Document class for working with encrypted document.

public Document(string filename, string password, bool isManagedStream)

Parameters

filename string

Document file name.

password string

User or owner password.

isManagedStream bool

if set to true inner stream is closed before exit; otherwise, is not.

Document(string, LoadOptions)

Opens an existing document from a file providing necessary converting options to get pdf document.

public Document(string filename, LoadOptions options)

Parameters

filename string

Input file to convert into pdf document.

options LoadOptions

Represents properties for converting filename into pdf document.

Document(Stream, LoadOptions)

Opens an existing document from a stream providing necessary converting to get pdf document.

public Document(Stream input, LoadOptions options)

Parameters

input Stream

Input stream to convert into pdf document.

options LoadOptions

Represents properties for converting input into pdf document.

Fields

DefaultNodesNumInSubtrees

public const byte DefaultNodesNumInSubtrees = 10

Field Value

byte

Properties

Actions

Gets document actions. This property is instance of DocumentActions class which allows to get/set BeforClosing, BeforSaving, etc. actions.

public DocumentActionCollection Actions { get; }

Property Value

DocumentActionCollection

Examples

This example demonstrates how to obtain after open action of the document:

Aspose.Pdf.Document document = new Aspose.Pdf.Document("d:\\work\\aspose\\aspose.pdf.kit.net.new\\trunk\\testdata\\Aspose.Pdf\\PdfWithOpenAction.pdf");
Aspose.Pdf.Annotations.DocumentActionCollection actions = document.Actions;
Aspose.Pdf.Annotations.PdfAction afterSavingAction = actions.AfterSaving;

AllowReusePageContent

Allows to merge page contents to optimize docuement size. If used then differnet but duplicated pages may reference to the same content object. Please note that this mode may cause side effects like changing page content when other page is changed.

public bool AllowReusePageContent { get; set; }

Property Value

bool

Background

Gets or sets the background color of the document.

public Color Background { get; set; }

Property Value

Color

CenterWindow

Gets or sets flag specifying whether position of the document’s window will be centerd on the screen.

public bool CenterWindow { get; set; }

Property Value

bool

Examples

Example demonstrates how to get CenterWindow flag:

Document document = new Document("sample.pdf");
bool value = document.CenterWindow;

Collection

Gets collection of document.

public Collection Collection { get; set; }

Property Value

Collection

CryptoAlgorithm

Gets security settings if document is encrypted. If document is not encrypted then corresponding exception will be raised in .net 1.1 or CryptoAlgorithm will be null for other .net versions.

public CryptoAlgorithm? CryptoAlgorithm { get; }

Property Value

CryptoAlgorithm?

Destinations

Gets the collection of destinations. Obsolete. Please use NamedDestinations.

public DestinationCollection Destinations { get; }

Property Value

DestinationCollection

Direction

Gets or sets reading order of text: L2R (left to right) or R2L (right to left).

public Direction Direction { get; set; }

Property Value

Direction

DisableFontLicenseVerifications

Many operations with font can’t be executed if these operations are prohibited by license of this font. For example some font can’t be embedded into PDF document if license rules disable embedding for this font. This flag is used to disable any license restrictions for all fonts in current PDF document. Be careful when using this flag. When it is set it means that person who sets this flag, takes all responsibility of possible license/law violations on himself. So He takes it on it’s own risk. It’s strongly recommended to use this flag only when you are fully confident that you are not breaking the copyright law. By default false.

public bool DisableFontLicenseVerifications { get; set; }

Property Value

bool

DisplayDocTitle

Gets or sets flag specifying whether document’s window title bar should display document title.

public bool DisplayDocTitle { get; set; }

Property Value

bool

Examples

Example demonstrates how to get DisplayDocTitle flag:

Document document = new Document("sample.pdf");
bool value = document.DisplayDocTitle;

Duplex

Gets or sets print duplex mode handling option to use when printing the file from the print dialog.

public PrintDuplex Duplex { get; set; }

Property Value

PrintDuplex

EmbedStandardFonts

Property which declares that document must embed all standard Type1 fonts which has flag IsEmbedded set into true. All PDF fonts can be embedded into document simply via setting of flag IsEmbedded into true, but PDF standard Type1 fonts is an exception from this rule. Standard Type1 font embedding requires much time, so to embed these fonts it’s necessary not only set flag IsEmbedded into true for specified font but also set an additiona flag on document’s level - EmbedStandardFonts = true; This property can be set only one time for all fonts. By default false.

public bool EmbedStandardFonts { get; set; }

Property Value

bool

EmbeddedFiles

Gets collection of files embedded to document.

public EmbeddedFileCollection EmbeddedFiles { get; }

Property Value

EmbeddedFileCollection

EnableObjectUnload

Get or sets flag which enables document partially be unloaded from memory. This allow to decrease memory usage but may have negative effect on perfomance.

public bool EnableObjectUnload { get; set; }

Property Value

bool

EnableSignatureSanitization

Gets or sets flag to manage signature fields sanitization. Enabled by default.

public bool EnableSignatureSanitization { get; set; }

Property Value

bool

FileName

Name of the PDF file that caused this document

public string FileName { get; }

Property Value

string

FitWindow

Gets or sets flag specifying whether document window must be resized to fit the first displayed page.

public bool FitWindow { get; set; }

Property Value

bool

Examples

Example demonstrates how to get FitWindow flag:

Document document = new Document("sample.pdf");
bool value = document.FitWindow;

FontUtilities

IDocumentFontUtilities instance

public Document.IDocumentFontUtilities FontUtilities { get; }

Property Value

Document.IDocumentFontUtilities

Form

Gets Acro Form of the document.

public Form Form { get; }

Property Value

Form

HandleSignatureChange

Throw Exception if the document will save with changes and have signature

public bool HandleSignatureChange { get; set; }

Property Value

bool

HideMenubar

Gets or sets flag specifying whether menu bar should be hidden when document is active.

public bool HideMenubar { get; set; }

Property Value

bool

Examples

Example demonstrates how to get HideMenubar flag:

Document document = new Document("sample.pdf");
bool value = document.HideMenubar;

HideToolBar

Gets or sets flag specifying whether toolbar should be hidden when document is active.

public bool HideToolBar { get; set; }

Property Value

bool

Examples

Example demonstrates how to get HideToolBar flag:

Document document = new Document("sample.pdf");
bool value = document.HideToolBar;

HideWindowUI

Gets or sets flag specifying whether user interface elements should be hidden when document is active.

public bool HideWindowUI { get; set; }

Property Value

bool

Examples

Example demonstrates how to get HideWindowUI flag:

Document document = new Document("sample.pdf");
bool value = document.HideWindowUI;

Id

Gets the ID.

public Id Id { get; }

Property Value

Id

IgnoreCorruptedObjects

Gets or sets flag of ignoring errors in source files. When pages from source document copied into destination document, copying process is stopped with exception if some objects in source files are corrupted when this flag is false. example: dest.Pages.Add(src.Pages); If this flag is set to true then corrupted objects will be replaced with empty values. By default: true.

public bool IgnoreCorruptedObjects { get; set; }

Property Value

bool

Info

Gets document info.

public DocumentInfo Info { get; }

Property Value

DocumentInfo

IsEncrypted

Gets encrypted status of the document. True if document is encrypted.

public bool IsEncrypted { get; }

Property Value

bool

IsLicensed

Gets licensed state of the system. Returns true is system works in licensed mode and false otherwise.

public static bool IsLicensed { get; }

Property Value

bool

IsLinearized

Gets or sets a value indicating whether document is linearized.

public bool IsLinearized { get; set; }

Property Value

bool

IsPdfUaCompliant

Gets the is document pdfua compliant.

public bool IsPdfUaCompliant { get; }

Property Value

bool

IsPdfaCompliant

Gets the is document pdfa compliant.

public bool IsPdfaCompliant { get; }

Property Value

bool

IsXrefGapsAllowed

Gets or sets the is document pdfa compliant.

public bool IsXrefGapsAllowed { get; set; }

Property Value

bool

JavaScript

Collection of JavaScript of document level.

public JavaScriptCollection JavaScript { get; }

Property Value

JavaScriptCollection

LogicalStructure

Gets logical structure of the document.

public RootElement LogicalStructure { get; }

Property Value

RootElement

Metadata

Document metadata. (A PDF document may include general information, such as the document’s title, author, and creation and modification dates. Such global information about the document (as opposed to its content or structure) is called metadata and is intended to assist in cataloguing and searching for documents in external databases.)

public Metadata Metadata { get; }

Property Value

Metadata

NamedDestinations

Collection of Named Destination in the document.

public NamedDestinationCollection NamedDestinations { get; }

Property Value

NamedDestinationCollection

NonFullScreenPageMode

Gets or sets page mode, specifying how to display the document on exiting full-screen mode.

public PageMode NonFullScreenPageMode { get; set; }

Property Value

PageMode

OpenAction

Gets or sets action performed at document opening.

public IAppointment OpenAction { get; set; }

Property Value

IAppointment

Examples

Example demonstrates how to get CenterWindow flag:

Document document = new Document("sample.pdf");
IAppointment value = document.OpenAction;

OptimizeSize

Gets or sets optimization flag. When pages are added to document, equal resource streams in resultant file are merged into one PDF object if this flag set. This allows to decrease resultant file size but may cause slower execution and larger memory requirements. Default value: false.

public bool OptimizeSize { get; set; }

Property Value

bool

Outlines

Gets document outlines.

public OutlineCollection Outlines { get; }

Property Value

OutlineCollection

OutputIntents

Gets the collection of Output intents in the document.

public OutputIntents OutputIntents { get; }

Property Value

OutputIntents

PageInfo

Gets or sets the page info.(for generator only, not filled in when reading document)

public PageInfo PageInfo { get; set; }

Property Value

PageInfo

PageLabels

Gets page labels in the document.

public PageLabelCollection PageLabels { get; }

Property Value

PageLabelCollection

PageLayout

Gets or sets page layout which shall be used when the document is opened.

public PageLayout PageLayout { get; set; }

Property Value

PageLayout

PageMode

Gets or sets page mode, specifying how document should be displayed when opened.

public PageMode PageMode { get; set; }

Property Value

PageMode

Pages

Gets or sets collection of document pages. Note that pages are numbered from 1 in collection.

public PageCollection Pages { get; }

Property Value

PageCollection

Examples

Example below demonstrates how to operate with the document pages: How to obtain number of pages and how to obtain rectangle of starting page of the document.

Aspose.Pdf.Document document = new Aspose.Pdf.Document("sample.pdf");
Aspose.Pdf.PageCollection pages = document.Pages;
System.Console.WriteLine("Document contains " + pages.Count);
Page page = pages[1];
Rectangle rect = page.Rect;

PdfFormat

Gets PDF format

public PdfFormat PdfFormat { get; }

Property Value

PdfFormat

Permissions

Gets permissions of the document.

public int Permissions { get; }

Property Value

int

PickTrayByPdfSize

Gets or sets a flag specifying whether the PDF page size shall be used to select the input paper tray.

public bool PickTrayByPdfSize { get; set; }

Property Value

bool

PrintScaling

Gets or sets the page scaling option that shall be selected when a print dialog is displayed for this document.

public PrintScaling PrintScaling { get; set; }

Property Value

PrintScaling

TaggedContent

Gets access to TaggedPdf content.

public ITaggedContent TaggedContent { get; }

Property Value

ITaggedContent

Examples

The example demonstrates how to use tagged content for creating new document with header, paragraphs and images.

// Create new document
Document document = new Document();

// Get the tagged content
ITaggedContent taggedContent = document.TaggedContent;

// Set language for document
taggedContent.SetLanguage("en-US");

// Set title for PDF document
taggedContent.SetTitle("Example document");

// Creating and adding Section
SectElement sect = taggedContent.CreateSectElement();
taggedContent.RootElement.AppendChild(sect);

// Create Header
HeaderElement h1 = taggedContent.CreateHeaderElement(1);
h1.SetText("The Header");
sect.AppendChild(h1);

// Create paragraph
ParagraphElement p = taggedContent.CreateParagraphElement();
p.SetTag("Paragraph");
p.SetText("The text of paragraph.");
sect.AppendChild(p);

// Create illustration
IllustrationElement figure1 = taggedContent.CreateFigureElement();
sect.AppendChild(figure1);
figure1.AlternativeText = "Figure 1";
figure1.Title = "Image 1";
figure1.SetTag("Fig");
figure1.SetImage("path/of/image.jpg");

// Save document
document.Save("example.pdf");

Version

Gets a version of Pdf from Pdf file header.

public string Version { get; }

Property Value

string

Methods

BindXml(string)

Bind xml to document

public void BindXml(string file)

Parameters

file string

The xml file

BindXml(string, string)

Bind xml/xsl to document

public void BindXml(string xmlFile, string xslFile)

Parameters

xmlFile string

The xml file.

xslFile string

The xsl file if XSLT is used.

BindXml(Stream, Stream)

Bind xml/xsl to document

public void BindXml(Stream xmlStream, Stream xslStream)

Parameters

xmlStream Stream

The xml stream.

xslStream Stream

The xsl stream if XSLT is used.

BindXml(Stream, Stream, XmlReaderSettings)

Bind xml/xsl to document

public void BindXml(Stream xmlStream, Stream xslStream, XmlReaderSettings settings)

Parameters

xmlStream Stream

The xml stream.

xslStream Stream

The xsl stream if XSLT is used.

settings XmlReaderSettings

The xml reader settings.

BindXml(Stream)

Bind xml to document

public void BindXml(Stream stream)

Parameters

stream Stream

The xml stream.

ChangePasswords(string, string, string)

Changes document passwords. This action can be done only using owner password.

public void ChangePasswords(string ownerPassword, string newUserPassword, string newOwnerPassword)

Parameters

ownerPassword string

Owner password.

newUserPassword string

New user password.

newOwnerPassword string

New owner password.

Check(bool)

Validates document.

public bool Check(bool doRepair)

Parameters

doRepair bool

If true found issues will be repaired.

Returns

bool

True - if document repaired; otherwise, false.

Convert(string, PdfFormat, ConvertErrorAction, ConvertTransparencyAction)

Convert document and save errors into the specified file.

public bool Convert(string outputLogFileName, PdfFormat format, ConvertErrorAction action, ConvertTransparencyAction transparencyAction)

Parameters

outputLogFileName string

Path to file where the comments will be stored.

format PdfFormat

The pdf format.

action ConvertErrorAction

Action for objects that can not be converted

transparencyAction ConvertTransparencyAction

Action for image masked objects

Returns

bool

The operation result

Convert(Stream, PdfFormat, ConvertErrorAction, ConvertTransparencyAction)

Convert document and save errors into the specified file.

public bool Convert(Stream outputLogStream, PdfFormat format, ConvertErrorAction action, ConvertTransparencyAction transparencyAction)

Parameters

outputLogStream Stream

Stream where the comments will be stored.

format PdfFormat

The pdf format.

action ConvertErrorAction

Action for objects that can not be converted

transparencyAction ConvertTransparencyAction

Action for image masked objects

Returns

bool

The operation result

Convert(string, PdfFormat, ConvertErrorAction)

Convert document and save errors into the specified file.

public bool Convert(string outputLogFileName, PdfFormat format, ConvertErrorAction action)

Parameters

outputLogFileName string

Path to file where the comments will be stored.

format PdfFormat

The pdf format.

action ConvertErrorAction

Action for objects that can not be converted

Returns

bool

The operation result

Convert(PdfFormatConversionOptions)

Convert document using specified conversion options

public bool Convert(PdfFormatConversionOptions options)

Parameters

options PdfFormatConversionOptions

set of options for convert PDF document

Returns

bool

The operation result

Convert(CallBackGetHocrWithPage, bool)

Recognize images inside the document and add hocr strings over it.

public bool Convert(Document.CallBackGetHocrWithPage callback, bool flattenImages = false)

Parameters

callback Document.CallBackGetHocrWithPage

Action for images that will be processed by hocr recognize.

flattenImages bool

Text in pdf images can be painted using the mechanics of masks, in which case the images must be flattened.

Returns

bool

The operation result. If there are no images in the document returns false.

Convert(CallBackGetHocr, bool)

Recognize images inside the document and add hocr strings over it.

public bool Convert(Document.CallBackGetHocr callback, bool flattenImages = false)

Parameters

callback Document.CallBackGetHocr

Action for images that will be processed by hocr recognize.

flattenImages bool

Text in pdf images can be painted using the mechanics of masks, in which case the images must be flattened.

Returns

bool

The operation result. If there are no images in the document returns false.

Convert(Stream, PdfFormat, ConvertErrorAction)

Convert document and save errors into the specified stream.

public bool Convert(Stream outputLogStream, PdfFormat format, ConvertErrorAction action)

Parameters

outputLogStream Stream

Stream where the comments will be stored.

format PdfFormat

Pdf format.

action ConvertErrorAction

Action for objects that can not be converted

Returns

bool

The operation result

Convert(Fixup, Stream, bool, object[])

Convert document by applying the Fixup.

public bool Convert(Fixup fixup, Stream outputLog, bool onlyValidation = false, object[] parameters = null)

Parameters

fixup Fixup

The Fixup type.

outputLog Stream

The log of process.

onlyValidation bool

Only document validation.

parameters object[]

Properties for Fixup that can not be set.

Returns

bool

The operation result.

Convert(Fixup, string, bool, object[])

Convert document by applying the Fixup.

public bool Convert(Fixup fixup, string outputLog, bool onlyValidation = false, object[] parameters = null)

Parameters

fixup Fixup

The Fixup type.

outputLog string

The log of process.

onlyValidation bool

Only document validation.

parameters object[]

Properties for Fixup that can not be set.

Returns

bool

The operation result.

Convert(string, LoadOptions, string, SaveOptions)

Converts source file in source format into destination file in destination format.

public static void Convert(string srcFileName, LoadOptions loadOptions, string dstFileName, SaveOptions saveOptions)

Parameters

srcFileName string

The source file name.

loadOptions LoadOptions

The source file format.

dstFileName string

The destination file name.

saveOptions SaveOptions

The destination file format.

Convert(Stream, LoadOptions, string, SaveOptions)

Converts stream in source format into destination file in destination format.

public static void Convert(Stream srcStream, LoadOptions loadOptions, string dstFileName, SaveOptions saveOptions)

Parameters

srcStream Stream

The source stream.

loadOptions LoadOptions

The source stream format.

dstFileName string

The destination file name.

saveOptions SaveOptions

The destination file format.

Convert(string, LoadOptions, Stream, SaveOptions)

Converts source file in source format into stream in destination format.

public static void Convert(string srcFileName, LoadOptions loadOptions, Stream dstStream, SaveOptions saveOptions)

Parameters

srcFileName string

The source file name.

loadOptions LoadOptions

The source file format.

dstStream Stream

The destination stream.

saveOptions SaveOptions

The destination stream format.

Convert(Stream, LoadOptions, Stream, SaveOptions)

Converts stream in source format into stream in destination format.

public static void Convert(Stream srcStream, LoadOptions loadOptions, Stream dstStream, SaveOptions saveOptions)

Parameters

srcStream Stream

The source stream.

loadOptions LoadOptions

The source stream format.

dstStream Stream

The destination stream.

saveOptions SaveOptions

The destination file format.

ConvertPageToPNGMemoryStream(Page)

Convert page to PNG for DSR, OMR, OCR image stream.

public MemoryStream ConvertPageToPNGMemoryStream(Page page)

Parameters

page Page

Page to convert.

Returns

MemoryStream

Image stream.

Decrypt()

Decrypts the document. Call then Save to obtain decrypted version of the document.

public void Decrypt()

Dispose()

Closes all resources used by this document.

public void Dispose()

Encrypt(string, string, DocumentPrivilege, CryptoAlgorithm, bool)

Encrypts the document. Call then Save to get encrypted version of the document.

public void Encrypt(string userPassword, string ownerPassword, DocumentPrivilege privileges, CryptoAlgorithm cryptoAlgorithm, bool usePdf20)

Parameters

userPassword string

User password.

ownerPassword string

Owner password.

privileges DocumentPrivilege

Document permissions, see Aspose.Pdf.Document.Permissions for details.

cryptoAlgorithm CryptoAlgorithm

Cryptographic algorithm, see Aspose.Pdf.Document.CryptoAlgorithm for details.

usePdf20 bool

Support for revision 6 (Extension 8).

Encrypt(string, string, Permissions, CryptoAlgorithm)

Encrypts the document. Call then Save to get encrypted version of the document.

public void Encrypt(string userPassword, string ownerPassword, Permissions permissions, CryptoAlgorithm cryptoAlgorithm)

Parameters

userPassword string

User password.

ownerPassword string

Owner password.

permissions Permissions

Document permissions, see Aspose.Pdf.Document.Permissions for details.

cryptoAlgorithm CryptoAlgorithm

Cryptographic algorithm, see Aspose.Pdf.Document.CryptoAlgorithm for details.

Encrypt(string, string, Permissions, CryptoAlgorithm, bool)

Encrypts the document. Call then Save to get encrypted version of the document.

public void Encrypt(string userPassword, string ownerPassword, Permissions permissions, CryptoAlgorithm cryptoAlgorithm, bool usePdf20)

Parameters

userPassword string

User password.

ownerPassword string

Owner password.

permissions Permissions

Document permissions, see Aspose.Pdf.Document.Permissions for details.

cryptoAlgorithm CryptoAlgorithm

Cryptographic algorithm, see Aspose.Pdf.Document.CryptoAlgorithm for details.

usePdf20 bool

Support for revision 6 (Extension 8).

ExportAnnotationsToXfdf(string)

Exports all document annotations to XFDF file

public void ExportAnnotationsToXfdf(string fileName)

Parameters

fileName string

XFDF file name

ExportAnnotationsToXfdf(Stream)

Export all document annotations into stream.

public void ExportAnnotationsToXfdf(Stream stream)

Parameters

stream Stream

Stream where store XFDF.

Flatten()

Removes all fields from the document and place their values instead.

public void Flatten()

Flatten(FlattenSettings)

Removes all fields (and annotations) from the document and place their values instead.

public void Flatten(Form.FlattenSettings flattenSettings)

Parameters

flattenSettings Form.FlattenSettings

Settings for flattening process.

FlattenTransparency()

Replaces transparent content with non-transparent raster and vector graphics.

public void FlattenTransparency()

FreeMemory()

Clears memory

public void FreeMemory()

GetCatalogValue(string)

Returns item value from catalog dictionary.

public object GetCatalogValue(string key)

Parameters

key string

The key of item.

Returns

object

Item value - if key was successfully found; otherwise, null.

GetObjectById(string)

Gets a object with specified ID in the document.

public object GetObjectById(string id)

Parameters

id string

The object id.

Returns

object

The object with specified id. Null if the id is not found.

GetXmpMetadata(Stream)

Get XMP metadata from document.

public void GetXmpMetadata(Stream stream)

Parameters

stream Stream

Stream where metadata will be stored.

HasIncrementalUpdate()

Checks if the current PDF document has been saved with incremental updates.

public bool HasIncrementalUpdate()

Returns

bool

true if the PDF document has incremental updates; otherwise, false.

ImportAnnotationsFromXfdf(string)

Imports annotations from XFDF file to document.

public void ImportAnnotationsFromXfdf(string fileName)

Parameters

fileName string

XFDF file name

ImportAnnotationsFromXfdf(Stream)

Imports annotations from stream to document.

public void ImportAnnotationsFromXfdf(Stream stream)

Parameters

stream Stream

Stream contains XFDF data.

LoadFrom(string, LoadOptions)

Loads a file, converting it to PDF.

public void LoadFrom(string filename, LoadOptions options)

Parameters

filename string

The path to the file to open.

options LoadOptions

The load options.

Exceptions

PdfException

If the file cannot be loaded.

FileNotFoundException

If the file is not found.

Merge(MergeOptions, params Document[])

Merges documents.

public void Merge(Document.MergeOptions mergeOptions, params Document[] documents)

Parameters

mergeOptions Document.MergeOptions

The merge options.

documents Document[]

The documents to merge.

Merge(MergeOptions, params string[])

Merges documents.

public void Merge(Document.MergeOptions mergeOptions, params string[] files)

Parameters

mergeOptions Document.MergeOptions

The merge options.

files string[]

The pdf-files to merge.

Merge(params Document[])

Merges documents.

public void Merge(params Document[] documents)

Parameters

documents Document[]

The documents to merge.

Merge(params string[])

Merges pdf files.

public void Merge(params string[] files)

Parameters

files string[]

The pdf-files to merge.

MergeDocuments(MergeOptions, params string[])

Merges documents.

public static Document MergeDocuments(Document.MergeOptions mergeOptions, params string[] files)

Parameters

mergeOptions Document.MergeOptions

The merge options.

files string[]

The pdf-files to merge.

Returns

Document

The merged document.

MergeDocuments(MergeOptions, params Document[])

Merges documents.

public static Document MergeDocuments(Document.MergeOptions mergeOptions, params Document[] files)

Parameters

mergeOptions Document.MergeOptions

files Document[]

The documents to merge.

Returns

Document

The merged document.

MergeDocuments(params string[])

Merges pdf files.

public static Document MergeDocuments(params string[] files)

Parameters

files string[]

The pdf-files to merge.

Returns

Document

The merged document.

MergeDocuments(params Document[])

Merges documents.

public static Document MergeDocuments(params Document[] documents)

Parameters

documents Document[]

The documents to merge.

Returns

Document

The merged document.

Optimize()

Linearize the document in order to

  • open the first page as quickly as possible;
  • display next page or follow by link to the next page as quickly as possible;
  • display the page incrementally as it arrives when data for a page is delivered over a slow channel (display the most useful data first);
  • permit user interaction, such as following a link, to be performed even before the entire page has been received and displayed. Invoking this method doesn’t actually saves the document. On the contrary the document only is prepared to have optimized structure, call then Save to get optimized document.
public void Optimize()

OptimizeResources()

Optimize resources in the document:

  1. Resources which are not used on the document pages are removed;
  2. Equal resources are joined into one object;
  3. Unused objects are deleted.
public void OptimizeResources()

OptimizeResources(OptimizationOptions)

Optimize resources in the document according to defined optimization strategy.

public void OptimizeResources(OptimizationOptions strategy)

Parameters

strategy OptimizationOptions

Optimization strategy.

PageNodesToBalancedTree(byte)

Organizes page tree nodes in a document into a balanced tree. Only if the document has more than nodesNumInSubtrees page objects, otherwise it does nothing. Do not call this method while iterating over Pages elements, it may give unpredictable results

public void PageNodesToBalancedTree(byte nodesNumInSubtrees = 10)

Parameters

nodesNumInSubtrees byte

Desired number of subnodes. Default value is ten.

ProcessParagraphs()

Process paragraphs for generator.

public void ProcessParagraphs()

RemoveMetadata()

Removes metadata from the document.

public void RemoveMetadata()

RemovePdfUaCompliance()

Remove pdfUa compliance from the document

public void RemovePdfUaCompliance()

RemovePdfaCompliance()

Remove pdfa compliance from the document

public void RemovePdfaCompliance()

Repair()

Repairs broken document.

public void Repair()

Save(Stream)

Stores document into stream.

public void Save(Stream output)

Parameters

output Stream

Stream where document shell be stored.

Save(string)

Saves document into the specified file.

public void Save(string outputFileName)

Parameters

outputFileName string

Path to file where the document will be stored.

Save()

Save document incrementally (i.e. using incremental update technique).

public void Save()

Remarks

In order to save document incrementally we should open the document file for writing. Therefore Document must be initialized with writable stream like in the next code snippet: Document doc = new Document(new FileStream(“document.pdf”, FileMode.Open, FileAccess.ReadWrite)); // make some changes and save the document incrementally doc.Save();

Save(SaveOptions)

Saves the document with save options.

public void Save(SaveOptions options)

Parameters

options SaveOptions

Save options.

Save(string, SaveFormat)

Saves the document with a new name along with a file format.

public void Save(string outputFileName, SaveFormat format)

Parameters

outputFileName string

Path to file where the document will be stored.

format SaveFormat

Format options.

Save(Stream, SaveFormat)

Saves the document with a new name along with a file format.

public void Save(Stream outputStream, SaveFormat format)

Parameters

outputStream Stream

Stream where the document will be stored.

format SaveFormat

Format options.

Exceptions

ArgumentException

System.ArgumentException when Aspose.Pdf.HtmlSaveOptions is passed to a method. Save a document to the html stream is not supported. Please use method save to the file.

Save(string, SaveOptions)

Saves the document with a new name setting its save options.

public void Save(string outputFileName, SaveOptions options)

Parameters

outputFileName string

Path to file where the document will be stored.

options SaveOptions

Save options.

Save(Stream, SaveOptions)

Saves the document to a stream with a save options.

public void Save(Stream outputStream, SaveOptions options)

Parameters

outputStream Stream

Stream where the document will be stored.

options SaveOptions

Save options.

Exceptions

ArgumentException

System.ArgumentException when Aspose.Pdf.HtmlSaveOptions is passed to a method. Save a document to the html stream is not supported. Please use method save to the file.

SaveAsync(Stream, CancellationToken)

Stores document into stream.

public Task SaveAsync(Stream output, CancellationToken cancellationToken)

Parameters

output Stream

Stream where document shell be stored.

cancellationToken CancellationToken

Caclellation token.

Returns

Task

Asynchronous task.

SaveAsync(string, CancellationToken)

Saves document into the specified file.

public Task SaveAsync(string outputFileName, CancellationToken cancellationToken)

Parameters

outputFileName string

Path to file where the document will be stored.

cancellationToken CancellationToken

Caclellation token.

Returns

Task

Asynchronous task.

SaveAsync(CancellationToken)

Save document incrementally (i.e. using incremental update technique).

public Task SaveAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Caclellation token.

Returns

Task

Asynchronous task.

Remarks

In order to save document incrementally we should open the document file for writing. Therefore Document must be initialized with writable stream like in the next code snippet: Document doc = new Document(new FileStream(“document.pdf”, FileMode.Open, FileAccess.ReadWrite)); // make some changes and save the document incrementally doc.Save();

SaveAsync(SaveOptions, CancellationToken)

Saves the document with save options.

public Task SaveAsync(SaveOptions options, CancellationToken cancellationToken)

Parameters

options SaveOptions

Save options.

cancellationToken CancellationToken

Caclellation token.

Returns

Task

Asynchronous task.

SaveAsync(string, SaveFormat, CancellationToken)

Saves the document with a new name along with a file format.

public Task SaveAsync(string outputFileName, SaveFormat format, CancellationToken cancellationToken)

Parameters

outputFileName string

Path to file where the document will be stored.

format SaveFormat

Format options.

cancellationToken CancellationToken

Caclellation token.

Returns

Task

Asynchronous task.

SaveAsync(Stream, SaveFormat, CancellationToken)

Saves the document with a new name along with a file format.

public Task SaveAsync(Stream outputStream, SaveFormat format, CancellationToken cancellationToken)

Parameters

outputStream Stream

Stream where the document will be stored.

format SaveFormat

Format options.

cancellationToken CancellationToken

Cancellation token

Returns

Task

Asynchronous task.

Exceptions

ArgumentException

System.ArgumentException when Aspose.Pdf.HtmlSaveOptions is passed to a method. Save a document to the html stream is not supported. Please use method save to the file.

SaveAsync(string, SaveOptions, CancellationToken)

Saves the document with a new name setting its save options.

public Task SaveAsync(string outputFileName, SaveOptions options, CancellationToken cancellationToken)

Parameters

outputFileName string

Path to file where the document will be stored.

options SaveOptions

Save options.

cancellationToken CancellationToken

Caclellation token.

Returns

Task

Asynchronous task.

SaveAsync(Stream, SaveOptions, CancellationToken)

Saves the document to a stream with a save options.

public Task SaveAsync(Stream outputStream, SaveOptions options, CancellationToken cancellationToken)

Parameters

outputStream Stream

Stream where the document will be stored.

options SaveOptions

Save options.

cancellationToken CancellationToken

Caclellation token.

Returns

Task

Asynchronous task.

Exceptions

ArgumentException

System.ArgumentException when Aspose.Pdf.HtmlSaveOptions is passed to a method. Save a document to the html stream is not supported. Please use method save to the file.

SaveXml(string)

Save document to XML.

public void SaveXml(string file)

Parameters

file string

The document model xml file

SendTo(DocumentDevice, Stream)

Sends the whole document to the document device for processing.

public void SendTo(DocumentDevice device, Stream output)

Parameters

device DocumentDevice

Document device which is used to process the document.

output Stream

Output stream contains the results of the document processing with given device.

SendTo(DocumentDevice, int, int, Stream)

Sends the certain pages of the document to the document device for processing.

public void SendTo(DocumentDevice device, int fromPage, int toPage, Stream output)

Parameters

device DocumentDevice

Document device which is used to process the document.

fromPage int

The first page for processing.

toPage int

The last page for processing.

output Stream

Output stream contains the results of the document pages processing with given device.

SendTo(DocumentDevice, string)

Sends the whole document to the document device for processing.

public void SendTo(DocumentDevice device, string outputFileName)

Parameters

device DocumentDevice

Document device which is used to process the document.

outputFileName string

Output file name with the results of processing.

SendTo(DocumentDevice, int, int, string)

Sends the whole document to the document device for processing.

public void SendTo(DocumentDevice device, int fromPage, int toPage, string outputFileName)

Parameters

device DocumentDevice

Document device which is used to process the document.

fromPage int

The first page for processing.

toPage int

The last page for processing.

outputFileName string

Output file name with the results of processing.

SetTitle(string)

Set Title for Pdf Document

public void SetTitle(string title)

Parameters

title string

Document’s title

SetXmpMetadata(Stream)

Set XMP metadata of document.

public void SetXmpMetadata(Stream stream)

Parameters

stream Stream

Stream which contains XMP metadata.

Validate(string, PdfFormat)

Validate document into the specified file.

public bool Validate(string outputLogFileName, PdfFormat format)

Parameters

outputLogFileName string

Path to file where the comments will be stored.

format PdfFormat

The pdf format.

Returns

bool

The operation result

Validate(Stream, PdfFormat)

Validate document into the specified file.

public bool Validate(Stream outputLogStream, PdfFormat format)

Parameters

outputLogStream Stream

Stream where the comments will be stored.

format PdfFormat

The pdf format.

Returns

bool

The operation result

Validate(PdfFormatConversionOptions)

Validate document into the specified file.

public bool Validate(PdfFormatConversionOptions options)

Parameters

options PdfFormatConversionOptions

set of options for convert PDF document

Returns

bool

The operation result

FontSubstitution

Occurs when font replaces another font in document.

public event Document.FontSubstitutionHandler FontSubstitution

Event Type

Document.FontSubstitutionHandler

 Ελληνικά