• DR-IT Software
  • Products
  • Documentation
  • Product page
  • Examples
  • API reference
  • Support
Show / Hide Table of Contents

Class Document

Top-level PDF document. Entry point for creating, reading, and saving PDFs.

Inheritance
object
Document
Implements
IDisposable
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
Namespace: DRIT.Pdf
Assembly: DRIT.Pdf.dll
Syntax
public sealed class Document : IDisposable

Constructors

Document()

Create a new, empty PDF document.

Declaration
public Document()

Properties

Collection

Portfolio (collection) view for this document's embedded files. Set to a new PdfCollection instance to activate portfolio mode.

Declaration
public PdfCollection? Collection { get; set; }
Property Value
Type Description
PdfCollection

EmbeddedFiles

Files embedded in this document.

Declaration
public EmbeddedFileCollection EmbeddedFiles { get; }
Property Value
Type Description
EmbeddedFileCollection

Form

The interactive form (AcroForm) associated with this document.

Declaration
public AcroForm Form { get; }
Property Value
Type Description
AcroForm

Identifier

Document identifier pair (spec §7.5.5, trailer /ID). Lazily loaded for documents opened from a file/stream. When set to null, the writer auto-generates the /ID on save.

Declaration
public DocumentIdentifier? Identifier { get; set; }
Property Value
Type Description
DocumentIdentifier

Info

Document-level metadata (Title, Author, Subject, Keywords, Creator).

Declaration
public DocumentInfo Info { get; }
Property Value
Type Description
DocumentInfo

Language

Language identifier (spec §7.9.2, catalog /Lang). An RFC 3066 language tag such as "en-US".

Declaration
public Language Language { get; set; }
Property Value
Type Description
Language

Metadata

XMP metadata entries associated with this document.

Declaration
public MetadataCollection Metadata { get; }
Property Value
Type Description
MetadataCollection

Names

Document-level names dictionary (spec §7.7.2, catalog /Names). Contains named destinations and document-level JavaScript.

Declaration
public DocumentNames Names { get; }
Property Value
Type Description
DocumentNames

OptionalContent

Optional content groups (layers) for this document.

Declaration
public OptionalContentCollection OptionalContent { get; }
Property Value
Type Description
OptionalContentCollection

Outlines

The document outline (bookmarks) collection.

Declaration
public OutlineCollection Outlines { get; }
Property Value
Type Description
OutlineCollection

PageLayout

Page layout mode (spec §12.2.1, catalog /PageLayout). Controls how pages are laid out in the viewer. Null means not set.

Declaration
public PageLayout? PageLayout { get; set; }
Property Value
Type Description
PageLayout?

PageMode

Specifies how the viewer should display the document when it is first opened. Writes /PageMode to the catalog on Save.

Declaration
public PageMode PageMode { get; set; }
Property Value
Type Description
PageMode

Pages

The page collection. Use Pages.Add() to add blank pages.

Declaration
public PageCollection Pages { get; }
Property Value
Type Description
PageCollection

SaveOptions

Options applied when calling Save(Stream). Lazily created on first access.

Declaration
public SaveOptions SaveOptions { get; }
Property Value
Type Description
SaveOptions

SecurityStore

Signature validation/security store (DSS) metadata container.

Declaration
public SecurityStore SecurityStore { get; }
Property Value
Type Description
SecurityStore

TaggedContent

Tagged PDF structure tree content.

Declaration
public TaggedContent TaggedContent { get; }
Property Value
Type Description
TaggedContent

ViewerPreferences

Viewer preferences (spec §12.2, catalog /ViewerPreferences). Lazily loaded for documents opened from a file/stream.

Declaration
public ViewerPreferences ViewerPreferences { get; }
Property Value
Type Description
ViewerPreferences

Methods

AppendPage(Document, int, PdfPoint)

Imports the content of source.Pages[pageIndex] as a Form XObject placed at insertAt on a newly created page in this document. The source page's content stream must already be committed (i.e. the source document must have been saved at least once before calling this method).

Declaration
public void AppendPage(Document source, int pageIndex, PdfPoint insertAt)
Parameters
Type Name Description
Document source
int pageIndex
PdfPoint insertAt

ApplyRedactions()

Apply all pending redaction annotations: paints solid black rectangles over the redacted areas and removes the redaction annotation markers. Call this before Save(Stream).

Declaration
public void ApplyRedactions()

Dispose()

Releases all resources used by the Document.

Declaration
public void Dispose()

Extract()

Creates an immutable extraction projection of this document. This is a concise alias for GetExtractionProjection().

Declaration
public PdfExtractionProjection Extract()
Returns
Type Description
PdfExtractionProjection

GetCatalogDictionary()

Returns a controlled low-level view of the catalog dictionary for advanced edits.

Declaration
public ObjectDictionary GetCatalogDictionary()
Returns
Type Description
ObjectDictionary

GetExtractionProjection()

Creates an immutable, importer-facing projection of the parsed document. Pages, content elements, and annotations are copied into projection records; the parser and content-stream interpreter remain implementation details.

Declaration
public PdfExtractionProjection GetExtractionProjection()
Returns
Type Description
PdfExtractionProjection

Load(Stream)

Load a PDF document from a stream.

Declaration
public static Document Load(Stream stream)
Parameters
Type Name Description
Stream stream

A readable, seekable stream containing a valid PDF file.

Returns
Type Description
Document

Load(Stream, LoadOptions)

Load a PDF document from a stream with load options (e.g. password).

Declaration
public static Document Load(Stream stream, LoadOptions options)
Parameters
Type Name Description
Stream stream
LoadOptions options
Returns
Type Description
Document

Load(string)

Load a PDF document from a file path.

Declaration
public static Document Load(string filePath)
Parameters
Type Name Description
string filePath
Returns
Type Description
Document

Load(string, LoadOptions)

Load a PDF document from a file path with load options (e.g. password).

Declaration
public static Document Load(string filePath, LoadOptions options)
Parameters
Type Name Description
string filePath
LoadOptions options
Returns
Type Description
Document

RemoveOpenAction()

Removes the document open action from the catalog.

Declaration
public void RemoveOpenAction()

Save(Stream)

Save the document to a stream.

Declaration
public void Save(Stream stream)
Parameters
Type Name Description
Stream stream

Save(string)

Save the document to a file.

Declaration
public void Save(string filePath)
Parameters
Type Name Description
string filePath

SetOpenActionGoToPage(Page, DestinationViewType, params double[])

Sets a document open action that navigates to a page destination when the document is opened.

Declaration
public void SetOpenActionGoToPage(Page page, DestinationViewType viewType, params double[] args)
Parameters
Type Name Description
Page page
DestinationViewType viewType
double[] args

SetOpenActionJavaScript(string)

Sets a document open action that executes JavaScript when the document is opened.

Declaration
public void SetOpenActionJavaScript(string script)
Parameters
Type Name Description
string script

Implements

IDisposable

Extension Methods

DocumentRenderingExtensions.Print(Document)
DocumentRenderingExtensions.Print(Document, PrintOptions)
DocumentRenderingExtensions.Save(Document, Stream, ImageSaveOptions)
DocumentRenderingExtensions.Save(Document, string, ImageSaveOptions)
Back to top

DR-IT Software documentation

DR-IT Software · Products · Documentation index · Product page · Downloads · Support · Licensing

Generated by DocFX