Table of Contents

Class PdfWriter

Namespace
iTextSharp.text.pdf
Assembly
iTextSharp.LGPLv2.Core.dll

A DocWriter class for PDF. When this PdfWriter is added to a certain PdfDocument , the PDF representation of every Element added to this Document will be written to the outputstream.

public class PdfWriter : DocWriter, IDocListener, IElementListener, IDisposable, IPdfViewerPreferences, IPdfEncryptionSettings, IPdfVersion, IPdfDocumentActions, IPdfPageActions, IPdfXConformance, IPdfRunDirection, IPdfAnnotations
Inheritance
PdfWriter
Implements
Derived
Inherited Members

Constructors

PdfWriter()

Constructs a PdfWriter .

protected PdfWriter()

PdfWriter(PdfDocument, Stream)

protected PdfWriter(PdfDocument document, Stream os)

Parameters

document PdfDocument
os Stream

Fields

ALLOW_ASSEMBLY

The operation permitted when the document is opened with the user password @since 2.0.7

public const int ALLOW_ASSEMBLY = 1024

Field Value

int

ALLOW_COPY

The operation permitted when the document is opened with the user password @since 2.0.7

public const int ALLOW_COPY = 16

Field Value

int

ALLOW_DEGRADED_PRINTING

The operation permitted when the document is opened with the user password @since 2.0.7

public const int ALLOW_DEGRADED_PRINTING = 4

Field Value

int

ALLOW_FILL_IN

The operation permitted when the document is opened with the user password @since 2.0.7

public const int ALLOW_FILL_IN = 256

Field Value

int

ALLOW_MODIFY_ANNOTATIONS

The operation permitted when the document is opened with the user password @since 2.0.7

public const int ALLOW_MODIFY_ANNOTATIONS = 32

Field Value

int

ALLOW_MODIFY_CONTENTS

The operation permitted when the document is opened with the user password @since 2.0.7

public const int ALLOW_MODIFY_CONTENTS = 8

Field Value

int

ALLOW_PRINTING

The operation permitted when the document is opened with the user password @since 2.0.7

public const int ALLOW_PRINTING = 2052

Field Value

int

ALLOW_SCREENREADERS

permissions

public const int ALLOW_SCREENREADERS = 512

Field Value

int

AllowAssembly

