com.lowagie.text.pdf

Class PdfWriter

public class PdfWriter extends DocWriter implements PdfViewerPreferences, PdfEncryptionSettings, PdfVersion, PdfDocumentActions, PdfPageActions, PdfXConformance, PdfRunDirection, PdfAnnotations

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.

Nested Class Summary
static classPdfWriter.PdfBody
This class generates the structure of a PDF document.
static classPdfWriter.PdfTrailer
PdfTrailer is the PDF Trailer object.
Field Summary
static intAllowAssembly
The operation permitted when the document is opened with the user password
static intAllowCopy
The operation permitted when the document is opened with the user password
static intAllowDegradedPrinting
The operation permitted when the document is opened with the user password
static intAllowFillIn
The operation permitted when the document is opened with the user password
static intAllowModifyAnnotations
The operation permitted when the document is opened with the user password
static intAllowModifyContents
The operation permitted when the document is opened with the user password
static intAllowPrinting
The operation permitted when the document is opened with the user password
static intAllowScreenReaders
The operation permitted when the document is opened with the user password
protected PdfWriter.PdfBodybody
body of the PDF document
protected intcolorNumber
The color number counter for the colors in the document.
protected PdfEncryptioncrypto
Contains the business logic for cryptography.
protected intcurrentPageNumber
The current page number.
protected PdfReaderInstancecurrentPdfReaderInstance
static intCenterWindow
A viewer preference
protected PdfDictionarydefaultColorspace
protected PdfContentBytedirectContent
The direct content in this document.
protected PdfContentBytedirectContentUnder
The direct content under in this document.
protected HashMapdocumentColors
The colors of this document
protected HashMapdocumentExtGState
protected HashMapdocumentFonts
The fonts of this document
protected HashSetdocumentOCG
protected ArrayListdocumentOCGorder
protected HashMapdocumentPatterns
The patterns of this document
protected HashMapdocumentProperties
protected HashMapdocumentShadingPatterns
protected HashMapdocumentShadings
protected HashMapdocumentSpotPatterns
static intDirectionL2R
A viewer preference
static intDirectionR2L
A viewer preference
static intDisplayDocTitle
A viewer preference
static PdfNameDID_PRINT
action value
static PdfNameDID_SAVE
action value
static PdfNameDOCUMENT_CLOSE
action value
static intDO_NOT_ENCRYPT_METADATA
Add this to the mode to keep the metadata in clear text
protected PdfDictionaryextraCatalog
Holds value of property extraCatalog this is used for Output Intents.
static intENCRYPTION_AES_128
Type of encryption
static intENCRYPTION_MASK
Mask to separate the encryption type from the encryption mode.
static intENCRYPTION_RC4_128
Type of encryption
static intENCRYPTION_RC4_40
Type of encryption
protected intfontNumber
The font number counter for the fonts in the document.
protected HashMapformXObjects
The form XObjects in this document.
protected intformXObjectsCounter
The name counter for the form XObjects name.
protected booleanfullCompression
Holds value of property fullCompression.
static intFitWindow
A viewer preference
protected PdfDictionarygroup
A group attributes dictionary specifying the attributes of the pages page group for use in the transparent imaging model
static intHideMenubar
A viewer preference
static intHideToolbar
A viewer preference
static intHideWindowUI
A viewer preference
protected PdfDictionaryimageDictionary
Dictionary, containing all the images of the PDF document
HashMapimages
This is the list with all the images in the document.
protected HashMapimportedPages
static intNonFullScreenPageModeUseNone
A viewer preference
static intNonFullScreenPageModeUseOC
A viewer preference
static intNonFullScreenPageModeUseOutlines
A viewer preference
static intNonFullScreenPageModeUseThumbs
A viewer preference
static floatNO_SPACE_CHAR_RATIO
Disable the inter-character spacing.
protected PdfArrayOCGRadioGroup
protected PdfOCPropertiesOCProperties
PdfPageEventpageEvent
The PdfPageEvent for this document.
protected ArrayListpageReferences
The PdfIndirectReference to the pages.
protected ColorDetailspatternColorspaceCMYK
protected ColorDetailspatternColorspaceGRAY
protected ColorDetailspatternColorspaceRGB
protected intpatternNumber
The patten number counter for the colors in the document.
protected PdfDocumentpdf
the pdfdocument object.
PdfXConformanceImppdfxConformance
Stores the PDF/X level.
protected PdfVersionImppdf_version
Stores the version information for the header and the catalog.
protected intprevxref
A number refering to the previous Cross-Reference Table.
static PdfNamePAGE_CLOSE
action value
static PdfNamePAGE_OPEN
action value
static intPageLayoutOneColumn
A viewer preference
static intPageLayoutSinglePage
A viewer preference
static intPageLayoutTwoColumnLeft
A viewer preference
static intPageLayoutTwoColumnRight
A viewer preference
static intPageLayoutTwoPageLeft
A viewer preference
static intPageLayoutTwoPageRight
A viewer preference
static intPageModeFullScreen
A viewer preference
static intPageModeUseAttachments
A viewer preference
static intPageModeUseNone
A viewer preference
static intPageModeUseOC
A viewer preference
static intPageModeUseOutlines
A viewer preference
static intPageModeUseThumbs
A viewer preference
static intPDFX1A2001
A PDF/X level.
static intPDFX32002
A PDF/X level.
static intPDFXNONE
A PDF/X level.
static PdfNamePDF_VERSION_1_2
possible PDF version (catalog)
static PdfNamePDF_VERSION_1_3
possible PDF version (catalog)
static PdfNamePDF_VERSION_1_4
possible PDF version (catalog)
static PdfNamePDF_VERSION_1_5
possible PDF version (catalog)
static PdfNamePDF_VERSION_1_6
possible PDF version (catalog)
static PdfNamePDF_VERSION_1_7
possible PDF version (catalog)
static intPrintScalingNone
A viewer preference
protected PdfPagesroot
The root of the page tree.
protected intrunDirection
static intRUN_DIRECTION_DEFAULT
Use the default run direction.
static intRUN_DIRECTION_LTR
Use bidirectional reordering with left-to-right preferential run direction.
static intRUN_DIRECTION_NO_BIDI
Do not use bidirectional reordering.
static intRUN_DIRECTION_RTL
Use bidirectional reordering with right-to-left preferential run direction.
floatspaceCharRatio
The ratio between the extra word spacing and the extra character spacing.
protected PdfStructureTreeRootstructureTreeRoot
static intSIGNATURE_APPEND_ONLY
signature value
static intSIGNATURE_EXISTS
signature value
static floatSPACE_CHAR_RATIO_DEFAULT
The default space-char ratio.
static booleanSTRENGTH128BITS
Type of RC4 encryption strength
static booleanSTRENGTH40BITS
Type of RC4 encryption strength
protected booleantagged
protected floatuserunit
static charVERSION_1_2
possible PDF version (header)
static charVERSION_1_3
possible PDF version (header)
static charVERSION_1_4
possible PDF version (header)
static charVERSION_1_5
possible PDF version (header)
static charVERSION_1_6
possible PDF version (header)
static charVERSION_1_7
possible PDF version (header)
static PdfNameWILL_PRINT
action value
static PdfNameWILL_SAVE
action value
protected byte[]xmpMetadata
XMP Metadata for the document.
Constructor Summary
protected PdfWriter()
Constructs a PdfWriter.
protected PdfWriter(PdfDocument document, OutputStream os)
Constructs a PdfWriter.
Method Summary
PdfIndirectReferenceadd(PdfPage page, PdfContents contents)
Adds some PdfContents to this Writer.
PdfIndirectReferenceadd(PdfImage pdfImage, PdfIndirectReference fixedRef)
Writes a PdfImage to the outputstream.
protected PdfIndirectReferenceadd(PdfICCBased icc)
voidaddAnnotation(PdfAnnotation annot)
voidaddAnnotation(PdfAnnotation annot, int page)
voidaddASEvent(PdfName event, PdfName category)
voidaddCalculationOrder(PdfFormField annot)
PdfNameaddDirectImageSimple(Image image)
Use this method to adds an image to the document but not to the page resources.
PdfNameaddDirectImageSimple(Image image, PdfIndirectReference fixedRef)
Adds an image to the document but not to the page resources.
PdfNameaddDirectTemplateSimple(PdfTemplate template, PdfName forcedName)
Adds a template to the document but not to the page resources.
voidaddFileAttachment(String description, byte[] fileStore, String file, String fileDisplay)
Use this method to add a file attachment at the document level.
voidaddFileAttachment(String description, PdfFileSpecification fs)
Use this method to add a file attachment at the document level.
voidaddFileAttachment(PdfFileSpecification fs)
Use this method to add a file attachment at the document level.
voidaddJavaScript(PdfAction js)
Use this method to add a JavaScript action at the document level.
voidaddJavaScript(String code, boolean unicode)
Use this method to add a JavaScript action at the document level.
voidaddJavaScript(String code)
Use this method to adds a JavaScript action at the document level.
voidaddLocalDestinations(TreeMap dest)
Adds the local destinations to the body of the document.
voidaddOCGRadioGroup(ArrayList group)
Use this method to set a collection of optional content groups whose states are intended to follow a "radio button" paradigm.
protected voidaddSharedObjectsToBody()
FontDetailsaddSimple(BaseFont bf)
Adds a BaseFont to the document but not to the page resources.
ColorDetailsaddSimple(PdfSpotColor spc)
Adds a SpotColor to the document but not to the page resources.
PdfObject[]addSimpleExtGState(PdfDictionary gstate)
PdfNameaddSimplePattern(PdfPatternPainter painter)
ColorDetailsaddSimplePatternColorspace(Color color)
PdfObject[]addSimpleProperty(Object prop, PdfIndirectReference refi)
voidaddSimpleShading(PdfShading shading)
voidaddSimpleShadingPattern(PdfShadingPattern shading)
PdfIndirectObjectaddToBody(PdfObject object)
Use this method to add a PDF object to the PDF body.
PdfIndirectObjectaddToBody(PdfObject object, boolean inObjStm)
Use this method to add a PDF object to the PDF body.
PdfIndirectObjectaddToBody(PdfObject object, PdfIndirectReference ref)
Use this method to add a PDF object to the PDF body.
PdfIndirectObjectaddToBody(PdfObject object, PdfIndirectReference ref, boolean inObjStm)
Use this method to add a PDF object to the PDF body.
PdfIndirectObjectaddToBody(PdfObject object, int refNumber)
Use this method to add a PDF object to the PDF body.
PdfIndirectObjectaddToBody(PdfObject object, int refNumber, boolean inObjStm)
Use this method to add a PDF object to the PDF body.
voidaddViewerPreference(PdfName key, PdfObject value)
booleanbreakTableIfDoesntFit(PdfTable table)
Row additions to the original Table used to build the PdfTable are processed and pre-rendered, and then the contents are deleted.
voidclearTextWrap()
Use this method to clear text wrapping around images (if applicable).
voidclose()
Signals that the Document was closed and that no other Elements will be added.
voidcreateXmpMetadata()
Use this method to creates XMP Metadata based on the metadata in the PdfDocument.
byte[]createXmpMetadataBytes()
voideliminateFontSubset(PdfDictionary fonts)
voidfillOCProperties(boolean erase)
booleanfitsPage(Table table, float margin)
Checks if a Table fits the current page of the PdfDocument.
booleanfitsPage(Table table)
Checks if a Table fits the current page of the PdfDocument.
booleanfitsPage(PdfPTable table, float margin)
Checks if a PdfPTable fits the current page of the PdfDocument.
booleanfitsPage(PdfPTable table)
Checks if a PdfPTable fits the current page of the PdfDocument.
voidfreeReader(PdfReader reader)
Use this method to writes the reader to the document and free the memory used by it.
PdfAcroFormgetAcroForm()
RectanglegetBoxSize(String boxName)
Use this method to get the size of a trim, art, crop or bleed box, or null if not defined.
protected PdfDictionarygetCatalog(PdfIndirectReference rootObj)
PdfNamegetColorspaceName()
intgetCurrentDocumentSize()
Use this method to gets the current document size.
PdfIndirectReferencegetCurrentPage()
intgetCurrentPageNumber()
PdfDictionarygetDefaultColorspace()
Use this method to get the default colorspaces.
PdfContentBytegetDirectContent()
Use this method to get the direct content for this document.
PdfContentBytegetDirectContentUnder()
Use this method to get the direct content under for this document.
PdfEncryptiongetEncryption()
PdfDictionarygetExtraCatalog()
Sets extra keys to the catalog.
PdfDictionarygetGroup()
Use this method to get the group dictionary.
PdfIndirectReferencegetImageReference(PdfName name)
return the PdfIndirectReference to the image with a given name.
PdfImportedPagegetImportedPage(PdfReader reader, int pageNumber)
Use this method to get a page from other PDF document.
intgetIndirectReferenceNumber()
PdfDictionarygetInfo()
Use this method to get the info dictionary if you want to change it directly (add keys and values to the info dictionary).
static PdfWritergetInstance(Document document, OutputStream os)
Use this method to get an instance of the PdfWriter.
static PdfWritergetInstance(Document document, OutputStream os, DocListener listener)
Use this method to get an instance of the PdfWriter.
static StringgetNameString(PdfDictionary dic, PdfName key)
protected intgetNewObjectNumber(PdfReader reader, int number, int generation)
static voidgetOCGOrder(PdfArray order, PdfLayer layer)
PdfOCPropertiesgetOCProperties()
Use this method to get the Optional Content Properties Dictionary.
OutputStreamCountergetOs()
Returns the outputStreamCounter.
PdfPageEventgetPageEvent()
Gets the PdfPageEvent for this document or null if none is set.
intgetPageNumber()
Gets the pagenumber of this document.
PdfIndirectReferencegetPageReference(int page)
Use this method to get a reference to a page existing or not.
RectanglegetPageSize()
Use this method to get the size of the media box.
PdfDocumentgetPdfDocument()
Gets the PdfDocument associated with this writer.
PdfIndirectReferencegetPdfIndirectReference()
Use this to get an PdfIndirectReference for an object that will be created in the future.
PdfTablegetPdfTable(Table table)
Gets a pre-rendered table.
PdfVersionImpgetPdfVersion()
Returns the version information.
intgetPDFXConformance()
RandomAccessFileOrArraygetReaderFile(PdfReader reader)
PdfOutlinegetRootOutline()
Use this method to get the root outline and construct bookmarks.
intgetRunDirection()
Use this method to set the run direction.
floatgetSpaceCharRatio()
Use this method to gets the space/character extra spacing ratio for fully justified text.
PdfStructureTreeRootgetStructureTreeRoot()
Gets the structure tree root.
floatgetTableBottom(Table table)
Sometimes it is necessary to know where the just added Table ends.
floatgetUserunit()
Use this method to get the user unit.
floatgetVerticalPosition(boolean ensureNewLine)
Use this method to get the current vertical page position.
booleanisFullCompression()
Use this method to find out if 1.5 compression is on.
booleanisPdfX()
booleanisStrictImageSequence()
Use this method to get the strictImageSequence status.
booleanisTagged()
Check if the document is marked for tagging.
voidopen()
Signals that the Document has been opened and that Elements can be added.
booleanpropertyExists(Object prop)
voidregisterLayer(PdfOCG layer)
voidreleaseTemplate(PdfTemplate tp)
Use this method to releases the memory used by a template.
intreorderPages(int[] order)
Use this method to reorder the pages in the document.
voidresetContent()
Resets all the direct contents to empty.
voidsetAdditionalAction(PdfName actionType, PdfAction action)
voidsetAtLeastPdfVersion(char version)
voidsetBoxSize(String boxName, Rectangle size)
Use this method to set the page box sizes.
voidsetCollection(PdfCollection collection)
Use this method to add the Collection dictionary.
voidsetCropBoxSize(Rectangle crop)
Use this method to set the crop box.
voidsetDefaultColorspace(PdfName key, PdfObject cs)
Use this method to sets the default colorspace that will be applied to all the document.
voidsetDuration(int seconds)
voidsetEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionType)
voidsetEncryption(Certificate[] certs, int[] permissions, int encryptionType)
voidsetEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, boolean strength128Bits)
Sets the encryption options for this document.
voidsetEncryption(boolean strength, String userPassword, String ownerPassword, int permissions)
Sets the encryption options for this document.
voidsetEncryption(int encryptionType, String userPassword, String ownerPassword, int permissions)
Sets the encryption options for this document.
voidsetFullCompression()
Use this method to set the document's compression to the PDF 1.5 mode with object streams and xref streams.
voidsetGroup(PdfDictionary group)
Use this method to set the group dictionary.
voidsetLinearPageMode()
Use this method to make sure the page tree has a lineair structure (every leave is attached directly to the root).
voidsetOpenAction(String name)
voidsetOpenAction(PdfAction action)
voidsetOutputIntents(String outputConditionIdentifier, String outputCondition, String registryName, String info, byte[] destOutputProfile)
Use this method to set the values of the output intent dictionary.
booleansetOutputIntents(PdfReader reader, boolean checkExistence)
Use this method to copy the output intent dictionary from another document to this one.
voidsetPageAction(PdfName actionType, PdfAction action)
voidsetPageEmpty(boolean pageEmpty)
Use this method to make sure a page is added, even if it's empty.
voidsetPageEvent(PdfPageEvent event)
Sets the PdfPageEvent for this document.
voidsetPageLabels(PdfPageLabels pageLabels)
Use this method to add page labels
voidsetPdfVersion(char version)
voidsetPdfVersion(PdfName version)
voidsetPDFXConformance(int pdfx)
voidsetRunDirection(int runDirection)
Use this method to set the run direction.
voidsetSigFlags(int f)
voidsetSpaceCharRatio(float spaceCharRatio)
Use this method to set the ratio between the extra word spacing and the extra character spacing when the text is fully justified.
voidsetStrictImageSequence(boolean strictImageSequence)
Use this method to set the image sequence, so that it follows the text in strict order (or not).
voidsetTagged()
Mark this document for tagging.
voidsetThumbnail(Image image)
Use this method to set the thumbnail image for the current page.
voidsetTransition(PdfTransition transition)
voidsetUserunit(float userunit)
Use this method to set the user unit.
voidsetViewerPreferences(int preferences)
voidsetXmpMetadata(byte[] xmpMetadata)
Use this method to set the XMP Metadata.

