Class Document

Document class

Class representing PDF document

public sealed class Document : IDisposable

Constructors

NameDescription
Document()Initializes empty document.
Document(Stream)Initialize new Document instance from the input stream.
Document(string)Just init Document using filename. The same as Document.
Document(Stream, bool)Initialize new Document instance from the input stream.
Document(Stream, LoadOptions)Opens an existing document from a stream providing necessary converting to get pdf document.
Document(Stream, string)Initialize new Document instance from the input stream.
Document(string, LoadOptions)Opens an existing document from a file providing necessary converting options to get pdf document.
Document(string, string)Initializes new instance of the Document class for working with encrypted document.
Document(Stream, string, bool)Initialize new Document instance from the input stream.
Document(string, string, bool)Initializes new instance of the Document class for working with encrypted document.

Properties

NameDescription
Actions { get; }Gets document actions. This property is instance of DocumentActions class which allows to get/set BeforClosing, BeforSaving, etc. actions.
AllowReusePageContent { get; set; }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.
Background { get; set; }Gets or sets the background color of the document.
CenterWindow { get; set; }Gets or sets flag specifying whether position of the document’s window will be centerd on the screen.
Collection { get; set; }Gets collection of document.
CryptoAlgorithm { get; }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.
Destinations { get; }Gets the collection of destinations. Obsolete. Please use NamedDestinations.
Direction { get; set; }Gets or sets reading order of text: L2R (left to right) or R2L (right to left).
DisableFontLicenseVerifications { get; set; }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.
DisplayDocTitle { get; set; }Gets or sets flag specifying whether document’s window title bar should display document title.
Duplex { get; set; }Gets or sets print duplex mode handling option to use when printing the file from the print dialog.
EmbeddedFiles { get; }Gets collection of files embedded to document.
EmbedStandardFonts { get; set; }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.
EnableObjectUnload { get; set; }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.
EnableSignatureSanitization { get; set; }Gets or sets flag to manage signature fields sanitization. Enabled by default.
FileName { get; }Name of the PDF file that caused this document
FitWindow { get; set; }Gets or sets flag specifying whether document window must be resized to fit the first displayed page.
FontUtilities { get; }IDocumentFontUtilities instance
Form { get; }Gets Acro Form of the document.
HandleSignatureChange { get; set; }Throw Exception if the document will save with changes and have signature
HideMenubar { get; set; }Gets or sets flag specifying whether menu bar should be hidden when document is active.
HideToolBar { get; set; }Gets or sets flag specifying whether toolbar should be hidden when document is active.
HideWindowUI { get; set; }Gets or sets flag specifying whether user interface elements should be hidden when document is active.
Id { get; }Gets the ID.
IgnoreCorruptedObjects { get; set; }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.
Info { get; }Gets document info.
IsEncrypted { get; }Gets encrypted status of the document. True if document is encrypted.
IsLinearized { get; set; }Gets or sets a value indicating whether document is linearized.
IsPdfaCompliant { get; }Gets the is document pdfa compliant.
IsPdfUaCompliant { get; }Gets the is document pdfua compliant.
IsXrefGapsAllowed { get; set; }Gets or sets the is document pdfa compliant.
JavaScript { get; }Collection of JavaScript of document level.
LogicalStructure { get; }Gets logical structure of the document.
Metadata { get; }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.)
NamedDestinations { get; }Collection of Named Destination in the document.
NonFullScreenPageMode { get; set; }Gets or sets page mode, specifying how to display the document on exiting full-screen mode.
OpenAction { get; set; }Gets or sets action performed at document opening.
OptimizeSize { get; set; }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.
Outlines { get; }Gets document outlines.
OutputIntents { get; }Gets the collection of Output intents in the document.
PageInfo { get; set; }Gets or sets the page info.(for generator only, not filled in when reading document)
PageLabels { get; }Gets page labels in the document.
PageLayout { get; set; }Gets or sets page layout which shall be used when the document is opened.
PageMode { get; set; }Gets or sets page mode, specifying how document should be displayed when opened.
Pages { get; }Gets or sets collection of document pages. Note that pages are numbered from 1 in collection.
PdfFormat { get; }Gets PDF format
Permissions { get; }Gets permissions of the document.
PrintScaling { get; set; }Gets or sets the page scaling option that shall be selected when a print dialog is displayed for this document.
TaggedContent { get; }Gets access to TaggedPdf content.
Version { get; }Gets a version of Pdf from Pdf file header.
static IsLicensed { get; }Gets licensed state of the system. Returns true is system works in licensed mode and false otherwise.

Methods

