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
PdfDocumentos
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
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
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
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
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
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
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
ALLOW_SCREENREADERS
permissions
public const int ALLOW_SCREENREADERS = 512
Field Value
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
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
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
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
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
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
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
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
Body
body of the PDF document
protected PdfWriter.PdfBody Body
Field Value
CenterWindow
A viewer preference
public const int CenterWindow = 65536
Field Value
ColorNumber
The color number counter for the colors in the document.
protected int ColorNumber
Field Value
Crypto
[F1] PdfEncryptionSettings interface
protected PdfEncryption Crypto
Field Value
CurrentPdfReaderInstance
protected PdfReaderInstance CurrentPdfReaderInstance
Field Value
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
DidPrint
action value
public static PdfName DidPrint
Field Value
DidSave
action value
public static PdfName DidSave
Field Value
DirectionL2R
A viewer preference
public const int DirectionL2R = 4194304
Field Value
DirectionR2L
A viewer preference
public const int DirectionR2L = 8388608
Field Value
DisplayDocTitle
A viewer preference
public const int DisplayDocTitle = 131072
Field Value
DocumentClose
action value
public static PdfName DocumentClose
Field Value
DocumentColors
The colors of this document
protected INullValueDictionary<PdfSpotColor, ColorDetails> DocumentColors
Field Value
DocumentExtGState
protected INullValueDictionary<PdfDictionary, PdfObject[]> DocumentExtGState
Field Value
DocumentFonts
The fonts of this document
protected INullValueDictionary<BaseFont, FontDetails> DocumentFonts
Field Value
DocumentOcGorder
[F13] Optional Content Groups
protected List<IPdfOcg> DocumentOcGorder
Field Value
DocumentOcg
protected INullValueDictionary<IPdfOcg, object> DocumentOcg
Field Value
DocumentPatterns
The patterns of this document
protected INullValueDictionary<PdfPatternPainter, PdfName> DocumentPatterns
Field Value
DocumentProperties
protected INullValueDictionary<object, PdfObject[]> DocumentProperties
Field Value
DocumentShadingPatterns
protected INullValueDictionary<PdfShadingPattern, object> DocumentShadingPatterns
Field Value
DocumentShadings
protected INullValueDictionary<PdfShading, object> DocumentShadings
Field Value
DocumentSpotPatterns
protected INullValueDictionary<ColorDetails, ColorDetails> DocumentSpotPatterns
Field Value
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
ENCRYPTION_AES_128
Type of encryption
public const int ENCRYPTION_AES_128 = 2
Field Value
ENCRYPTION_AES_256_V3
Type of encryption
public const int ENCRYPTION_AES_256_V3 = 4
Field Value
FitWindow
A viewer preference
public const int FitWindow = 32768
Field Value
FontNumber
[F3] adding fonts
protected int FontNumber
Field Value
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
FormXObjectsCounter
[F4] adding (and releasing) form XObjects
protected int FormXObjectsCounter
Field Value
GENERATION_MAX
The highest generation number possible. @since iText 2.1.6
public const int GENERATION_MAX = 65535
Field Value
HideMenubar
INNER CLASSES
public const int HideMenubar = 8192
Field Value
HideToolbar
A viewer preference
public const int HideToolbar = 4096
Field Value
HideWindowUI
values for setting viewer preferences in iText versions older than 2.x
public const int HideWindowUI = 16384
Field Value
ImageDictionary
Dictionary, containing all the images of the PDF document
protected PdfDictionary ImageDictionary
Field Value
ImportedPages
protected INullValueDictionary<PdfReader, PdfReaderInstance> ImportedPages
Field Value
Jbig2Globals
A Hashtable with Stream objects containing JBIG2 Globals @since 2.1.5
protected INullValueDictionary<PdfStream, PdfIndirectReference> Jbig2Globals
Field Value
NO_SPACE_CHAR_RATIO
Disable the inter-character spacing.
public const float NO_SPACE_CHAR_RATIO = 10000000
Field Value
NewBookmarks
protected IList<INullValueDictionary<string, object>> NewBookmarks
Field Value
NonFullScreenPageModeUseNone
A viewer preference
public const int NonFullScreenPageModeUseNone = 262144
Field Value
NonFullScreenPageModeUseOC
A viewer preference
public const int NonFullScreenPageModeUseOC = 2097152
Field Value
NonFullScreenPageModeUseOutlines
A viewer preference
public const int NonFullScreenPageModeUseOutlines = 524288
Field Value
NonFullScreenPageModeUseThumbs
A viewer preference
public const int NonFullScreenPageModeUseThumbs = 1048576
Field Value
OcgLocked
protected PdfArray OcgLocked
Field Value
OcgRadioGroup
protected PdfArray OcgRadioGroup
Field Value
PDFA1A
PDFA-1A level.
public const int PDFA1A = 3
Field Value
PDFA1B
PDFA-1B level.
public const int PDFA1B = 4
Field Value
PDFX1A2001
PDF/X level
public const int PDFX1A2001 = 1
Field Value
PDFX32002
PDF/X level
public const int PDFX32002 = 2
Field Value
PDFXNONE
PDF/X level
public const int PDFXNONE = 0
Field Value
PageClose
action value
public static readonly PdfName PageClose
Field Value
PageLayoutOneColumn
A viewer preference
public const int PageLayoutOneColumn = 2
Field Value
PageLayoutSinglePage
A viewer preference
public const int PageLayoutSinglePage = 1
Field Value
PageLayoutTwoColumnLeft
page layout (section 13.1.1 of "iText in Action")
public const int PageLayoutTwoColumnLeft = 4
Field Value
PageLayoutTwoColumnRight
[C3] PdfViewerPreferences interface
public const int PageLayoutTwoColumnRight = 8
Field Value
PageLayoutTwoPageLeft
A viewer preference
public const int PageLayoutTwoPageLeft = 16
Field Value
PageLayoutTwoPageRight
A viewer preference
public const int PageLayoutTwoPageRight = 32
Field Value
PageModeFullScreen
A viewer preference
public const int PageModeFullScreen = 512
Field Value
PageModeUseAttachments
A viewer preference
public const int PageModeUseAttachments = 2048
Field Value
PageModeUseNone
A viewer preference
public const int PageModeUseNone = 64
Field Value
PageModeUseOC
A viewer preference
public const int PageModeUseOC = 1024
Field Value
PageModeUseOutlines
page mode (section 13.1.2 of "iText in Action")
public const int PageModeUseOutlines = 128
Field Value
PageModeUseThumbs
A viewer preference
public const int PageModeUseThumbs = 256
Field Value
PageOpen
action value
public static readonly PdfName PageOpen
Field Value
PageReferences
The PdfIndirectReference to the pages.
protected List<PdfIndirectReference> PageReferences
Field Value
PatternColorspaceCmyk
protected ColorDetails PatternColorspaceCmyk
Field Value
PatternColorspaceGray
protected ColorDetails PatternColorspaceGray
Field Value
PatternColorspaceRgb
[M2] spot patterns
protected ColorDetails PatternColorspaceRgb
Field Value
PatternNumber
[F7] document patterns
protected int PatternNumber
Field Value
the PdfDocument instance
protected PdfDocument Pdf
Field Value
PdfVersion12
possible PDF version (catalog)
public static readonly PdfName PdfVersion12
Field Value
PdfVersion13
possible PDF version (catalog)
public static readonly PdfName PdfVersion13
Field Value
PdfVersion14
possible PDF version (catalog)
public static readonly PdfName PdfVersion14
Field Value
PdfVersion15
possible PDF version (catalog)
public static readonly PdfName PdfVersion15
Field Value
PdfVersion16
possible PDF version (catalog)
public static readonly PdfName PdfVersion16
Field Value
PdfVersion17
possible PDF version (catalog)
public static readonly PdfName PdfVersion17
Field Value
Prevxref
A number refering to the previous Cross-Reference Table.
protected int Prevxref
Field Value
PrintScalingNone
A viewer preference
public const int PrintScalingNone = 16777216
Field Value
RUN_DIRECTION_DEFAULT
Use the default run direction.
public const int RUN_DIRECTION_DEFAULT = 0
Field Value
RUN_DIRECTION_LTR
Use bidirectional reordering with left-to-right preferential run direction.
public const int RUN_DIRECTION_LTR = 2
Field Value
RUN_DIRECTION_NO_BIDI
[U7] run direction (doesn't actually do anything)
public const int RUN_DIRECTION_NO_BIDI = 1
Field Value
RUN_DIRECTION_RTL
Use bidirectional reordering with right-to-left preferential run direction.
public const int RUN_DIRECTION_RTL = 3
Field Value
Root
The root of the page tree.
protected PdfPages Root
Field Value
SIGNATURE_APPEND_ONLY
signature value
public const int SIGNATURE_APPEND_ONLY = 2
Field Value
SIGNATURE_EXISTS
signature value
public const int SIGNATURE_EXISTS = 1
Field Value
SPACE_CHAR_RATIO_DEFAULT
The default space-char ratio.
public const float SPACE_CHAR_RATIO_DEFAULT = 2.5
Field Value
STANDARD_ENCRYPTION_128
Type of encryption
public const int STANDARD_ENCRYPTION_128 = 1
Field Value
STANDARD_ENCRYPTION_40
Type of encryption
public const int STANDARD_ENCRYPTION_40 = 0
Field Value
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
STRENGTH40BITS
Strength of the encryption (kept for historical reasons)
public const bool STRENGTH40BITS = false
Field Value
Tagged
protected bool Tagged
Field Value
VERSION_1_2
[C2] PdfVersion interface
public const char VERSION_1_2 = '2'
Field Value
VERSION_1_3
possible PDF version (header)
public const char VERSION_1_3 = '3'
Field Value
VERSION_1_4
possible PDF version (header)
public const char VERSION_1_4 = '4'
Field Value
VERSION_1_5
possible PDF version (header)
public const char VERSION_1_5 = '5'
Field Value
VERSION_1_6
possible PDF version (header)
public const char VERSION_1_6 = '6'
Field Value
VERSION_1_7
possible PDF version (header)
public const char VERSION_1_7 = '7'
Field Value
VOcProperties
protected PdfOcProperties VOcProperties
Field Value
WillPrint
action value
public static PdfName WillPrint
Field Value
WillSave
[C6] Actions (open and additional)
public static PdfName WillSave
Field Value
compressionLevel
The compression level of the content streams. @since 2.1.3
protected int compressionLevel
Field Value
currentPageNumber
The current page number.
protected int currentPageNumber
Field Value
defaultColorspace
protected PdfDictionary defaultColorspace
Field Value
directContent
The direct content in this document.
protected PdfContentByte directContent
Field Value
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
extraCatalog
Holds value of property extraCatalog.
protected PdfDictionary extraCatalog
Field Value
fullCompression
Holds value of property fullCompression.
protected bool fullCompression
Field Value
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
pdf_version
Stores the version information for the header and the catalog.
protected PdfVersionImp pdf_version
Field Value
runDirection
protected int runDirection
Field Value
structureTreeRoot
protected PdfStructureTreeRoot structureTreeRoot
Field Value
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
userunit
protected float userunit
Field Value
xmpMetadata
XMP Metadata for the document.
protected byte[] xmpMetadata
Field Value
- byte[]
Properties
AcroForm
public PdfAcroForm AcroForm { get; }
Property Value
Collection
[C7] portable collections
public PdfCollection Collection { set; }
Property Value
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
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
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
CurrentPageNumber
public virtual int CurrentPageNumber { get; }
Property Value
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
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
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
PageDictionary
Adds additional entries to the page dictionary.
public PdfDictionary PageDictionary { get; set; }
Property Value
PageEmpty
If you use SetPageEmpty(false), invoking NewPage() after a blank page will add a newPage.
public bool PageEmpty { set; }
Property Value
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
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
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
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
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
SigFlags
Set the signature flags.
public virtual int SigFlags { set; }
Property Value
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
StrictImageSequence
Sets the image sequence to follow the text in strict order.
public bool StrictImageSequence { get; set; }
Property Value
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
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
Transition
Sets the transition for the page
public virtual PdfTransition Transition { set; }
Property Value
UserProperties
Sets the flag indicating the presence of structure elements that contain user properties attributes.
public bool UserProperties { get; set; }
Property Value
Userunit
[U4] Thumbnail image
public float Userunit { get; set; }
Property Value
ViewerPreferences
Sets the viewer preferences as the sum of several constants. @see PdfViewerPreferences#setViewerPreferences
public virtual int ViewerPreferences { set; }
Property Value
XmpMetadata
[C9] Metadata
public byte[] XmpMetadata { get; set; }
Property Value
- byte[]
Methods
Add(PdfIccBased)
protected virtual PdfIndirectReference Add(PdfIccBased icc)
Parameters
icc
PdfIccBased
Returns
AddAnnotation(PdfAnnotation)
[C8] AcroForm
public virtual void AddAnnotation(PdfAnnotation annot)
Parameters
annot
PdfAnnotationthe PdfAnnotation or the PdfFormField to add
AddCalculationOrder(PdfFormField)
Adds the PdfAnnotation to the calculation order array.
public virtual void AddCalculationOrder(PdfFormField annot)
Parameters
annot
PdfFormFieldthe 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
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
Imagethe 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
Imagethe Image to add
fixedRef
PdfIndirectReferencethe 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
stringthe file description
fileStore
byte[]an array with the file. If it's null
file
stringthe path to the file. It will only be used if
fileDisplay
stringthe 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
stringthe file description
fs
PdfFileSpecificationthe file specification
AddFileAttachment(PdfFileSpecification)
Adds a file attachment at the document level.
public void AddFileAttachment(PdfFileSpecification fs)
Parameters
fs
PdfFileSpecificationthe 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
stringthe JavaScript code
AddJavaScript(string, bool)
[C4] Page labels
public virtual void AddJavaScript(string code, bool unicode)
Parameters
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
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
stringThe name of the JS Action in the name tree
code
stringthe JavaScript code
unicode
boolselect 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
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
PdfActionThe 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
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
Returns
- PdfIndirectObject
a PdfIndirectObject
AddToBody(PdfObject, int)
Adds an object to the PDF body. @throws IOException
public PdfIndirectObject AddToBody(PdfObject objecta, int refNumber)
Parameters
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
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
PdfObjectrefa
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
PdfObjectrefa
PdfIndirectReferenceinObjStm
bool
Returns
- PdfIndirectObject
a PdfIndirectObject
AddViewerPreference(PdfName, PdfObject)
Adds a viewer preference @see PdfViewerPreferences#addViewerPreference
public virtual void AddViewerPreference(PdfName key, PdfObject value)
Parameters
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
Tablethe 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
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
PdfReaderthe 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
stringcrop, trim, art or bleed
Returns
GetCatalog(PdfIndirectReference)
protected virtual PdfDictionary GetCatalog(PdfIndirectReference rootObj)
Parameters
rootObj
PdfIndirectReference
Returns
GetImportedPage(PdfReader, int)
[F5] adding pages imported form other PDF documents
public virtual PdfImportedPage GetImportedPage(PdfReader reader, int pageNumber)
Parameters
reader
PdfReaderthe PDF document where the page is
pageNumber
intthe 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
Returns
GetInstance(Document, Stream, IDocListener)
public static PdfWriter GetInstance(Document document, Stream os, IDocListener listener)
Parameters
document
Documentos
Streamlistener
IDocListener
Returns
GetNewObjectNumber(PdfReader, int, int)
protected virtual int GetNewObjectNumber(PdfReader reader, int number, int generation)
Parameters
Returns
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
intthe 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
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
boolTells 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
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
PdfLayerthe 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
PdfTemplatethe 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
PdfNamethe action type
action
PdfActionthe 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
SetDefaultColorspace(PdfName, PdfObject)
Miscellaneous topics
public void SetDefaultColorspace(PdfName key, PdfObject cs)
Parameters
key
PdfNamethe name of the colorspace. It can be PdfName.DEFAULTGRAY , PdfName.DEFAULTRGB
cs
PdfObjectthe 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
intthe 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
booltrue for 128 bit key length, false for 40 bit key length
userPassword
stringthe user password. Can be null or empty
ownerPassword
stringthe owner password. Can be null or empty
permissions
intthe 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
intthe user permissions
strength128Bits
booltrue 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
intthe user permissions
encryptionType
intthe 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
intthe type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128.
userPassword
stringthe user password. Can be null or empty
ownerPassword
stringthe owner password. Can be null or empty
permissions
intthe 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
stringthe 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
PdfActionthe 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
stringa value
outputCondition
stringa value, "PDFA/A" to force GTS_PDFA1, otherwise cued by pdfxConformance.
registryName
stringa value
info
stringa 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
stringoutputCondition
stringregistryName
stringinfo
stringcolorProfile
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
PdfReaderthe other document
checkExistence
booltrue 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
PdfNamethe action type. It can be PdfWriter.PAGE_OPEN
action
PdfActionthe 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
PdfDictionarynamedAsNames
bool