Field Detail

AllowAssembly

public static final int AllowAssembly
The operation permitted when the document is opened with the user password

AllowCopy

public static final int AllowCopy
The operation permitted when the document is opened with the user password

AllowDegradedPrinting

public static final int AllowDegradedPrinting
The operation permitted when the document is opened with the user password

AllowFillIn

public static final int AllowFillIn
The operation permitted when the document is opened with the user password

AllowModifyAnnotations

public static final int AllowModifyAnnotations
The operation permitted when the document is opened with the user password

AllowModifyContents

public static final int AllowModifyContents
The operation permitted when the document is opened with the user password

AllowPrinting

public static final int AllowPrinting
The operation permitted when the document is opened with the user password

AllowScreenReaders

public static final int AllowScreenReaders
The operation permitted when the document is opened with the user password

body

protected PdfWriter.PdfBody body
body of the PDF document

colorNumber

protected int colorNumber
The color number counter for the colors in the document.

crypto

protected PdfEncryption crypto
Contains the business logic for cryptography.

currentPageNumber

protected int currentPageNumber
The current page number.

currentPdfReaderInstance

protected PdfReaderInstance currentPdfReaderInstance

CenterWindow

public static final int CenterWindow
A viewer preference

defaultColorspace

protected PdfDictionary defaultColorspace