NameDescription
static MergeDocuments(params Document[])Merges documents.
static MergeDocuments(params string[])Merges pdf files.
static MergeDocuments(MergeOptions, params Document[])Merges documents.
static MergeDocuments(MergeOptions, params string[])Merges documents.
BindXml(Stream)Bind xml to document
BindXml(string)Bind xml to document
BindXml(Stream, Stream)Bind xml/xsl to document
BindXml(string, string)Bind xml/xsl to document
BindXml(Stream, Stream, XmlReaderSettings)Bind xml/xsl to document
ChangePasswords(string, string, string)Changes document passwords. This action can be done only using owner password.
Check(bool)Validates document.
Convert(PdfFormatConversionOptions)Convert document using specified conversion options
Convert(CallBackGetHocr, bool)Recognize images inside the document and add hocr strings over it.
Convert(CallBackGetHocrWithPage, bool)Recognize images inside the document and add hocr strings over it.
Convert(Stream, PdfFormat, ConvertErrorAction)Convert document and save errors into the specified stream.
Convert(string, PdfFormat, ConvertErrorAction)Convert document and save errors into the specified file.
Convert(Fixup, Stream, bool, object[])Convert document by applying the Fixup.
Convert(Fixup, string, bool, object[])Convert document by applying the Fixup.
Convert(Stream, PdfFormat, ConvertErrorAction, ConvertTransparencyAction)Convert document and save errors into the specified file.
Convert(string, PdfFormat, ConvertErrorAction, ConvertTransparencyAction)Convert document and save errors into the specified file.
ConvertPageToPNGMemoryStream(Page)Convert page to PNG for DSR, OMR, OCR image stream.
Decrypt()Decrypts the document. Call then Save to obtain decrypted version of the document.
Dispose()Closes all resources used by this document.
Encrypt(string, string, Permissions, CryptoAlgorithm)Encrypts the document. Call then Save to get encrypted version of the document.
Encrypt(string, string, DocumentPrivilege, CryptoAlgorithm, bool)Encrypts the document. Call then Save to get encrypted version of the document.
Encrypt(string, string, Permissions, CryptoAlgorithm, bool)Encrypts the document. Call then Save to get encrypted version of the document.
ExportAnnotationsToXfdf(Stream)Export all document annotations into stream.
ExportAnnotationsToXfdf(string)Exports all document annotations to XFDF file
Flatten()Removes all fields from the document and place their values instead.
Flatten(FlattenSettings)Removes all fields (and annotations) from the document and place their values instead.
FlattenTransparency()Replaces transparent content with non-transparent raster and vector graphics.
FreeMemory()Clears memory
GetCatalogValue(string)Returns item value from catalog dictionary.
GetObjectById(string)Gets a object with specified ID in the document.
GetXmpMetadata(Stream)Get XMP metadata from document.
HasIncrementalUpdate()Checks if the current PDF document has been saved with incremental updates.
ImportAnnotationsFromXfdf(Stream)Imports annotations from stream to document.
ImportAnnotationsFromXfdf(string)Imports annotations from XFDF file to document.
LoadFrom(string, LoadOptions)Loads a file, converting it to PDF.
Merge(params Document[])Merges documents.
Merge(params string[])Merges pdf files.
Merge(MergeOptions, params Document[])Merges documents.
Merge(MergeOptions, params string[])Merges documents.
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.
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.
OptimizeResources(OptimizationOptions)Optimize resources in the document according to defined 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
ProcessParagraphs()Process paragraphs for generator.
RemoveMetadata()Removes metadata from the document.
RemovePdfaCompliance()Remove pdfa compliance from the document
RemovePdfUaCompliance()Remove pdfUa compliance from the document
Repair()Repairs broken document.
Save()Save document incrementally (i.e. using incremental update technique).
Save(SaveOptions)Saves the document with save options.
Save(Stream)Stores document into stream.
Save(string)Saves document into the specified file.
Save(Stream, SaveFormat)Saves the document with a new name along with a file format.
Save(Stream, SaveOptions)Saves the document to a stream with a save options.
Save(string, SaveFormat)Saves the document with a new name along with a file format.
Save(string, SaveOptions)Saves the document with a new name setting its save options.
Save(HttpResponse, string, ContentDisposition, SaveOptions)Saves the document to a response stream with a save options.
SaveXml(string)Save document to XML.
SendTo(DocumentDevice, Stream)Sends the whole document to the document device for processing.
SendTo(DocumentDevice, string)Sends the whole document to the document device for processing.
SendTo(DocumentDevice, int, int, Stream)Sends the certain pages of the document to the document device for processing.
SendTo(DocumentDevice, int, int, string)Sends the whole document to the document device for processing.
SetTitle(string)Set Title for Pdf Document
SetXmpMetadata(Stream)Set XMP metadata of document.
Validate(PdfFormatConversionOptions)Validate document into the specified file.
Validate(Stream, PdfFormat)Validate document into the specified file.
Validate(string, PdfFormat)Validate document into the specified file.
static Convert(Stream, LoadOptions, Stream, SaveOptions)Converts stream in source format into stream in destination format.
static Convert(Stream, LoadOptions, string, SaveOptions)Converts stream in source format into destination file in destination format.
static Convert(string, LoadOptions, Stream, SaveOptions)Converts source file in source format into stream in destination format.
static Convert(string, LoadOptions, string, SaveOptions)Converts source file in source format into destination file in destination format.

Fields

NameDescription
const DefaultNodesNumInSubtrees

Events

NameDescription
event FontSubstitutionOccurs when font replaces another font in document.

Other Members

NameDescription
delegate CallBackGetHocr
delegate CallBackGetHocrWithPage
delegate FontSubstitutionHandlerRepresents the method that will handle FontSubstitution event.
interface IDocumentFontUtilitiesHolds functionality to tune fonts
class MergeOptionsRepresents the options to Merge methods.

See Also