@deprecated As of iText 2.0.7, use {@link #ALLOW_ASSEMBLY} instead. Scheduled for removal at or after 2.2.0

public const int AllowAssembly = 1024

Field Value

int

AllowCopy

@deprecated As of iText 2.0.7, use {@link #ALLOW_COPY} instead. Scheduled for removal at or after 2.2.0

public const int AllowCopy = 16

Field Value

int

AllowDegradedPrinting

@deprecated As of iText 2.0.7, use {@link #ALLOW_DEGRADED_PRINTING} instead. Scheduled for removal at or after 2.2.0

public const int AllowDegradedPrinting = 4

Field Value

int

AllowFillIn

@deprecated As of iText 2.0.7, use {@link #ALLOW_FILL_IN} instead. Scheduled for removal at or after 2.2.0

public const int AllowFillIn = 256

Field Value

int

AllowModifyAnnotations

@deprecated As of iText 2.0.7, use {@link #ALLOW_MODIFY_ANNOTATIONS} instead. Scheduled for removal at or after 2.2.0

public const int AllowModifyAnnotations = 32

Field Value

int

AllowModifyContents

@deprecated As of iText 2.0.7, use {@link #ALLOW_MODIFY_CONTENTS} instead. Scheduled for removal at or after 2.2.0

public const int AllowModifyContents = 8

Field Value

int

AllowPrinting

@deprecated As of iText 2.0.7, use {@link #ALLOW_PRINTING} instead. Scheduled for removal at or after 2.2.0

public const int AllowPrinting = 2052

Field Value

int

AllowScreenReaders

@deprecated As of iText 2.0.7, use {@link #ALLOW_SCREENREADERS} instead. Scheduled for removal at or after 2.2.0

public const int AllowScreenReaders = 512

Field Value

int

Body

body of the PDF document

protected PdfWriter.PdfBody Body

Field Value

PdfWriter.PdfBody

CenterWindow

A viewer preference

public const int CenterWindow = 65536

Field Value

int

ColorNumber

The color number counter for the colors in the document.

protected int ColorNumber

Field Value

int

Crypto

[F1] PdfEncryptionSettings interface

protected PdfEncryption Crypto

Field Value

PdfEncryption

CurrentPdfReaderInstance

protected PdfReaderInstance CurrentPdfReaderInstance

Field Value

PdfReaderInstance

DO_NOT_ENCRYPT_METADATA

Add this to the mode to keep the metadata in clear text

public const int DO_NOT_ENCRYPT_METADATA = 8

Field Value

int

DidPrint

action value

public static PdfName DidPrint

Field Value

PdfName

DidSave

action value

public static PdfName DidSave

Field Value

PdfName

DirectionL2R

A viewer preference

public const int DirectionL2R = 4194304

Field Value

int

DirectionR2L

A viewer preference

public const int DirectionR2L = 8388608

Field Value

int

DisplayDocTitle

A viewer preference

public const int DisplayDocTitle = 131072

Field Value

int

DocumentClose

action value

public static PdfName DocumentClose

Field Value

PdfName

DocumentColors

The colors of this document

protected INullValueDictionary<PdfSpotColor, ColorDetails> DocumentColors

Field Value

INullValueDictionary<PdfSpotColor, ColorDetails>

DocumentExtGState

protected INullValueDictionary<PdfDictionary, PdfObject[]> DocumentExtGState

Field Value

INullValueDictionary<PdfDictionary, PdfObject[]>

DocumentFonts

The fonts of this document

protected INullValueDictionary<BaseFont, FontDetails> DocumentFonts

Field Value

INullValueDictionary<BaseFont, FontDetails>

DocumentOcGorder

[F13] Optional Content Groups

protected List<IPdfOcg> DocumentOcGorder

Field Value

List<IPdfOcg>

DocumentOcg

protected INullValueDictionary<IPdfOcg, object> DocumentOcg

Field Value

INullValueDictionary<IPdfOcg, object>

DocumentPatterns

The patterns of this document

protected INullValueDictionary<PdfPatternPainter, PdfName> DocumentPatterns

Field Value

INullValueDictionary<PdfPatternPainter, PdfName>

DocumentProperties

protected INullValueDictionary<object, PdfObject[]> DocumentProperties

Field Value

INullValueDictionary<object, PdfObject[]>

DocumentShadingPatterns

protected INullValueDictionary<PdfShadingPattern, object> DocumentShadingPatterns

Field Value

INullValueDictionary<PdfShadingPattern, object>

DocumentShadings

protected INullValueDictionary<PdfShading, object> DocumentShadings

Field Value

INullValueDictionary<PdfShading, object>

DocumentSpotPatterns

protected INullValueDictionary<ColorDetails, ColorDetails> DocumentSpotPatterns

Field Value

INullValueDictionary<ColorDetails, ColorDetails>

EMBEDDED_FILES_ONLY

Add this to the mode to keep encrypt only the embedded files. @since 2.1.3

public const int EMBEDDED_FILES_ONLY = 24

Field Value

int

ENCRYPTION_AES_128

Type of encryption

public const int ENCRYPTION_AES_128 = 2

Field Value

int

ENCRYPTION_AES_256_V3

Type of encryption

public const int ENCRYPTION_AES_256_V3 = 4

Field Value

int

FitWindow

A viewer preference

public const int FitWindow = 32768

Field Value

int

FontNumber

[F3] adding fonts

protected int FontNumber

Field Value

int

FormXObjects

The form XObjects in this document. The key is the xref and the value is Object[]{PdfName, template}.

protected INullValueDictionary<PdfIndirectReference, object[]> FormXObjects

Field Value

INullValueDictionary<PdfIndirectReference, object[]>

FormXObjectsCounter

[F4] adding (and releasing) form XObjects

protected int FormXObjectsCounter

Field Value

int

GENERATION_MAX

The highest generation number possible. @since iText 2.1.6

public const int GENERATION_MAX = 65535

Field Value

int

HideMenubar

INNER CLASSES

public const int HideMenubar = 8192

Field Value

int

HideToolbar

A viewer preference

public const int HideToolbar = 4096

Field Value

int

HideWindowUI

values for setting viewer preferences in iText versions older than 2.x

public const int HideWindowUI = 16384

Field Value

int

ImageDictionary

Dictionary, containing all the images of the PDF document

protected PdfDictionary ImageDictionary

Field Value

PdfDictionary

ImportedPages

protected INullValueDictionary<PdfReader, PdfReaderInstance> ImportedPages

Field Value

INullValueDictionary<PdfReader, PdfReaderInstance>

Jbig2Globals

A Hashtable with Stream objects containing JBIG2 Globals @since 2.1.5

protected INullValueDictionary<PdfStream, PdfIndirectReference> Jbig2Globals

Field Value

INullValueDictionary<PdfStream, PdfIndirectReference>

NO_SPACE_CHAR_RATIO

Disable the inter-character spacing.

public const float NO_SPACE_CHAR_RATIO = 10000000

Field Value

float

NewBookmarks

protected IList<INullValueDictionary<string, object>> NewBookmarks

Field Value

IList<INullValueDictionary<string, object>>

NonFullScreenPageModeUseNone

A viewer preference

public const int NonFullScreenPageModeUseNone = 262144

Field Value

int

NonFullScreenPageModeUseOC

A viewer preference

public const int NonFullScreenPageModeUseOC = 2097152

Field Value

int

NonFullScreenPageModeUseOutlines

A viewer preference

public const int NonFullScreenPageModeUseOutlines = 524288

Field Value

int

NonFullScreenPageModeUseThumbs

A viewer preference

public const int NonFullScreenPageModeUseThumbs = 1048576

Field Value

int

OcgLocked

protected PdfArray OcgLocked

Field Value

PdfArray

OcgRadioGroup

protected PdfArray OcgRadioGroup

Field Value

PdfArray

PDFA1A

PDFA-1A level.

public const int PDFA1A = 3

Field Value

int

PDFA1B

PDFA-1B level.

public const int PDFA1B = 4

Field Value

int

PDFX1A2001

PDF/X level

public const int PDFX1A2001 = 1

Field Value

int

PDFX32002

PDF/X level

public const int PDFX32002 = 2

Field Value

int

PDFXNONE

PDF/X level

public const int PDFXNONE = 0

Field Value

int

PageClose

action value

public static readonly PdfName PageClose

Field Value

PdfName

PageLayoutOneColumn

A viewer preference

public const int PageLayoutOneColumn = 2

Field Value

int

PageLayoutSinglePage

A viewer preference

public const int PageLayoutSinglePage = 1

Field Value

int

PageLayoutTwoColumnLeft

page layout (section 13.1.1 of "iText in Action")

public const int PageLayoutTwoColumnLeft = 4

Field Value

int

PageLayoutTwoColumnRight

[C3] PdfViewerPreferences interface

public const int PageLayoutTwoColumnRight = 8

Field Value

int

PageLayoutTwoPageLeft

A viewer preference

public const int PageLayoutTwoPageLeft = 16

Field Value

int

PageLayoutTwoPageRight

A viewer preference

public const int PageLayoutTwoPageRight = 32

Field Value

int

PageModeFullScreen

A viewer preference

public const int PageModeFullScreen = 512

Field Value

int

PageModeUseAttachments

A viewer preference

public const int PageModeUseAttachments = 2048

Field Value

int

PageModeUseNone

A viewer preference

public const int PageModeUseNone = 64

Field Value

int

PageModeUseOC

A viewer preference

public const int PageModeUseOC = 1024

Field Value

int

PageModeUseOutlines

page mode (section 13.1.2 of "iText in Action")

public const int PageModeUseOutlines = 128

Field Value

int

PageModeUseThumbs

A viewer preference

public const int PageModeUseThumbs = 256

Field Value

int

PageOpen

action value

public static readonly PdfName PageOpen

Field Value

PdfName

PageReferences

The PdfIndirectReference to the pages.

protected List<PdfIndirectReference> PageReferences

Field Value

List<PdfIndirectReference>

PatternColorspaceCmyk

protected ColorDetails PatternColorspaceCmyk

Field Value

ColorDetails

PatternColorspaceGray

protected ColorDetails PatternColorspaceGray

Field Value

ColorDetails

PatternColorspaceRgb

[M2] spot patterns

protected ColorDetails PatternColorspaceRgb

Field Value

ColorDetails

PatternNumber

[F7] document patterns

protected int PatternNumber

Field Value

int

Pdf

the PdfDocument instance

protected PdfDocument Pdf

Field Value

PdfDocument

PdfVersion12

possible PDF version (catalog)

public static readonly PdfName PdfVersion12

Field Value

PdfName

PdfVersion13

possible PDF version (catalog)

public static readonly PdfName PdfVersion13

Field Value

PdfName

PdfVersion14

possible PDF version (catalog)

public static readonly PdfName PdfVersion14

Field Value

PdfName

PdfVersion15

possible PDF version (catalog)

public static readonly PdfName PdfVersion15

Field Value

PdfName

PdfVersion16

possible PDF version (catalog)

public static readonly PdfName PdfVersion16

Field Value

PdfName

PdfVersion17

possible PDF version (catalog)

public static readonly PdfName PdfVersion17

Field Value

PdfName

Prevxref

A number refering to the previous Cross-Reference Table.

protected int Prevxref

Field Value

int

PrintScalingNone

A viewer preference

public const int PrintScalingNone = 16777216

Field Value

int

RUN_DIRECTION_DEFAULT

Use the default run direction.

public const int RUN_DIRECTION_DEFAULT = 0

Field Value

int

RUN_DIRECTION_LTR

Use bidirectional reordering with left-to-right preferential run direction.

public const int RUN_DIRECTION_LTR = 2

Field Value

int

RUN_DIRECTION_NO_BIDI

[U7] run direction (doesn't actually do anything)

public const int RUN_DIRECTION_NO_BIDI = 1

Field Value

int

RUN_DIRECTION_RTL

Use bidirectional reordering with right-to-left preferential run direction.

public const int RUN_DIRECTION_RTL = 3

Field Value

int

Root

The root of the page tree.

protected PdfPages Root

Field Value

PdfPages

SIGNATURE_APPEND_ONLY

signature value

public const int SIGNATURE_APPEND_ONLY = 2

Field Value

int

SIGNATURE_EXISTS

signature value

public const int SIGNATURE_EXISTS = 1

Field Value

int

SPACE_CHAR_RATIO_DEFAULT

The default space-char ratio.

public const float SPACE_CHAR_RATIO_DEFAULT = 2.5

Field Value

float

STANDARD_ENCRYPTION_128

Type of encryption

public const int STANDARD_ENCRYPTION_128 = 1

Field Value

int

STANDARD_ENCRYPTION_40

Type of encryption

public const int STANDARD_ENCRYPTION_40 = 0

Field Value

int

STRENGTH128BITS

@deprecated As of iText 2.0.7, use {@link #STANDARD_ENCRYPTION_128} instead. Scheduled for removal at or after 2.2.0

public const bool STRENGTH128BITS = true

Field Value

bool

STRENGTH40BITS

Strength of the encryption (kept for historical reasons)

public const bool STRENGTH40BITS = false

Field Value

bool

Tagged

protected bool Tagged

Field Value

bool

VERSION_1_2

[C2] PdfVersion interface

public const char VERSION_1_2 = '2'

Field Value

char

VERSION_1_3

possible PDF version (header)

public const char VERSION_1_3 = '3'

Field Value

char

VERSION_1_4

possible PDF version (header)

public const char VERSION_1_4 = '4'

Field Value

char

VERSION_1_5

possible PDF version (header)

public const char VERSION_1_5 = '5'

Field Value

char

VERSION_1_6

possible PDF version (header)

public const char VERSION_1_6 = '6'

Field Value

char

VERSION_1_7

possible PDF version (header)

public const char VERSION_1_7 = '7'

Field Value

char

VOcProperties

protected PdfOcProperties VOcProperties

Field Value

PdfOcProperties

WillPrint

action value

public static PdfName WillPrint

Field Value

PdfName

WillSave

[C6] Actions (open and additional)

public static PdfName WillSave

Field Value

PdfName

compressionLevel

The compression level of the content streams. @since 2.1.3

protected int compressionLevel

Field Value

int

currentPageNumber

The current page number.

protected int currentPageNumber

Field Value

int

defaultColorspace

protected PdfDictionary defaultColorspace

Field Value

PdfDictionary

directContent

The direct content in this document.

protected PdfContentByte directContent

Field Value

PdfContentByte

directContentUnder

You should see Direct Content as a canvas on which you can draw graphics and text. One canvas goes on top of the page (getDirectContent), the other goes underneath (getDirectContentUnder). You can always the same object throughout your document, even if you have moved to a new page. Whatever you add on the canvas will be displayed on top or under the current page.

protected PdfContentByte directContentUnder

Field Value

PdfContentByte

extraCatalog

Holds value of property extraCatalog.

protected PdfDictionary extraCatalog

Field Value

PdfDictionary

fullCompression

Holds value of property fullCompression.

protected bool fullCompression

Field Value

bool

group

A group attributes dictionary specifying the attributes of the page�s page group for use in the transparent imaging model

protected PdfDictionary group

Field Value

PdfDictionary

pdf_version

Stores the version information for the header and the catalog.

protected PdfVersionImp pdf_version

Field Value

PdfVersionImp

runDirection

protected int runDirection

Field Value

int

structureTreeRoot

protected PdfStructureTreeRoot structureTreeRoot

Field Value

PdfStructureTreeRoot

tabs

The page root keeps the complete page tree of the document. There's an entry in the Catalog that refers to the root of the page tree, the page tree contains the references to pages and other page trees.

protected PdfName tabs

Field Value

PdfName

userunit

protected float userunit

Field Value

float

xmpMetadata

XMP Metadata for the document.

protected byte[] xmpMetadata

Field Value

byte[]

Properties

AcroForm

public PdfAcroForm AcroForm { get; }

Property Value

PdfAcroForm

Collection

[C7] portable collections

public PdfCollection Collection { set; }

Property Value

PdfCollection

CompressionLevel

Sets the compression level to be used for streams written by this writer. @since 2.1.3

public int CompressionLevel { get; set; }

Property Value

int

CropBoxSize

Sets the crop box. The crop box should not be rotated even if the page is rotated. This change only takes effect in the next page.

public virtual Rectangle CropBoxSize { set; }

Property Value

Rectangle

CurrentDocumentSize

Gets the current document size. This size only includes the data already writen to the output stream, it does not include templates or fonts. It is usefull if used with freeReader() when concatenating many documents and an idea of the current size is needed.

public int CurrentDocumentSize { get; }

Property Value

int

the approximate size without fonts or templates

CurrentPageHeight

This is the current height of the document.

public float CurrentPageHeight { get; }

Property Value

float

CurrentPageNumber

public virtual int CurrentPageNumber { get; }

Property Value

int

DefaultColorspace

[M1] Color settings

public PdfDictionary DefaultColorspace { get; }

Property Value

PdfDictionary

the default colorspaces

DirectContent

the PdfDirectContentByte instances

public virtual PdfContentByte DirectContent { get; }

Property Value

PdfContentByte

the direct content

DirectContentUnder

Use this method to get the direct content under for this document. There is only one direct content, multiple calls to this method will allways retrieve the same object.

public virtual PdfContentByte DirectContentUnder { get; }

Property Value

PdfContentByte

the direct content

Duration

Sets the display duration for the page (for presentations)

public virtual int Duration { set; }

Property Value

int

ExtraCatalog

Sets extra keys to the catalog.

public PdfDictionary ExtraCatalog { get; }

Property Value

PdfDictionary

the catalog to change

FullCompression

[F2] compression

public bool FullCompression { get; }

Property Value

bool

true if the 1.5 compression is on

Group

[U5] Transparency groups

public PdfDictionary Group { get; set; }

Property Value

PdfDictionary

Info

Use this method to get the info dictionary if you want to change it directly (add keys and values to the info dictionary).

public PdfDictionary Info { get; }

Property Value

PdfDictionary

the info dictionary

OcProperties

Gets the Optional Content Properties Dictionary. Each call fills the dictionary with the current layer state. It's advisable to only call this method right before close and do any modifications at that time.

public PdfOcProperties OcProperties { get; }

Property Value

PdfOcProperties

the Optional Content Properties Dictionary

Outlines

Sets the bookmarks. The list structure is defined in {@link SimpleBookmark}.

public IList<INullValueDictionary<string, object>> Outlines { set; }

Property Value

IList<INullValueDictionary<string, object>>

PageDictionary

Adds additional entries to the page dictionary.

public PdfDictionary PageDictionary { get; set; }

Property Value

PdfDictionary

PageEmpty

If you use SetPageEmpty(false), invoking NewPage() after a blank page will add a newPage.

public bool PageEmpty { set; }

Property Value

bool

PageEvent

Page events are specific for iText, not for PDF. Upon specific events (for instance when a page starts or ends), the corresponing method in the page event implementation that is added to the writer is invoked.

public IPdfPageEvent PageEvent { get; set; }

Property Value

IPdfPageEvent

the PdfPageEvent for this document or null

PageLabels

Use this method to add page labels

public virtual PdfPageLabels PageLabels { set; }

Property Value

PdfPageLabels

PageNumber

Gets the pagenumber of this document. This number can be different from the real pagenumber, if you have (re)set the page number previously.

public int PageNumber { get; }

Property Value

int

a page number

PageSize

Gives the size of the media box.

public Rectangle PageSize { get; }

Property Value

Rectangle

a Rectangle

PageXmpMetadata

Use this method to set the XMP Metadata for each page.

public byte[] PageXmpMetadata { set; }

Property Value

byte[]

PdfIndirectReference

Gets a PdfIndirectReference for an object that will be created in the future.

public PdfIndirectReference PdfIndirectReference { get; }

Property Value

PdfIndirectReference

the PdfIndirectReference

PdfVersion

@see com.lowagie.text.pdf.interfaces.PdfVersion#setPdfVersion(char)

public virtual char PdfVersion { set; }

Property Value

char

PdfxConformance

Sets the PDFX conformance level. Allowed values are PDFX1A2001 and PDFX32002. It must be called before opening the document.

public int PdfxConformance { get; set; }

Property Value

int

RgbTransparencyBlending

Sets the transparency blending colorspace to RGB. The default blending colorspace is CMYK and will result in faded colors in the screen and in printing. Calling this method will return the RGB colors to what is expected. The RGB blending will be applied to all subsequent pages until other value is set. Note that this is a generic solution that may not work in all cases. to use the default blending colorspace

public bool RgbTransparencyBlending { get; set; }

Property Value

bool

RootOutline

Use this method to get the root outline and construct bookmarks.

public PdfOutline RootOutline { get; }

Property Value

PdfOutline

the root outline

RunDirection

Sets the run direction. This is only used as a placeholder as it does not affect anything.

public virtual int RunDirection { get; set; }

Property Value

int

SigFlags

Set the signature flags.

public virtual int SigFlags { set; }

Property Value

int

SpaceCharRatio

Sets the ratio between the extra word spacing and the extra character spacing when the text is fully justified. Extra word spacing will grow spaceCharRatio times more than extra character spacing. If the ratio is PdfWriter.NO_SPACE_CHAR_RATIO then the extra character spacing will be zero.

public virtual float SpaceCharRatio { get; set; }

Property Value

float

StrictImageSequence

Sets the image sequence to follow the text in strict order.

public bool StrictImageSequence { get; set; }

Property Value

bool

StructureTreeRoot

Gets the structure tree root. If the document is not marked for tagging it will return null .

public PdfStructureTreeRoot StructureTreeRoot { get; }

Property Value

PdfStructureTreeRoot

the structure tree root

Tabs

Sets the value for the Tabs entry in the page tree. Since the Adobe Extensions Level 3, it can also be PdfName.A or PdfName.W @since 2.1.5

public PdfName Tabs { get; set; }

Property Value

PdfName

Thumbnail

Sets the the thumbnail image for the current page. @throws PdfException on error @throws DocumentException or error

public virtual Image Thumbnail { set; }

Property Value

Image

Transition

Sets the transition for the page

public virtual PdfTransition Transition { set; }

Property Value

PdfTransition

UserProperties

Sets the flag indicating the presence of structure elements that contain user properties attributes.

public bool UserProperties { get; set; }

Property Value

bool

Userunit

[U4] Thumbnail image

public float Userunit { get; set; }

Property Value

float

ViewerPreferences

Sets the viewer preferences as the sum of several constants. @see PdfViewerPreferences#setViewerPreferences

public virtual int ViewerPreferences { set; }

Property Value

int

XmpMetadata

[C9] Metadata

public byte[] XmpMetadata { get; set; }

Property Value

byte[]

Methods

Add(PdfIccBased)

protected virtual PdfIndirectReference Add(PdfIccBased icc)

Parameters

icc PdfIccBased

Returns

PdfIndirectReference

AddAnnotation(PdfAnnotation)

[C8] AcroForm

public virtual void AddAnnotation(PdfAnnotation annot)

Parameters

annot PdfAnnotation

the PdfAnnotation or the PdfFormField to add

AddCalculationOrder(PdfFormField)

Adds the PdfAnnotation to the calculation order array.

public virtual void AddCalculationOrder(PdfFormField annot)

Parameters

annot PdfFormField

the PdfAnnotation to be added

AddDeveloperExtension(PdfDeveloperExtension)

@see com.lowagie.text.pdf.interfaces.PdfVersion#addDeveloperExtension(com.lowagie.text.pdf.PdfDeveloperExtension) @since 2.1.6

public void AddDeveloperExtension(PdfDeveloperExtension de)

Parameters

de PdfDeveloperExtension

AddDirectImageSimple(Image)

Adds an image to the document but not to the page resources. It is used with templates and Document.Add(Image) . @throws PdfException on error @throws DocumentException on error

public PdfName AddDirectImageSimple(Image image)

Parameters

image Image

the Image to add

Returns

PdfName

the name of the image added

AddDirectImageSimple(Image, PdfIndirectReference)

Adds an image to the document but not to the page resources. It is used with templates and Document.Add(Image) . a PdfIndirectReference or a PRIndirectReference . @throws PdfException on error @throws DocumentException on error

public PdfName AddDirectImageSimple(Image image, PdfIndirectReference fixedRef)

Parameters

image Image

the Image to add

fixedRef PdfIndirectReference

the reference to used. It may be null ,

Returns

PdfName

the name of the image added

AddFileAttachment(string, byte[], string, string)

Adds a file attachment at the document level. the file will be read from the disk fileStore is not null @throws IOException on error

public virtual void AddFileAttachment(string description, byte[] fileStore, string file, string fileDisplay)

Parameters

description string

the file description

fileStore byte[]

an array with the file. If it's null

file string

the path to the file. It will only be used if

fileDisplay string

the actual file name stored in the pdf

AddFileAttachment(string, PdfFileSpecification)

Adds a file attachment at the document level.

public virtual void AddFileAttachment(string description, PdfFileSpecification fs)

Parameters

description string

the file description

fs PdfFileSpecification

the file specification

AddFileAttachment(PdfFileSpecification)

Adds a file attachment at the document level.

public void AddFileAttachment(PdfFileSpecification fs)

Parameters

fs PdfFileSpecification

the file specification

AddJavaScript(string)

Adds a JavaScript action at the document level. When the document opens all this JavaScript runs.

public virtual void AddJavaScript(string code)

Parameters

code string

the JavaScript code

AddJavaScript(string, bool)

[C4] Page labels

public virtual void AddJavaScript(string code, bool unicode)

Parameters

code string

the JavaScript code

unicode bool

select JavaScript unicode. Note that the internal

AddJavaScript(string, string)

Use this method to adds a JavaScript action at the document level. When the document opens, all this JavaScript runs.

public void AddJavaScript(string name, string code)

Parameters

name string

The name of the JS Action in the name tree

code string

the JavaScript code

AddJavaScript(string, string, bool)

Use this method to add a JavaScript action at the document level. When the document opens, all this JavaScript runs. Acrobat JavaScript engine does not support unicode, so this may or may not work for you

public void AddJavaScript(string name, string code, bool unicode)

Parameters

name string

The name of the JS Action in the name tree

code string

the JavaScript code

unicode bool

select JavaScript unicode. Note that the internal

AddJavaScript(string, PdfAction)

Use this method to add a JavaScript action at the document level. When the document opens, all this JavaScript runs.

public void AddJavaScript(string name, PdfAction js)

Parameters

name string

The name of the JS Action in the name tree

js PdfAction

The JavaScript action

AddJavaScript(PdfAction)

Use this method to add a JavaScript action at the document level. When the document opens, all this JavaScript runs.

public virtual void AddJavaScript(PdfAction js)

Parameters

js PdfAction

The JavaScript action

AddOcgRadioGroup(IList<PdfLayer>)

Sets a collection of optional content groups whose states are intended to follow a "radio button" paradigm. That is, the state of at most one optional content group in the array should be ON at a time: if one group is turned ON, all others must be turned OFF.

public void AddOcgRadioGroup(IList<PdfLayer> group)

Parameters

group IList<PdfLayer>

the radio group

AddSharedObjectsToBody()

protected void AddSharedObjectsToBody()

AddToBody(PdfObject)

Adds an object to the PDF body. @throws IOException

public PdfIndirectObject AddToBody(PdfObject objecta)

Parameters

objecta PdfObject

Returns

PdfIndirectObject

a PdfIndirectObject

AddToBody(PdfObject, bool)

Adds an object to the PDF body. @throws IOException

public PdfIndirectObject AddToBody(PdfObject objecta, bool inObjStm)

Parameters

objecta PdfObject
inObjStm bool

Returns

PdfIndirectObject

a PdfIndirectObject

AddToBody(PdfObject, int)

Adds an object to the PDF body. @throws IOException

public PdfIndirectObject AddToBody(PdfObject objecta, int refNumber)

Parameters

objecta PdfObject
refNumber int

Returns

PdfIndirectObject

a PdfIndirectObject

AddToBody(PdfObject, int, bool)

Adds an object to the PDF body. @throws IOException

public PdfIndirectObject AddToBody(PdfObject objecta, int refNumber, bool inObjStm)

Parameters

objecta PdfObject
refNumber int
inObjStm bool

Returns

PdfIndirectObject

a PdfIndirectObject

AddToBody(PdfObject, PdfIndirectReference)

Adds an object to the PDF body. @throws IOException

public PdfIndirectObject AddToBody(PdfObject objecta, PdfIndirectReference refa)

Parameters

objecta PdfObject
refa PdfIndirectReference

Returns

PdfIndirectObject

a PdfIndirectObject

AddToBody(PdfObject, PdfIndirectReference, bool)

Adds an object to the PDF body. @throws IOException

public PdfIndirectObject AddToBody(PdfObject objecta, PdfIndirectReference refa, bool inObjStm)

Parameters

objecta PdfObject
refa PdfIndirectReference
inObjStm bool

Returns

PdfIndirectObject

a PdfIndirectObject

AddViewerPreference(PdfName, PdfObject)

Adds a viewer preference @see PdfViewerPreferences#addViewerPreference

public virtual void AddViewerPreference(PdfName key, PdfObject value)

Parameters

key PdfName
value PdfObject

ClearTextWrap()

[M3] Images

public void ClearTextWrap()

Close()

Signals that the Document was closed and that no other Elements will be added. The pages-tree is built and written to the outputstream. A Catalog is constructed, as well as an Info-object, the referencetable is composed and everything is written to the outputstream embedded in a Trailer.

public override void Close()

CreateXmpMetadata()

Creates XMP Metadata based on the metadata in the PdfDocument.

public void CreateXmpMetadata()

FillOcProperties(bool)

protected void FillOcProperties(bool erase)

Parameters

erase bool

FitsPage(Table)

[M4] Old table functionality; do we still need it?

public bool FitsPage(Table table)

Parameters

table Table

the table that has to be checked

Returns

bool

true if the Table fits the page, false otherwise.

FitsPage(Table, float)

Checks if a Table fits the current page of the PdfDocument .

public bool FitsPage(Table table, float margin)

Parameters

table Table

the table that has to be checked

margin float

a certain margin

Returns

bool

true if the Table fits the page, false otherwise.

FreeReader(PdfReader)

Writes the reader to the document and frees the memory used by it. The main use is when concatenating multiple documents to keep the memory usage restricted to the current appending document. @throws IOException on error

public virtual void FreeReader(PdfReader reader)

Parameters

reader PdfReader

the PdfReader to free

GetBoxSize(string)

Gives the size of a trim, art, crop or bleed box, or null if not defined.

public Rectangle GetBoxSize(string boxName)

Parameters

boxName string

crop, trim, art or bleed

Returns

Rectangle

GetCatalog(PdfIndirectReference)

protected virtual PdfDictionary GetCatalog(PdfIndirectReference rootObj)

Parameters

rootObj PdfIndirectReference

Returns

PdfDictionary

GetImportedPage(PdfReader, int)

[F5] adding pages imported form other PDF documents

public virtual PdfImportedPage GetImportedPage(PdfReader reader, int pageNumber)

Parameters

reader PdfReader

the PDF document where the page is

pageNumber int

the page number. The first page is 1

Returns

PdfImportedPage

the template representing the imported page

GetInstance(Document, Stream)

public static PdfWriter GetInstance(Document document, Stream os)

Parameters

document Document
os Stream

Returns

PdfWriter

GetInstance(Document, Stream, IDocListener)

public static PdfWriter GetInstance(Document document, Stream os, IDocListener listener)

Parameters

document Document
os Stream
listener IDocListener

Returns

PdfWriter

GetNewObjectNumber(PdfReader, int, int)

protected virtual int GetNewObjectNumber(PdfReader reader, int number, int generation)

Parameters

reader PdfReader
number int
generation int

Returns

int

GetPageReference(int)

Use this method to get a reference to a page existing or not. If the page does not exist yet the reference will be created in advance. If on closing the document, a page number greater than the total number of pages was requested, an exception is thrown.

public virtual PdfIndirectReference GetPageReference(int page)

Parameters

page int

the page number. The first page is 1

Returns

PdfIndirectReference

the reference to the page

GetReferenceJbig2Globals(byte[])

Gets an indirect reference to a JBIG2 Globals stream. Adds the stream if it hasn't already been added to the writer. @since 2.1.5

protected PdfIndirectReference GetReferenceJbig2Globals(byte[] content)

Parameters

content byte[]

a byte array that may already been added to the writer inside a stream object.

Returns

PdfIndirectReference

GetVerticalPosition(bool)

Use this method to get the current vertical page position. for elements that do not terminate the lines they've started because those lines will get terminated.

public float GetVerticalPosition(bool ensureNewLine)

Parameters

ensureNewLine bool

Tells whether a new line shall be enforced. This may cause side effects

Returns

float

The current vertical page position.

IsPdfX()

@see com.lowagie.text.pdf.interfaces.PdfXConformance#isPdfX()

public bool IsPdfX()

Returns

bool

IsTagged()

Check if the document is marked for tagging.

public bool IsTagged()

Returns

bool

true if the document is marked for tagging

LockLayer(PdfLayer)

Use this method to lock an optional content group. The state of a locked group cannot be changed through the user interface of a viewer application. Producers can use this entry to prevent the visibility of content that depends on these groups from being changed by users. @since 2.1.2

public void LockLayer(PdfLayer layer)

Parameters

layer PdfLayer

the layer that needs to be added to the array of locked OCGs

Open()

page events

public override void Open()

ReleaseTemplate(PdfTemplate)

Releases the memory used by a template by writing it to the output. The template can still be added to any content but changes to the template itself won't have any effect. @throws IOException on error

public void ReleaseTemplate(PdfTemplate tp)

Parameters

tp PdfTemplate

the template to release

ReorderPages(int[])

Use this method to reorder the pages in the document. A null argument value only returns the number of pages to process. It is advisable to issue a Document.newPage() before using this method. same size as the number of pages. @throws DocumentException if all the pages are not present in the array

public int ReorderPages(int[] order)

Parameters

order int[]

an array with the new page sequence. It must have the

Returns

int

the total number of pages

SetAdditionalAction(PdfName, PdfAction)

Additional-actions defining the actions to be taken in response to various trigger events affecting the document as a whole. The actions types allowed are: DOCUMENT_CLOSE , WILL_SAVE , DID_SAVE , WILL_PRINT and DID_PRINT . @throws PdfException on invalid action type

public virtual void SetAdditionalAction(PdfName actionType, PdfAction action)

Parameters

actionType PdfName

the action type

action PdfAction

the action to execute in response to the trigger

SetAtLeastPdfVersion(char)

@see com.lowagie.text.pdf.interfaces.PdfVersion#setAtLeastPdfVersion(char)

public void SetAtLeastPdfVersion(char version)

Parameters

version char

SetBoxSize(string, Rectangle)

[U1] page size

public void SetBoxSize(string boxName, Rectangle size)

Parameters

boxName string

the box size

size Rectangle

the size

SetDefaultColorspace(PdfName, PdfObject)

Miscellaneous topics

public void SetDefaultColorspace(PdfName key, PdfObject cs)

Parameters

key PdfName

the name of the colorspace. It can be PdfName.DEFAULTGRAY , PdfName.DEFAULTRGB

cs PdfObject

the colorspace. A null or PdfNull removes any colorspace with the same name

SetEncryption(X509Certificate[], int[], int)

Sets the certificate encryption options for this document. An array of one or more public certificates must be provided together with an array of the same size for the permissions for each certificate. The open permissions for the document can be AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations, AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting. The permissions can be combined by ORing them. Optionally DO_NOT_ENCRYPT_METADATA can be ored to output the metadata in cleartext @throws DocumentException if the document is already open

public void SetEncryption(X509Certificate[] certs, int[] permissions, int encryptionType)

Parameters

certs X509Certificate[]

the public certificates to be used for the encryption

permissions int[]

the user permissions for each of the certicates

encryptionType int

the type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128.

SetEncryption(bool, string, string, int)

Sets the encryption options for this document. The userPassword and the ownerPassword can be null or have zero length. In this case the ownerPassword is replaced by a random string. The open permissions for the document can be AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations, AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting. The permissions can be combined by ORing them. @throws DocumentException if the document is already open

public void SetEncryption(bool strength, string userPassword, string ownerPassword, int permissions)

Parameters

strength bool

true for 128 bit key length, false for 40 bit key length

userPassword string

the user password. Can be null or empty

ownerPassword string

the owner password. Can be null or empty

permissions int

the user permissions

SetEncryption(byte[], byte[], int, bool)

Sets the encryption options for this document. The userPassword and the ownerPassword can be null or have zero length. In this case the ownerPassword is replaced by a random string. The open permissions for the document can be AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations, AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting. The permissions can be combined by ORing them. @throws DocumentException if the document is already open

public void SetEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, bool strength128Bits)

Parameters

userPassword byte[]

the user password. Can be null or empty

ownerPassword byte[]

the owner password. Can be null or empty

permissions int

the user permissions

strength128Bits bool

true for 128 bit key length, false for 40 bit key length

SetEncryption(byte[], byte[], int, int)

Sets the encryption options for this document. The userPassword and the ownerPassword can be null or have zero length. In this case the ownerPassword is replaced by a random string. The open permissions for the document can be AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations, AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting. The permissions can be combined by ORing them. Optionally DO_NOT_ENCRYPT_METADATA can be ored to output the metadata in cleartext @throws DocumentException if the document is already open

public void SetEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionType)

Parameters

userPassword byte[]

the user password. Can be null or empty

ownerPassword byte[]

the owner password. Can be null or empty

permissions int

the user permissions

encryptionType int

the type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128.

SetEncryption(int, string, string, int)

Sets the encryption options for this document. The userPassword and the ownerPassword can be null or have zero length. In this case the ownerPassword is replaced by a random string. The open permissions for the document can be AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations, AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting. The permissions can be combined by ORing them. Optionally DO_NOT_ENCRYPT_METADATA can be ored to output the metadata in cleartext @throws DocumentException if the document is already open

public void SetEncryption(int encryptionType, string userPassword, string ownerPassword, int permissions)

Parameters

encryptionType int

the type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128.

userPassword string

the user password. Can be null or empty

ownerPassword string

the owner password. Can be null or empty

permissions int

the user permissions

SetFullCompression()

Sets the document's compression to the new 1.5 mode with object streams and xref streams. It can be set at any time but once set it can't be unset. If set before opening the document it will also set the pdf version to 1.5.

public void SetFullCompression()

SetLinearPageMode()

PdfPages

public void SetLinearPageMode()

SetOpenAction(string)

When the document opens it will jump to the destination with this name.

public virtual void SetOpenAction(string name)

Parameters

name string

the name of the destination to jump to

SetOpenAction(PdfAction)

When the document opens this action will be invoked.

public virtual void SetOpenAction(PdfAction action)

Parameters

action PdfAction

the action to be invoked

SetOutputIntents(string, string, string, string, byte[])

[C11] Output intents

public void SetOutputIntents(string outputConditionIdentifier, string outputCondition, string registryName, string info, byte[] destOutputProfile)

Parameters

outputConditionIdentifier string

a value

outputCondition string

a value, "PDFA/A" to force GTS_PDFA1, otherwise cued by pdfxConformance.

registryName string

a value

info string

a value

destOutputProfile byte[]

a value

SetOutputIntents(string, string, string, string, IccProfile)

Sets the values of the output intent dictionary. Null values are allowed to suppress any key. @throws IOException on error

public void SetOutputIntents(string outputConditionIdentifier, string outputCondition, string registryName, string info, IccProfile colorProfile)

Parameters

outputConditionIdentifier string
outputCondition string
registryName string
info string
colorProfile IccProfile

SetOutputIntents(PdfReader, bool)

Copies the output intent dictionary from other document to this one. dictionary, false to insert the dictionary if it exists @throws IOException on error otherwise

public bool SetOutputIntents(PdfReader reader, bool checkExistence)

Parameters

reader PdfReader

the other document

checkExistence bool

true to just check for the existence of a valid output intent

Returns

bool

true if the output intent dictionary exists, false

SetPageAction(PdfName, PdfAction)

User methods to change aspects of the page

public virtual void SetPageAction(PdfName actionType, PdfAction action)

Parameters

actionType PdfName

the action type. It can be PdfWriter.PAGE_OPEN

action PdfAction

the action to perform

SetPdfVersion(PdfName)

@see com.lowagie.text.pdf.interfaces.PdfVersion#setPdfVersion(com.lowagie.text.pdf.PdfName)

public void SetPdfVersion(PdfName version)

Parameters

version PdfName

SetTagged()

[F12] tagged PDF

public void SetTagged()

WriteOutlines(PdfDictionary, bool)

[C1] Outlines (bookmarks)

protected void WriteOutlines(PdfDictionary catalog, bool namedAsNames)

Parameters

catalog PdfDictionary
namedAsNames bool