directContent

protected PdfContentByte directContent
The direct content in this document.

directContentUnder

protected PdfContentByte directContentUnder
The direct content under in this document.

documentColors

protected HashMap documentColors
The colors of this document

documentExtGState

protected HashMap documentExtGState

documentFonts

protected HashMap documentFonts
The fonts of this document

documentOCG

protected HashSet documentOCG

documentOCGorder

protected ArrayList documentOCGorder

documentPatterns

protected HashMap documentPatterns
The patterns of this document

documentProperties

protected HashMap documentProperties

documentShadingPatterns

protected HashMap documentShadingPatterns

documentShadings

protected HashMap documentShadings

documentSpotPatterns

protected HashMap documentSpotPatterns

DirectionL2R

public static final int DirectionL2R
A viewer preference

DirectionR2L

public static final int DirectionR2L
A viewer preference

DisplayDocTitle

public static final int DisplayDocTitle
A viewer preference

DID_PRINT

public static final PdfName DID_PRINT
action value

DID_SAVE

public static final PdfName DID_SAVE
action value

DOCUMENT_CLOSE

public static final PdfName DOCUMENT_CLOSE
action value

DO_NOT_ENCRYPT_METADATA

public static final int DO_NOT_ENCRYPT_METADATA
Add this to the mode to keep the metadata in clear text

