Table of Contents

Class PDF

Namespace
PDFjet.NET
Assembly
PDFjet.dll

Used to create PDF objects that represent PDF documents.

public sealed class PDF
Inheritance
PDF
Inherited Members

Constructors

PDF()

The default constructor - use when reading PDF files.

public PDF()

PDF(Stream)

Creates a PDF document that is written to the stream.

public PDF(Stream os)

Parameters

os Stream

PDF(Stream, Compliance)

Creates a PDF document with the specified compliance level.

public PDF(Stream os, Compliance compliance)

Parameters

os Stream

the associated output stream.

compliance Compliance

must be: Compliance.PDF_UA_1, Compliance.PDF_A_1A to Compliance.PDF_A_3B, or Compliance.PDF_A_3A_UA_1, which is both PDF/A-3a and PDF/UA-1

Methods

AddAssociatedFile(EmbeddedFile)

Adds a file that the document carries with it: a reader shows it beside the document, and a program that reads the document finds it by its name. This is how a document of PDF/A-3 carries the data behind what it shows, such as the XML of an invoice.

The file names what it holds, how it relates to the document and what it is, so it has to be made with the constructor of EmbeddedFile that takes them.

public PDF AddAssociatedFile(EmbeddedFile file)

Parameters

file EmbeddedFile

The embedded file.

Returns

PDF

this PDF object.

AddMetadata(string)

Adds a description to the metadata of the document: the rdf:Description element of a standard that asks for properties of its own, such as the invoice standards that say which of the files the document carries is the invoice. The text is written into the metadata as it is given, so it has to be XML, and the document has to be of PDF/A or PDF/UA, which are the documents that carry metadata.

public PDF AddMetadata(string rdfDescription)

Parameters

rdfDescription string

The rdf:Description element.

Returns

PDF

this PDF object.

AddObjects(List<PDFobj>)

Adds objects read from an existing PDF to this document. The objects keep their numbers and are written as they are, so they are added before any font, image or page of this document, and an encrypted PDF cannot take them. Their page tree is the page tree of this document, so it can have no pages of its own, before or after them, and it cannot be a PDF/UA or PDF/A document, as the pages were not made for its compliance.

public void AddObjects(List<PDFobj> objects)

Parameters

objects List<PDFobj>

AddPage(Page)

Adds the page to this document.

public void AddPage(Page page)

Parameters

page Page

AddPages(List<Page>)

Adds the pages to this document.

public void AddPages(List<Page> pages)

Parameters

pages List<Page>

AddResourceObjects(List<PDFobj>)

Adds the fonts, images and graphics states used by the pages to this document. The objects keep their numbers and are written as they are, so they are added before any font, image or page of this document, and an encrypted PDF cannot take them.

public void AddResourceObjects(List<PDFobj> objects)

Parameters

objects List<PDFobj>

Complete()

Completes the construction of the PDF and writes it to the output stream. The output stream is then automatically closed.

public void Complete()

GetCompliance()

Returns the PDF document compliance.

public Compliance GetCompliance()

Returns

Compliance

GetPageObjects(List<PDFobj>)

Returns the page objects, each holding the entries it inherits from the page tree: /Resources, /MediaBox, /CropBox and /Rotate, which a PDF can write once on a node above the pages rather than on every page. A page that has an entry of its own keeps it, and the entries are added to the page the first time it is returned, so that GetPageSize and GetResourcesObject read what the page is.

public List<PDFobj> GetPageObjects(List<PDFobj> objects)

Parameters

objects List<PDFobj>

Returns

List<PDFobj>

Merge(List<PDFobj>)

Adds all the pages of a document that was read with Read after the pages of this document, in their order. A PDF can merge several documents and draw pages of its own before, between and after them.

public void Merge(List<PDFobj> objects)

Parameters

objects List<PDFobj>

the objects of the document, as Read returns them.

Remarks

The merged pages keep their content, resources, annotations and links. The parts of the read document that belong to the whole document are left out: its bookmarks, form fields, tagging, named destinations and optional content settings. The objects that the pages use are written at once, so the list of objects is not needed after the call. A PDF/UA or PDF/A document cannot merge pages, which were not made for its compliance, and Merge cannot be used with AddObjects.

Merge(List<PDFobj>, params int[])

Adds the listed pages of a document that was read with Read after the pages of this document, in the order they are listed. A document is split by merging each part of it into a PDF of its own: the objects that Read returned can be merged into any number of PDFs.

public void Merge(List<PDFobj> objects, params int[] pageNumbers)

Parameters

objects List<PDFobj>

the objects of the document, as Read returns them.

pageNumbers int[]

the numbers of the pages, counted from 1.

Remarks

The pages are merged as Merge(objects) merges all of them, and a link to a page that is not merged leads nowhere. A page number that the document does not have, or one that is listed twice, is refused.

Read(Stream)

Reads the objects of an existing PDF from the stream. An encrypted PDF is decrypted when it opens without a password.

public List<PDFobj> Read(Stream inputStream)

Parameters

inputStream Stream

Returns

List<PDFobj>

Read(Stream, string)

Reads the objects of an existing PDF from the stream, which holds a PDF that is encrypted with the standard security handler. The PDF is decrypted with the password, which is its user or its owner password.

public List<PDFobj> Read(Stream inputStream, string password)

Parameters

inputStream Stream

The PDF input stream.

password string

The user or owner password of the PDF.

Returns

List<PDFobj>

Exceptions

Exception

If the password is not correct.

SetAuthor(string)

Set the "Author" document property of the PDF file.

public PDF SetAuthor(string author)

Parameters

author string

The author of this document.

Returns

PDF

this PDF object.

SetCompliance(Compliance)

Sets the PDF/UA or PDF/A compliance of this document, before any font, image or page is added.

public PDF SetCompliance(Compliance compliance)

Parameters

compliance Compliance

Returns

PDF

SetCreator(string)

Sets the creator in the document metadata.

public PDF SetCreator(string creator)

Parameters

creator string

Returns

PDF

SetEncryption(Encryption)

Sets the encryption applied to this document, before any font, image or page is added.

public PDF SetEncryption(Encryption encryption)

Parameters

encryption Encryption

Returns

PDF

SetKeywords(string)

Sets the keywords in the document metadata.

public PDF SetKeywords(string keywords)

Parameters

keywords string

Returns

PDF

SetLanguage(string)

Set the "Language" document property of the PDF file.

public PDF SetLanguage(string language)

Parameters

language string

The language of this document.

Returns

PDF

this PDF object.

SetPageLayout(PageLayout)

Sets the page layout used when the document is opened. See PageLayout.

public PDF SetPageLayout(PageLayout pageLayout)

Parameters

pageLayout PageLayout

Returns

PDF

SetPageMode(PageMode)

Sets the page mode used when the document is opened. See PageMode.

public PDF SetPageMode(PageMode pageMode)

Parameters

pageMode PageMode

Returns

PDF

SetSubject(string)

Set the "Subject" document property of the PDF file.

public PDF SetSubject(string subject)

Parameters

subject string

The subject of this document.

Returns

PDF

this PDF object.

SetTitle(string)

Set the "Title" document property of the PDF file. An empty title is not written.

public PDF SetTitle(string title)

Parameters

title string

The title of this document.

Returns

PDF

this PDF object.