extraCatalog

protected PdfDictionary extraCatalog
Holds value of property extraCatalog this is used for Output Intents.

ENCRYPTION_AES_128

public static final int ENCRYPTION_AES_128
Type of encryption

ENCRYPTION_MASK

static final int ENCRYPTION_MASK
Mask to separate the encryption type from the encryption mode.

ENCRYPTION_RC4_128

public static final int ENCRYPTION_RC4_128
Type of encryption

ENCRYPTION_RC4_40

public static final int ENCRYPTION_RC4_40
Type of encryption

fontNumber

protected int fontNumber
The font number counter for the fonts in the document.

formXObjects

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

formXObjectsCounter

protected int formXObjectsCounter
The name counter for the form XObjects name.

fullCompression

protected boolean fullCompression
Holds value of property fullCompression.

FitWindow

public static final int FitWindow
A viewer preference

group

protected PdfDictionary group
A group attributes dictionary specifying the attributes of the pages page group for use in the transparent imaging model

HideMenubar

public static final int HideMenubar
A viewer preference

HideToolbar

public static final int HideToolbar
A viewer preference

HideWindowUI

public static final int HideWindowUI
A viewer preference

imageDictionary

protected PdfDictionary imageDictionary
Dictionary, containing all the images of the PDF document

images

private HashMap images
This is the list with all the images in the document.

importedPages

protected HashMap importedPages

NonFullScreenPageModeUseNone

public static final int NonFullScreenPageModeUseNone
A viewer preference

NonFullScreenPageModeUseOC

public static final int NonFullScreenPageModeUseOC
A viewer preference

NonFullScreenPageModeUseOutlines

public static final int NonFullScreenPageModeUseOutlines
A viewer preference

NonFullScreenPageModeUseThumbs

public static final int NonFullScreenPageModeUseThumbs
A viewer preference

NO_SPACE_CHAR_RATIO

public static final float NO_SPACE_CHAR_RATIO
Disable the inter-character spacing.

OCGRadioGroup

protected PdfArray OCGRadioGroup

OCProperties

protected PdfOCProperties OCProperties

pageEvent

private PdfPageEvent pageEvent
The PdfPageEvent for this document.

pageReferences

protected ArrayList pageReferences
The PdfIndirectReference to the pages.

patternColorspaceCMYK

protected ColorDetails patternColorspaceCMYK

patternColorspaceGRAY

protected ColorDetails patternColorspaceGRAY

patternColorspaceRGB

protected ColorDetails patternColorspaceRGB

patternNumber

protected int patternNumber
The patten number counter for the colors in the document.

pdf

protected PdfDocument pdf
the pdfdocument object.

pdfxConformance

private PdfXConformanceImp pdfxConformance
Stores the PDF/X level.

pdf_version

protected PdfVersionImp pdf_version
Stores the version information for the header and the catalog.

prevxref

protected int prevxref
A number refering to the previous Cross-Reference Table.

PAGE_CLOSE

public static final PdfName PAGE_CLOSE
action value

PAGE_OPEN

public static final PdfName PAGE_OPEN
action value

PageLayoutOneColumn

public static final int PageLayoutOneColumn
A viewer preference

PageLayoutSinglePage

public static final int PageLayoutSinglePage
A viewer preference

PageLayoutTwoColumnLeft

public static final int PageLayoutTwoColumnLeft
A viewer preference

PageLayoutTwoColumnRight

public static final int PageLayoutTwoColumnRight
A viewer preference

PageLayoutTwoPageLeft

public static final int PageLayoutTwoPageLeft
A viewer preference

PageLayoutTwoPageRight

public static final int PageLayoutTwoPageRight
A viewer preference

PageModeFullScreen

public static final int PageModeFullScreen
A viewer preference

PageModeUseAttachments

public static final int PageModeUseAttachments
A viewer preference

PageModeUseNone

public static final int PageModeUseNone
A viewer preference

PageModeUseOC

public static final int PageModeUseOC
A viewer preference

PageModeUseOutlines

public static final int PageModeUseOutlines
A viewer preference

PageModeUseThumbs

public static final int PageModeUseThumbs
A viewer preference

PDFX1A2001

public static final int PDFX1A2001
A PDF/X level.

PDFX32002

public static final int PDFX32002
A PDF/X level.

PDFXNONE

public static final int PDFXNONE
A PDF/X level.

PDF_VERSION_1_2

public static final PdfName PDF_VERSION_1_2
possible PDF version (catalog)

PDF_VERSION_1_3

public static final PdfName PDF_VERSION_1_3
possible PDF version (catalog)

PDF_VERSION_1_4

public static final PdfName PDF_VERSION_1_4
possible PDF version (catalog)

PDF_VERSION_1_5

public static final PdfName PDF_VERSION_1_5
possible PDF version (catalog)

PDF_VERSION_1_6

public static final PdfName PDF_VERSION_1_6
possible PDF version (catalog)

PDF_VERSION_1_7

public static final PdfName PDF_VERSION_1_7
possible PDF version (catalog)

PrintScalingNone

public static final int PrintScalingNone
A viewer preference

root

protected PdfPages root
The root of the page tree.

runDirection

protected int runDirection

RUN_DIRECTION_DEFAULT

public static final int RUN_DIRECTION_DEFAULT
Use the default run direction.

RUN_DIRECTION_LTR

public static final int RUN_DIRECTION_LTR
Use bidirectional reordering with left-to-right preferential run direction.

RUN_DIRECTION_NO_BIDI

public static final int RUN_DIRECTION_NO_BIDI
Do not use bidirectional reordering.

RUN_DIRECTION_RTL

public static final int RUN_DIRECTION_RTL
Use bidirectional reordering with right-to-left preferential run direction.

spaceCharRatio

private float spaceCharRatio
The ratio between the extra word spacing and the extra character spacing. Extra word spacing will grow ratio times more than extra character spacing.

structureTreeRoot

protected PdfStructureTreeRoot structureTreeRoot

SIGNATURE_APPEND_ONLY

public static final int SIGNATURE_APPEND_ONLY
signature value

SIGNATURE_EXISTS

public static final int SIGNATURE_EXISTS
signature value

SPACE_CHAR_RATIO_DEFAULT

public static final float SPACE_CHAR_RATIO_DEFAULT
The default space-char ratio.

STRENGTH128BITS

public static final boolean STRENGTH128BITS
Type of RC4 encryption strength

STRENGTH40BITS

public static final boolean STRENGTH40BITS
Type of RC4 encryption strength

tagged

protected boolean tagged

userunit

protected float userunit

VERSION_1_2

public static final char VERSION_1_2
possible PDF version (header)

VERSION_1_3

public static final char VERSION_1_3
possible PDF version (header)

VERSION_1_4

public static final char VERSION_1_4
possible PDF version (header)

VERSION_1_5

public static final char VERSION_1_5
possible PDF version (header)

VERSION_1_6

public static final char VERSION_1_6
possible PDF version (header)

VERSION_1_7

public static final char VERSION_1_7
possible PDF version (header)

WILL_PRINT

public static final PdfName WILL_PRINT
action value

WILL_SAVE

public static final PdfName WILL_SAVE
action value

xmpMetadata

protected byte[] xmpMetadata
XMP Metadata for the document.

Constructor Detail

PdfWriter

protected PdfWriter()
Constructs a PdfWriter.

PdfWriter

protected PdfWriter(PdfDocument document, OutputStream os)
Constructs a PdfWriter.

Remark: a PdfWriter can only be constructed by calling the method getInstance(Document document, OutputStream os).

Parameters: document The PdfDocument that has to be written os The OutputStream the writer has to write to.

Method Detail

add

PdfIndirectReference add(PdfPage page, PdfContents contents)
Adds some PdfContents to this Writer.

The document has to be open before you can begin to add content to the body of the document.

Parameters: page the PdfPage to add contents the PdfContents of the page

Returns: a PdfIndirectReference

Throws: PdfException on error

add

PdfIndirectReference add(PdfImage pdfImage, PdfIndirectReference fixedRef)
Writes a PdfImage to the outputstream.

Parameters: pdfImage the image to be added

Returns: a PdfIndirectReference to the encapsulated image

Throws: PdfException when a document isn't open yet, or has been closed

add

protected PdfIndirectReference add(PdfICCBased icc)

addAnnotation

public void addAnnotation(PdfAnnotation annot)

See Also: addAnnotation

addAnnotation

void addAnnotation(PdfAnnotation annot, int page)

addASEvent

private void addASEvent(PdfName event, PdfName category)

addCalculationOrder

public void addCalculationOrder(PdfFormField annot)

See Also: addCalculationOrder

addDirectImageSimple

public PdfName addDirectImageSimple(Image image)
Use this method to adds an image to the document but not to the page resources. It is used with templates and Document.add(Image). Use this method only if you know what you're doing!

Parameters: image the Image to add

Returns: the name of the image added

Throws: PdfException on error DocumentException on error

addDirectImageSimple

public PdfName addDirectImageSimple(Image image, PdfIndirectReference fixedRef)
Adds an image to the document but not to the page resources. It is used with templates and Document.add(Image). Use this method only if you know what you're doing!

Parameters: image the Image to add fixedRef the reference to used. It may be null, a PdfIndirectReference or a PRIndirectReference.

Returns: the name of the image added

Throws: PdfException on error DocumentException on error

addDirectTemplateSimple

PdfName addDirectTemplateSimple(PdfTemplate template, PdfName forcedName)
Adds a template to the document but not to the page resources.

Parameters: template the template to add forcedName the template name, rather than a generated one. Can be null

Returns: the PdfName for this template

addFileAttachment

public void addFileAttachment(String description, byte[] fileStore, String file, String fileDisplay)
Use this method to add a file attachment at the document level.

Parameters: description the file description fileStore an array with the file. If it's null the file will be read from the disk file the path to the file. It will only be used if fileStore is not null fileDisplay the actual file name stored in the pdf

Throws: IOException on error

addFileAttachment

public void addFileAttachment(String description, PdfFileSpecification fs)
Use this method to add a file attachment at the document level.

Parameters: description the file description fs the file specification

addFileAttachment

public void addFileAttachment(PdfFileSpecification fs)
Use this method to add a file attachment at the document level.

Parameters: fs the file specification

addJavaScript

public void addJavaScript(PdfAction js)
Use this method to add a JavaScript action at the document level. When the document opens, all this JavaScript runs.

Parameters: js The JavaScrip action

addJavaScript

public void addJavaScript(String code, boolean unicode)
Use this method to add a JavaScript action at the document level. When the document opens, all this JavaScript runs.

Parameters: code the JavaScript code unicode select JavaScript unicode. Note that the internal Acrobat JavaScript engine does not support unicode, so this may or may not work for you

addJavaScript

public void addJavaScript(String code)
Use this method to adds a JavaScript action at the document level. When the document opens, all this JavaScript runs.

Parameters: code the JavaScript code

addLocalDestinations

void addLocalDestinations(TreeMap dest)
Adds the local destinations to the body of the document.

Parameters: dest the HashMap containing the destinations

Throws: IOException on error

addOCGRadioGroup

public void addOCGRadioGroup(ArrayList group)
Use this method to set 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.

Parameters: group the radio group

addSharedObjectsToBody

protected void addSharedObjectsToBody()

addSimple

FontDetails addSimple(BaseFont bf)
Adds a BaseFont to the document but not to the page resources. It is used for templates.

Parameters: bf the BaseFont to add

Returns: an Object[] where position 0 is a PdfName and position 1 is an PdfIndirectReference

addSimple

ColorDetails addSimple(PdfSpotColor spc)
Adds a SpotColor to the document but not to the page resources.

Parameters: spc the SpotColor to add

Returns: an Object[] where position 0 is a PdfName and position 1 is an PdfIndirectReference

addSimpleExtGState

PdfObject[] addSimpleExtGState(PdfDictionary gstate)

addSimplePattern

PdfName addSimplePattern(PdfPatternPainter painter)

addSimplePatternColorspace

ColorDetails addSimplePatternColorspace(Color color)

addSimpleProperty

PdfObject[] addSimpleProperty(Object prop, PdfIndirectReference refi)

addSimpleShading

void addSimpleShading(PdfShading shading)

addSimpleShadingPattern

void addSimpleShadingPattern(PdfShadingPattern shading)

addToBody

public PdfIndirectObject addToBody(PdfObject object)
Use this method to add a PDF object to the PDF body. Use this method only if you know what you're doing!

Parameters: object

Returns: a PdfIndirectObject

Throws: IOException

addToBody

public PdfIndirectObject addToBody(PdfObject object, boolean inObjStm)
Use this method to add a PDF object to the PDF body. Use this method only if you know what you're doing!

Parameters: object inObjStm

Returns: a PdfIndirectObject

Throws: IOException

addToBody

public PdfIndirectObject addToBody(PdfObject object, PdfIndirectReference ref)
Use this method to add a PDF object to the PDF body. Use this method only if you know what you're doing!

Parameters: object ref

Returns: a PdfIndirectObject

Throws: IOException

addToBody

public PdfIndirectObject addToBody(PdfObject object, PdfIndirectReference ref, boolean inObjStm)
Use this method to add a PDF object to the PDF body. Use this method only if you know what you're doing!

Parameters: object ref inObjStm

Returns: a PdfIndirectObject

Throws: IOException

addToBody

public PdfIndirectObject addToBody(PdfObject object, int refNumber)
Use this method to add a PDF object to the PDF body. Use this method only if you know what you're doing!

Parameters: object refNumber

Returns: a PdfIndirectObject

Throws: IOException

addToBody

public PdfIndirectObject addToBody(PdfObject object, int refNumber, boolean inObjStm)
Use this method to add a PDF object to the PDF body. Use this method only if you know what you're doing!

Parameters: object refNumber inObjStm

Returns: a PdfIndirectObject

Throws: IOException

addViewerPreference

public void addViewerPreference(PdfName key, PdfObject value)

See Also: PdfViewerPreferences

breakTableIfDoesntFit

public boolean breakTableIfDoesntFit(PdfTable table)

Deprecated: this method will probably disappear in one of the next releases

Row additions to the original Table used to build the PdfTable are processed and pre-rendered, and then the contents are deleted. If the pre-rendered table doesn't fit, then it is fully rendered and its data discarded. There shouldn't be any column change in the underlying Table object. (Contributed by dperezcar@fcc.es)

Parameters: table The pre-rendered table obtained from getPdfTable

Returns: true if the table is rendered and emptied.

Throws: DocumentException

See Also: getPdfTable

clearTextWrap

public void clearTextWrap()
Use this method to clear text wrapping around images (if applicable).

Throws: DocumentException

close

public void 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.

See Also: close

createXmpMetadata

public void createXmpMetadata()
Use this method to creates XMP Metadata based on the metadata in the PdfDocument.

createXmpMetadataBytes

private byte[] createXmpMetadataBytes()

Returns: an XmpMetadata byte array

eliminateFontSubset

void eliminateFontSubset(PdfDictionary fonts)

fillOCProperties

private void fillOCProperties(boolean erase)

fitsPage

public boolean fitsPage(Table table, float margin)

Deprecated: this method will probably disappear in one of the next releases

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

Parameters: table the table that has to be checked margin a certain margin

Returns: true if the Table fits the page, false otherwise.

fitsPage

public boolean fitsPage(Table table)

Deprecated: this method will probably disappear in one of the next releases

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

Parameters: table the table that has to be checked

Returns: true if the Table fits the page, false otherwise.

fitsPage

public boolean fitsPage(PdfPTable table, float margin)

Deprecated: this method will probably disappear in one of the next releases

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

Parameters: table the table that has to be checked margin a certain margin

Returns: true if the PdfPTable fits the page, false otherwise.

fitsPage

public boolean fitsPage(PdfPTable table)

Deprecated: this method will probably disappear in one of the next releases

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

Parameters: table the table that has to be checked

Returns: true if the PdfPTable fits the page, false otherwise.

freeReader

public void freeReader(PdfReader reader)
Use this method to writes the reader to the document and free the memory used by it. The main use is when concatenating multiple documents to keep the memory usage restricted to the current appending document.

Parameters: reader the PdfReader to free

Throws: IOException on error

getAcroForm

public PdfAcroForm getAcroForm()

See Also: getAcroForm

getBoxSize

public Rectangle getBoxSize(String boxName)
Use this method to get the size of a trim, art, crop or bleed box, or null if not defined.

Parameters: boxName crop, trim, art or bleed

getCatalog

protected PdfDictionary getCatalog(PdfIndirectReference rootObj)

getColorspaceName

PdfName getColorspaceName()

getCurrentDocumentSize

public int getCurrentDocumentSize()
Use this method to 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.

Returns: the approximate size without fonts or templates

getCurrentPage

PdfIndirectReference getCurrentPage()

getCurrentPageNumber

public int getCurrentPageNumber()

getDefaultColorspace

public PdfDictionary getDefaultColorspace()
Use this method to get the default colorspaces.

Returns: the default colorspaces

getDirectContent

public PdfContentByte getDirectContent()
Use this method to get the direct content for this document. There is only one direct content, multiple calls to this method will allways retrieve the same object.

Returns: the direct content

getDirectContentUnder

public PdfContentByte getDirectContentUnder()
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.

Returns: the direct content

getEncryption

PdfEncryption getEncryption()

getExtraCatalog

public PdfDictionary getExtraCatalog()
Sets extra keys to the catalog.

Returns: the catalog to change

getGroup

public PdfDictionary getGroup()
Use this method to get the group dictionary.

Returns: Value of property group.

getImageReference

PdfIndirectReference getImageReference(PdfName name)
return the PdfIndirectReference to the image with a given name.

Parameters: name the name of the image

Returns: a PdfIndirectReference

getImportedPage

public PdfImportedPage getImportedPage(PdfReader reader, int pageNumber)
Use this method to get a page from other PDF document. The page can be used as any other PdfTemplate. Note that calling this method more than once with the same parameters will retrieve the same object.

Parameters: reader the PDF document where the page is pageNumber the page number. The first page is 1

Returns: the template representing the imported page

getIndirectReferenceNumber

int getIndirectReferenceNumber()

getInfo

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

Returns: the info dictionary

getInstance

public static PdfWriter getInstance(Document document, OutputStream os)
Use this method to get an instance of the PdfWriter.

Parameters: document The Document that has to be written os The OutputStream the writer has to write to.

Returns: a new PdfWriter

Throws: DocumentException on error

getInstance

public static PdfWriter getInstance(Document document, OutputStream os, DocListener listener)
Use this method to get an instance of the PdfWriter.

Parameters: document The Document that has to be written os The OutputStream the writer has to write to. listener A DocListener to pass to the PdfDocument.

Returns: a new PdfWriter

Throws: DocumentException on error

getNameString

private static String getNameString(PdfDictionary dic, PdfName key)

getNewObjectNumber

protected int getNewObjectNumber(PdfReader reader, int number, int generation)

getOCGOrder

private static void getOCGOrder(PdfArray order, PdfLayer layer)

getOCProperties

public PdfOCProperties getOCProperties()
Use this method to get 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.

Returns: the Optional Content Properties Dictionary

getOs

OutputStreamCounter getOs()
Returns the outputStreamCounter.

Returns: the outputStreamCounter

getPageEvent

public PdfPageEvent getPageEvent()
Gets the PdfPageEvent for this document or null if none is set.

Returns: the PdfPageEvent for this document or null if none is set

getPageNumber

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

Returns: a page number

getPageReference

public PdfIndirectReference getPageReference(int page)
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.

Parameters: page the page number. The first page is 1

Returns: the reference to the page

getPageSize

public Rectangle getPageSize()
Use this method to get the size of the media box.

Returns: a Rectangle

getPdfDocument

PdfDocument getPdfDocument()
Gets the PdfDocument associated with this writer.

Returns: the PdfDocument

getPdfIndirectReference

public PdfIndirectReference getPdfIndirectReference()
Use this to get an PdfIndirectReference for an object that will be created in the future. Use this method only if you know what you're doing!

Returns: the PdfIndirectReference

getPdfTable

public PdfTable getPdfTable(Table table)

Deprecated: this method will probably disappear in one of the next releases

Gets a pre-rendered table. (Contributed by dperezcar@fcc.es)

Parameters: table Contains the table definition. Its contents are deleted, after being pre-rendered.

Returns: a PdfTable

getPdfVersion

PdfVersionImp getPdfVersion()
Returns the version information.

getPDFXConformance

public int getPDFXConformance()

See Also: getPDFXConformance

getReaderFile

RandomAccessFileOrArray getReaderFile(PdfReader reader)

getRootOutline

public PdfOutline getRootOutline()
Use this method to get the root outline and construct bookmarks.

Returns: the root outline

getRunDirection

public int getRunDirection()
Use this method to set the run direction.

Returns: the run direction

getSpaceCharRatio

public float getSpaceCharRatio()
Use this method to gets the space/character extra spacing ratio for fully justified text.

Returns: the space/character extra spacing ratio

getStructureTreeRoot

public PdfStructureTreeRoot getStructureTreeRoot()
Gets the structure tree root. If the document is not marked for tagging it will return null.

Returns: the structure tree root

getTableBottom

public float getTableBottom(Table table)

Deprecated: this method will probably disappear in one of the next releases

Sometimes it is necessary to know where the just added Table ends. For instance to avoid to add another table in a page that is ending up, because the new table will be probably splitted just after the header (it is an unpleasant effect, isn't it?). Added on September 8th, 2001 by Francesco De Milato francesco.demilato@tiscalinet.it

Parameters: table the Table

Returns: the bottom height of the just added table

getUserunit

public float getUserunit()
Use this method to get the user unit. A user unit is a value that defines the default user space unit. The minimum UserUnit is 1 (1 unit = 1/72 inch). The maximum UserUnit is 75,000. Note that this userunit only works starting with PDF1.6!

Returns: Returns the userunit.

getVerticalPosition

public float getVerticalPosition(boolean ensureNewLine)
Use this method to get the current vertical page position.

Parameters: ensureNewLine Tells whether a new line shall be enforced. This may cause side effects for elements that do not terminate the lines they've started because those lines will get terminated.

Returns: The current vertical page position.

isFullCompression

public boolean isFullCompression()
Use this method to find out if 1.5 compression is on.

Returns: the 1.5 compression status

isPdfX

public boolean isPdfX()

See Also: isPdfX

isStrictImageSequence

public boolean isStrictImageSequence()
Use this method to get the strictImageSequence status.

Returns: value of property strictImageSequence

isTagged

public boolean isTagged()
Check if the document is marked for tagging.

Returns: true if the document is marked for tagging

open

public void open()
Signals that the Document has been opened and that Elements can be added.

When this method is called, the PDF-document header is written to the outputstream.

See Also: open

propertyExists

boolean propertyExists(Object prop)

registerLayer

void registerLayer(PdfOCG layer)

releaseTemplate

public void releaseTemplate(PdfTemplate tp)
Use this method to releases the memory used by a template. This method writes the template to the output. The template can still be added to any content but changes to the template itself won't have any effect.

Parameters: tp the template to release

Throws: IOException on error

reorderPages

public int reorderPages(int[] order)
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.

Parameters: order an array with the new page sequence. It must have the same size as the number of pages.

Returns: the total number of pages

Throws: DocumentException if all the pages are not present in the array

resetContent

void resetContent()
Resets all the direct contents to empty. This happens when a new page is started.

setAdditionalAction

public void setAdditionalAction(PdfName actionType, PdfAction action)

See Also: PdfDocumentActions

setAtLeastPdfVersion

public void setAtLeastPdfVersion(char version)

See Also: PdfVersion

setBoxSize

public void setBoxSize(String boxName, Rectangle size)
Use this method to set the page box sizes. Allowed names are: "crop", "trim", "art" and "bleed".

Parameters: boxName the box size size the size

setCollection

public void setCollection(PdfCollection collection)
Use this method to add the Collection dictionary.

Parameters: collection a dictionary of type PdfCollection

setCropBoxSize

public void setCropBoxSize(Rectangle crop)
Use this method to set 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.

Parameters: crop the crop box

setDefaultColorspace

public void setDefaultColorspace(PdfName key, PdfObject cs)
Use this method to sets the default colorspace that will be applied to all the document. The colorspace is only applied if another colorspace with the same name is not present in the content.

The colorspace is applied immediately when creating templates and at the page end for the main document content.

Parameters: key the name of the colorspace. It can be PdfName.DEFAULTGRAY, PdfName.DEFAULTRGB or PdfName.DEFAULTCMYK cs the colorspace. A null or PdfNull removes any colorspace with the same name

setDuration

public void setDuration(int seconds)

See Also: PdfPageActions

setEncryption

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

See Also: (byte[], byte[], int, int)

setEncryption

public void setEncryption(Certificate[] certs, int[] permissions, int encryptionType)

See Also: (java.security.cert.Certificate[], int[], int)

setEncryption

public void setEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, boolean strength128Bits)

Deprecated: use the methods described in the PdfEncryptionSettings interface

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.

Parameters: userPassword the user password. Can be null or empty ownerPassword the owner password. Can be null or empty permissions the user permissions strength128Bits true for 128 bit key length, false for 40 bit key length

Throws: DocumentException if the document is already open

setEncryption

public void setEncryption(boolean strength, String userPassword, String ownerPassword, int permissions)

Deprecated: use the methods described in the PdfEncryptionSettings interface

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.

Parameters: strength true for 128 bit key length, false for 40 bit key length userPassword the user password. Can be null or empty ownerPassword the owner password. Can be null or empty permissions the user permissions

Throws: DocumentException if the document is already open

setEncryption

public void setEncryption(int encryptionType, String userPassword, String ownerPassword, int permissions)

Deprecated: use the methods described in the PdfEncryptionSettings interface

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.

Parameters: encryptionType the type of encryption. It can be one of ENCRYPTION_RC4_40, ENCRYPTION_RC4_128 or ENCRYPTION_AES128. Optionally DO_NOT_ENCRYPT_METADATA can be ored to output the metadata in cleartext userPassword the user password. Can be null or empty ownerPassword the owner password. Can be null or empty permissions the user permissions

Throws: DocumentException if the document is already open

setFullCompression

public void setFullCompression()
Use this method to set the document's compression to the PDF 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.

setGroup

public void setGroup(PdfDictionary group)
Use this method to set the group dictionary.

Parameters: group New value of property group.

setLinearPageMode

public void setLinearPageMode()
Use this method to make sure the page tree has a lineair structure (every leave is attached directly to the root). Use this method to allow page reordering with method reorderPages.

setOpenAction

public void setOpenAction(String name)

See Also: PdfDocumentActions

setOpenAction

public void setOpenAction(PdfAction action)

See Also: setOpenAction

setOutputIntents

public void setOutputIntents(String outputConditionIdentifier, String outputCondition, String registryName, String info, byte[] destOutputProfile)
Use this method to set the values of the output intent dictionary. Null values are allowed to suppress any key.

Parameters: outputConditionIdentifier a value outputCondition a value registryName a value info a value destOutputProfile a value

Throws: IOException on error

setOutputIntents

public boolean setOutputIntents(PdfReader reader, boolean checkExistence)
Use this method to copy the output intent dictionary from another document to this one.

Parameters: reader the other document checkExistence true to just check for the existence of a valid output intent dictionary, false to insert the dictionary if it exists

Returns: true if the output intent dictionary exists, false otherwise

Throws: IOException on error

setPageAction

public void setPageAction(PdfName actionType, PdfAction action)

See Also: PdfPageActions

setPageEmpty

public void setPageEmpty(boolean pageEmpty)
Use this method to make sure a page is added, even if it's empty. If you use setPageEmpty(false), invoking newPage() after a blank page will add a newPage.

Parameters: pageEmpty the state

setPageEvent

public void setPageEvent(PdfPageEvent event)
Sets the PdfPageEvent for this document.

Parameters: event the PdfPageEvent for this document

setPageLabels

public void setPageLabels(PdfPageLabels pageLabels)
Use this method to add page labels

Parameters: pageLabels the page labels

setPdfVersion

public void setPdfVersion(char version)

See Also: PdfVersion

setPdfVersion

public void setPdfVersion(PdfName version)

See Also: setPdfVersion

setPDFXConformance

public void setPDFXConformance(int pdfx)

See Also: PdfXConformance

setRunDirection

public void setRunDirection(int runDirection)
Use this method to set the run direction. This is only used as a placeholder as it does not affect anything.

Parameters: runDirection the run direction

setSigFlags

public void setSigFlags(int f)

See Also: PdfAnnotations

setSpaceCharRatio

public void setSpaceCharRatio(float spaceCharRatio)
Use this method to set 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.

Parameters: spaceCharRatio the ratio between the extra word spacing and the extra character spacing

setStrictImageSequence

public void setStrictImageSequence(boolean strictImageSequence)
Use this method to set the image sequence, so that it follows the text in strict order (or not).

Parameters: strictImageSequence new value of property strictImageSequence

setTagged

public void setTagged()
Mark this document for tagging. It must be called before open.

setThumbnail

public void setThumbnail(Image image)
Use this method to set the thumbnail image for the current page.

Parameters: image the image

Throws: PdfException on error DocumentException or error

setTransition

public void setTransition(PdfTransition transition)

See Also: setTransition

setUserunit

public void setUserunit(float userunit)
Use this method to set the user unit. A UserUnit is a value that defines the default user space unit. The minimum UserUnit is 1 (1 unit = 1/72 inch). The maximum UserUnit is 75,000. Note that this userunit only works starting with PDF1.6!

Parameters: userunit The userunit to set.

Throws: DocumentException on error

setViewerPreferences

public void setViewerPreferences(int preferences)

See Also: PdfViewerPreferences

setXmpMetadata

public void setXmpMetadata(byte[] xmpMetadata)
Use this method to set the XMP Metadata.

Parameters: xmpMetadata The xmpMetadata to set.