## com.lowagie.text.pdf
Class PdfWriter

    java.lang.Object
      com.lowagie.text.DocWriter
          com.lowagie.text.pdf.PdfWriter

All Implemented Interfaces:
  DocListener, ElementListener, java.util.EventListener

Direct Known Subclasses:
  FdfWriter.Wrt, PdfCopy, PdfCopyFieldsImp, PdfStamperImp

    public class PdfWriter

extends DocWriter

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 class` `PdfWriter.PdfBody` This class generates the structure of a PDF document.
`(package private) static class` `PdfWriter.PdfTrailer` `PdfTrailer` is the PDF Trailer object.

Field Summary
`static int` `AllowAssembly` The operation permitted when the document is opened with the user password
`static int` `AllowCopy` The operation permitted when the document is opened with the user password
`static int` `AllowDegradedPrinting` The operation permitted when the document is opened with the user password
`static int` `AllowFillIn` The operation permitted when the document is opened with the user password
`static int` `AllowModifyAnnotations` The operation permitted when the document is opened with the user password
`static int` `AllowModifyContents` The operation permitted when the document is opened with the user password
`static int` `AllowPrinting` The operation permitted when the document is opened with the user password
`static int` `AllowScreenReaders` The operation permitted when the document is opened with the user password
`protected PdfWriter.PdfBody` `body` body of the PDF document
`static int` `CenterWindow` A viewer preference
`protected int` `colorNumber` The color number counter for the colors in the document.
`protected PdfEncryption` `crypto`
`protected int` `currentPageNumber`
`protected PdfReaderInstance` `currentPdfReaderInstance`
`protected PdfDictionary` `defaultColorspace`
`static PdfName` `DID_PRINT` action value
`static PdfName` `DID_SAVE` action value
`protected PdfContentByte` `directContent` The direct content in this document.
`protected PdfContentByte` `directContentUnder` The direct content under in this document.
`static int` `DirectionL2R` A viewer preference
`static int` `DirectionR2L` A viewer preference
`static int` `DisplayDocTitle` A viewer preference
`static PdfName` `DOCUMENT_CLOSE` action value
`protected java.util.HashMap` `documentColors` The colors of this document
`protected java.util.HashMap` `documentExtGState`
`protected java.util.HashMap` `documentFonts` The fonts of this document
`protected java.util.HashSet` `documentOCG`
`protected java.util.ArrayList` `documentOCGorder`
`protected java.util.HashMap` `documentPatterns` The patterns of this document
`protected java.util.HashMap` `documentProperties`
`protected java.util.HashMap` `documentShadingPatterns`
`protected java.util.HashMap` `documentShadings`
`protected java.util.HashMap` `documentSpotPatterns`
`private PdfDictionary` `extraCatalog` Holds value of property extraCatalog.
`static int` `FitWindow` A viewer preference
`protected int` `fontNumber` The font number counter for the fonts in the document.
`protected java.util.HashMap` `formXObjects` The form XObjects in this document.
`protected int` `formXObjectsCounter` The name counter for the form XObjects name.
`protected boolean` `fullCompression` Holds value of property fullCompression.
`protected PdfDictionary` `group`
`protected byte[]` `HEADER` this is the header of a PDF document
`static int` `HideMenubar` A viewer preference
`static int` `HideToolbar` A viewer preference
`static int` `HideWindowUI` A viewer preference
`protected PdfDictionary` `imageDictionary` Dictionary, containing all the images of the PDF document
`private java.util.HashMap` `images` This is the list with all the images in the document.
`protected java.util.HashMap` `importedPages`
`static float` `NO_SPACE_CHAR_RATIO` Disable the inter-character spacing.
`static int` `NonFullScreenPageModeUseNone` A viewer preference
`static int` `NonFullScreenPageModeUseOC` A viewer preference
`static int` `NonFullScreenPageModeUseOutlines` A viewer preference
`static int` `NonFullScreenPageModeUseThumbs` A viewer preference
`protected PdfArray` `OCGRadioGroup`
`protected PdfOCProperties` `OCProperties`
`static PdfName` `PAGE_CLOSE` action value
`static PdfName` `PAGE_OPEN` action value
`private PdfPageEvent` `pageEvent` The `PdfPageEvent` for this document.
`static int` `PageLayoutOneColumn` A viewer preference
`static int` `PageLayoutSinglePage` A viewer preference
`static int` `PageLayoutTwoColumnLeft` A viewer preference
`static int` `PageLayoutTwoColumnRight` A viewer preference
`static int` `PageLayoutTwoPageLeft` A viewer preference
`static int` `PageLayoutTwoPageRight` A viewer preference
`static int` `PageModeFullScreen` A viewer preference
`static int` `PageModeUseAttachments` A viewer preference
`static int` `PageModeUseNone` A viewer preference
`static int` `PageModeUseOC` A viewer preference
`static int` `PageModeUseOutlines` A viewer preference
`static int` `PageModeUseThumbs` A viewer preference
`protected java.util.ArrayList` `pageReferences` The PdfIndirectReference to the pages.
`protected ColorDetails` `patternColorspaceCMYK`
`protected ColorDetails` `patternColorspaceGRAY`
`protected ColorDetails` `patternColorspaceRGB`
`protected int` `patternNumber` The patten number counter for the colors in the document.
`protected PdfDocument` `pdf` the pdfdocument object.
`static int` `PDFX1A2001` PDF/X value
`static int` `PDFX32002` PDF/X value
`private int` `pdfxConformance`
`(package private) static int` `PDFXKEY_CMYK`
`(package private) static int` `PDFXKEY_COLOR`
`(package private) static int` `PDFXKEY_FONT`
`(package private) static int` `PDFXKEY_GSTATE`
`(package private) static int` `PDFXKEY_IMAGE`
`(package private) static int` `PDFXKEY_LAYER`
`(package private) static int` `PDFXKEY_RGB`
`static int` `PDFXNONE` PDF/X value
`protected int` `prevxref`
`static int` `PrintScalingNone` A viewer preference
`protected PdfPages` `root`
`static int` `RUN_DIRECTION_DEFAULT` Use the default run direction.
`static int` `RUN_DIRECTION_LTR` Use bidirectional reordering with left-to-right preferential run direction.
`static int` `RUN_DIRECTION_NO_BIDI` Do not use bidirectional reordering.
`static int` `RUN_DIRECTION_RTL` Use bidirectional reordering with right-to-left preferential run direction.
`protected int` `runDirection`
`static int` `SIGNATURE_APPEND_ONLY` signature value
`static int` `SIGNATURE_EXISTS` signature value
`static float` `SPACE_CHAR_RATIO_DEFAULT` The default space-char ratio.
`private float` `spaceCharRatio` The ratio between the extra word spacing and the extra character spacing.
`static boolean` `STRENGTH128BITS` Type of encryption
`static boolean` `STRENGTH40BITS` Type of encryption
`protected PdfStructureTreeRoot` `structureTreeRoot`
`protected boolean` `tagged`
`protected float` `userunit`
`static char` `VERSION_1_2` possible PDF version
`static char` `VERSION_1_3` possible PDF version
`static char` `VERSION_1_4` possible PDF version
`static char` `VERSION_1_5` possible PDF version
`static char` `VERSION_1_6` possible PDF version
`(package private) static int` `ViewerPreferencesMask` The mask to decide if a ViewerPreferences dictionary is needed
`private static int` `VPOINT`
`static PdfName` `WILL_PRINT` action value
`static PdfName` `WILL_SAVE` action value
`protected byte[]` `xmpMetadata` XMP Metadata for the document.

Fields inherited from class com.lowagie.text.DocWriter
`closeStream, document, EQUALS, FORWARD, GT, LT, NEWLINE, open, os, pageSize, pause, QUOTE, SPACE, TAB`

Constructor Summary
`protected` `PdfWriter()`
`protected` `PdfWriter(PdfDocument document, java.io.OutputStream os)` Constructs a `PdfWriter`.

Method Summary
`protected PdfIndirectReference` `add(PdfICCBased icc)`
`(package private) PdfIndirectReference` `add(PdfImage pdfImage, PdfIndirectReference fixedRef)` Writes a `PdfImage` to the outputstream.
`(package private) PdfIndirectReference` `add(PdfPage page, PdfContents contents)` Adds some `PdfContents` to this Writer.
`void` `addAnnotation(PdfAnnotation annot)` Adds a `PdfAnnotation` or a `PdfFormField` to the document.
`(package private) void` `addAnnotation(PdfAnnotation annot, int page)`
`private void` `addASEvent(PdfName event, PdfName category)`
`void` `addCalculationOrder(PdfFormField annot)` Adds the `PdfAnnotation` to the calculation order array.
`PdfName` `addDirectImageSimple(Image image)` Adds an image to the document but not to the page resources.
`PdfName` `addDirectImageSimple(Image image, PdfIndirectReference fixedRef)` Adds an image to the document but not to the page resources.
`(package private) PdfName` `addDirectTemplateSimple(PdfTemplate template, PdfName forcedName)` Adds a template to the document but not to the page resources.
`void` `addFileAttachment(java.lang.String description, byte[] fileStore, java.lang.String file, java.lang.String fileDisplay)` Adds a file attachment at the document level.
`void` `addFileAttachment(java.lang.String description, PdfFileSpecification fs)` Adds a file attachment at the document level.
`void` `addJavaScript(PdfAction js)` Adds a JavaScript action at the document level.
`void` `addJavaScript(java.lang.String code)` Adds a JavaScript action at the document level.
`void` `addJavaScript(java.lang.String code, boolean unicode)` Adds a JavaScript action at the document level.
`(package private) void` `addLocalDestinations(java.util.TreeMap dest)` Adds the local destinations to the body of the document.
`void` `addOCGRadioGroup(java.util.ArrayList group)` Sets a collection of optional content groups whose states are intended to follow a "radio button" paradigm.
`protected void` `addSharedObjectsToBody()`
`(package private) FontDetails` `addSimple(BaseFont bf)` Adds a `BaseFont` to the document but not to the page resources.
`(package private) ColorDetails` `addSimple(PdfSpotColor spc)` Adds a `SpotColor` to the document but not to the page resources.
`(package private) PdfObject[]` `addSimpleExtGState(PdfDictionary gstate)`
`(package private) PdfName` `addSimplePattern(PdfPatternPainter painter)`
`(package private) ColorDetails` `addSimplePatternColorspace(java.awt.Color color)`
`(package private) PdfObject[]` `addSimpleProperty(java.lang.Object prop, PdfIndirectReference refi)`
`(package private) void` `addSimpleShading(PdfShading shading)`
`(package private) void` `addSimpleShadingPattern(PdfShadingPattern shading)`
`PdfIndirectObject` `addToBody(PdfObject object)` Adds an object to the PDF body.
`PdfIndirectObject` `addToBody(PdfObject object, boolean inObjStm)` Adds an object to the PDF body.
`PdfIndirectObject` `addToBody(PdfObject object, int refNumber)` Adds an object to the PDF body.
`PdfIndirectObject` `addToBody(PdfObject object, int refNumber, boolean inObjStm)` Adds an object to the PDF body.
`PdfIndirectObject` `addToBody(PdfObject object, PdfIndirectReference ref)` Adds an object to the PDF body.
`PdfIndirectObject` `addToBody(PdfObject object, PdfIndirectReference ref, boolean inObjStm)` Adds an object to the PDF body.
`boolean` `breakTableIfDoesntFit(PdfTable table)` Row additions to the original `Table` used to build the `PdfTable` are processed and pre-rendered, and then the contents are deleted.
`(package private) static void` `checkPDFXConformance(PdfWriter writer, int key, java.lang.Object obj1)`
`void` `close()` Signals that the `Document` was closed and that no other `Elements` will be added.
`void` `createXmpMetadata()` Creates XMP Metadata based on the metadata in the PdfDocument.
`(package private) void` `eliminateFontSubset(PdfDictionary fonts)`
`private void` `fillOCProperties(boolean erase)`
`boolean` `fitsPage(PdfPTable table)` Checks if a `PdfPTable` fits the current page of the `PdfDocument`.
`boolean` `fitsPage(PdfPTable table, float margin)` Checks if a `PdfPTable` fits the current page of the `PdfDocument`.
`boolean` `fitsPage(Table table)` Checks if a `Table` fits the current page of the `PdfDocument`.
`boolean` `fitsPage(Table table, float margin)` Checks if a `Table` fits the current page of the `PdfDocument`.
`void` `freeReader(PdfReader reader)` Writes the reader to the document and frees the memory used by it.
`PdfAcroForm` `getAcroForm()` Gets the AcroForm object.
`Rectangle` `getBoxSize(java.lang.String boxName)` Gives the size of a trim, art, crop or bleed box, or null if not defined.
`protected PdfDictionary` `getCatalog(PdfIndirectReference rootObj)`
`(package private) PdfName` `getColorspaceName()`
`int` `getCurrentDocumentSize()` Gets the current document size.
`(package private) PdfIndirectReference` `getCurrentPage()`
`(package private) int` `getCurrentPageNumber()`
`PdfDictionary` `getDefaultColorspace()` Gets the default colorspaces.
`PdfContentByte` `getDirectContent()` Gets the direct content for this document.
`PdfContentByte` `getDirectContentUnder()` Gets the direct content under for this document.
`(package private) PdfEncryption` `getEncryption()`
`PdfDictionary` `getExtraCatalog()` Sets extra keys to the catalog.
`PdfDictionary` `getGroup()` Getter for property group.
`(package private) PdfIndirectReference` `getImageReference(PdfName name)` return the `PdfIndirectReference` to the image with a given name.
`PdfImportedPage` `getImportedPage(PdfReader reader, int pageNumber)` Gets a page from other PDF document.
`(package private) int` `getIndirectReferenceNumber()`
`PdfDictionary` `getInfo()` Gets the info dictionary for changing.
`static PdfWriter` `getInstance(Document document, java.io.OutputStream os)` Gets an instance of the `PdfWriter`.
`static PdfWriter` `getInstance(Document document, java.io.OutputStream os, DocListener listener)` Gets an instance of the `PdfWriter`.
`private static java.lang.String` `getNameString(PdfDictionary dic, PdfName key)`
`protected int` `getNewObjectNumber(PdfReader reader, int number, int generation)`
`private static void` `getOCGOrder(PdfArray order, PdfLayer layer)`
`PdfOCProperties` `getOCProperties()` Gets the Optional Content Properties Dictionary.
`OutputStreamCounter` `getOs()` Returns the outputStreamCounter.
`PdfPageEvent` `getPageEvent()` Gets the `PdfPageEvent` for this document or `null` if none is set.
`int` `getPageNumber()` Gets the current pagenumber of this document.
`PdfIndirectReference` `getPageReference(int page)` Gets a reference to a page existing or not.
`Rectangle` `getPageSize()` Gives the size of the media box.
`(package private) PdfDocument` `getPdfDocument()` Gets the `PdfDocument` associated with this writer.
`PdfIndirectReference` `getPdfIndirectReference()` Gets a `PdfIndirectReference` for an object that will be created in the future.
`PdfTable` `getPdfTable(Table table)` Gets a pre-rendered table.
`int` `getPDFXConformance()` Gets the PDFX conformance level.
`(package private) RandomAccessFileOrArray` `getReaderFile(PdfReader reader)`
`PdfOutline` `getRootOutline()` Gets the root outline.
`int` `getRunDirection()` Gets the run direction.
`float` `getSpaceCharRatio()` Gets the space/character extra spacing ratio for fully justified text.
`PdfStructureTreeRoot` `getStructureTreeRoot()` Gets the structure tree root.
`float` `getTableBottom(Table table)` Sometimes it is necessary to know where the just added `Table` ends.
`float` `getUserunit()` A UserUnit is a value that defines the default user space unit.
`float` `getVerticalPosition(boolean ensureNewLine)` Gets the current vertical page position.
`boolean` `isFullCompression()` Gets the 1.5 compression status.
`(package private) boolean` `isPaused()` Checks if writing is paused.
`boolean` `isStrictImageSequence()` Getter for property strictImageSequence.
`boolean` `isTagged()` Check if the document is marked for tagging.
`void` `open()` Signals that the `Document` has been opened and that `Elements` can be added.
`(package private) boolean` `propertyExists(java.lang.Object prop)`
`(package private) void` `registerLayer(PdfOCG layer)`
`void` `releaseTemplate(PdfTemplate tp)` Releases the memory used by a template by writing it to the output.
`int` `reorderPages(int[] order)` Reorder the pages in the document.
`(package private) void` `resetContent()` Resets all the direct contents to empty.
`void` `setAdditionalAction(PdfName actionType, PdfAction action)` Additional-actions defining the actions to be taken in response to various trigger events affecting the document as a whole.
`void` `setBoxSize(java.lang.String boxName, Rectangle size)` Sets the page box sizes.
`void` `setCropBoxSize(Rectangle crop)` Sets the crop box.
`void` `setDefaultColorspace(PdfName key, PdfObject cs)` Sets the default colorspace that will be applied to all the document.
`void` `setDuration(int seconds)` Sets the display duration for the page (for presentations)
`void` `setEncryption(boolean strength, java.lang.String userPassword, java.lang.String ownerPassword, int permissions)` Sets the encryption options for this document.
`void` `setEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, boolean strength128Bits)` Sets the encryption options for this document.
`void` `setFullCompression()` Sets the document's compression to the new 1.5 mode with object streams and xref streams.
`void` `setGroup(PdfDictionary group)` Setter for property group.
`void` `setLinearPageMode()` Sets the document in a suitable way to do page reordering.
`void` `setOpenAction(PdfAction action)` When the document opens this `action` will be invoked.
`void` `setOpenAction(java.lang.String name)` When the document opens it will jump to the destination with this name.
`boolean` `setOutputIntents(PdfReader reader, boolean checkExistence)` Copies the output intent dictionary from other document to this one.
`void` `setOutputIntents(java.lang.String outputConditionIdentifier, java.lang.String outputCondition, java.lang.String registryName, java.lang.String info, byte[] destOutputProfile)` Sets the values of the output intent dictionary.
`void` `setPageAction(PdfName actionType, PdfAction action)` Sets the open and close page additional action.
`void` `setPageEmpty(boolean pageEmpty)` If you use setPageEmpty(false), invoking newPage() after a blank page will add a newPage.
`void` `setPageEvent(PdfPageEvent event)` Sets the `PdfPageEvent` for this document.
`void` `setPageLabels(PdfPageLabels pageLabels)` Sets the page labels
`void` `setPdfVersion(char version)` Sets the PDF version.
`void` `setPDFXConformance(int pdfxConformance)` Sets the PDFX conformance level.
`void` `setRunDirection(int runDirection)` Sets the run direction.
`void` `setSigFlags(int f)` Set the signature flags.
`void` `setSpaceCharRatio(float spaceCharRatio)` Sets the ratio between the extra word spacing and the extra character spacing when the text is fully justified.
`void` `setStrictImageSequence(boolean strictImageSequence)` Sets the image sequence to follow the text in strict order.
`void` `setTagged()` Mark this document for tagging.
`void` `setThumbnail(Image image)` Sets the the thumbnail image for the current page.
`void` `setTransition(PdfTransition transition)` Sets the transition for the page
`void` `setUserunit(float userunit)` A UserUnit is a value that defines the default user space unit.
`void` `setViewerPreferences(int preferences)` Sets the viewer preferences by ORing some constants.
`void` `setXmpMetadata(byte[] xmpMetadata)` Sets XMP Metadata.

Methods inherited from class com.lowagie.text.DocWriter
`add, add, addTabs, clearTextWrap, flush, getISOBytes, hasMarkupAttributes, isCloseStream, newPage, pause, removeWatermark, resetFooter, resetHeader, resetPageCount, resume, setCloseStream, setFooter, setHeader, setMarginMirroring, setMargins, setPageCount, setPageSize, write, write, writeEnd, writeEnd, writeMarkupAttributes, writeStart`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### PageLayoutSinglePage

    public static final int PageLayoutSinglePage

  A viewer preference

  See Also:
    Constant Field Values

### PageLayoutOneColumn

    public static final int PageLayoutOneColumn

  A viewer preference

  See Also:
    Constant Field Values

### PageLayoutTwoColumnLeft

    public static final int PageLayoutTwoColumnLeft

  A viewer preference

  See Also:
    Constant Field Values

### PageLayoutTwoColumnRight

    public static final int PageLayoutTwoColumnRight

  A viewer preference

  See Also:
    Constant Field Values

### PageLayoutTwoPageLeft

    public static final int PageLayoutTwoPageLeft

  A viewer preference

  See Also:
    Constant Field Values

### PageLayoutTwoPageRight

    public static final int PageLayoutTwoPageRight

  A viewer preference

  See Also:
    Constant Field Values

### PageModeUseNone

    public static final int PageModeUseNone

  A viewer preference

  See Also:
    Constant Field Values

### PageModeUseOutlines

    public static final int PageModeUseOutlines

  A viewer preference

  See Also:
    Constant Field Values

### PageModeUseThumbs

    public static final int PageModeUseThumbs

  A viewer preference

  See Also:
    Constant Field Values

### PageModeFullScreen

    public static final int PageModeFullScreen

  A viewer preference

  See Also:
    Constant Field Values

### PageModeUseOC

    public static final int PageModeUseOC

  A viewer preference

  See Also:
    Constant Field Values

### PageModeUseAttachments

    public static final int PageModeUseAttachments

  A viewer preference

  See Also:
    Constant Field Values

### HideToolbar

    public static final int HideToolbar

  A viewer preference

  See Also:
    Constant Field Values

### HideMenubar

    public static final int HideMenubar

  A viewer preference

  See Also:
    Constant Field Values

### HideWindowUI

    public static final int HideWindowUI

  A viewer preference

  See Also:
    Constant Field Values

### FitWindow

    public static final int FitWindow

  A viewer preference

  See Also:
    Constant Field Values

### CenterWindow

    public static final int CenterWindow

  A viewer preference

  See Also:
    Constant Field Values

### NonFullScreenPageModeUseNone

    public static final int NonFullScreenPageModeUseNone

  A viewer preference

  See Also:
    Constant Field Values

### NonFullScreenPageModeUseOutlines

    public static final int NonFullScreenPageModeUseOutlines

  A viewer preference

  See Also:
    Constant Field Values

### NonFullScreenPageModeUseThumbs

    public static final int NonFullScreenPageModeUseThumbs

  A viewer preference

  See Also:
    Constant Field Values

### NonFullScreenPageModeUseOC

    public static final int NonFullScreenPageModeUseOC

  A viewer preference

  See Also:
    Constant Field Values

### DirectionL2R

    public static final int DirectionL2R

  A viewer preference

  See Also:
    Constant Field Values

### DirectionR2L

    public static final int DirectionR2L

  A viewer preference

  See Also:
    Constant Field Values

### DisplayDocTitle

    public static final int DisplayDocTitle

  A viewer preference

  See Also:
    Constant Field Values

### PrintScalingNone

    public static final int PrintScalingNone

  A viewer preference

  See Also:
    Constant Field Values

### ViewerPreferencesMask

    static final int ViewerPreferencesMask

  The mask to decide if a ViewerPreferences dictionary is needed

  See Also:
    Constant Field Values

### AllowPrinting

    public static final int AllowPrinting

  The operation permitted when the document is opened with the user password

  See Also:
    Constant Field Values

### AllowModifyContents

    public static final int AllowModifyContents

  The operation permitted when the document is opened with the user password

  See Also:
    Constant Field Values

### AllowCopy

    public static final int AllowCopy

  The operation permitted when the document is opened with the user password

  See Also:
    Constant Field Values

### AllowModifyAnnotations

    public static final int AllowModifyAnnotations

  The operation permitted when the document is opened with the user password

  See Also:
    Constant Field Values

### AllowFillIn

    public static final int AllowFillIn

  The operation permitted when the document is opened with the user password

  See Also:
    Constant Field Values

### AllowScreenReaders

    public static final int AllowScreenReaders

  The operation permitted when the document is opened with the user password

  See Also:
    Constant Field Values

### AllowAssembly

    public static final int AllowAssembly

  The operation permitted when the document is opened with the user password

  See Also:
    Constant Field Values

### AllowDegradedPrinting

    public static final int AllowDegradedPrinting

  The operation permitted when the document is opened with the user password

  See Also:
    Constant Field Values

### STRENGTH40BITS

    public static final boolean STRENGTH40BITS

  Type of encryption

  See Also:
    Constant Field Values

### STRENGTH128BITS

    public static final boolean STRENGTH128BITS

  Type of encryption

  See Also:
    Constant Field Values

### DOCUMENT_CLOSE

    public static final PdfName DOCUMENT_CLOSE

  action value

### WILL_SAVE

    public static final PdfName WILL_SAVE

  action value

### DID_SAVE

    public static final PdfName DID_SAVE

  action value

### WILL_PRINT

    public static final PdfName WILL_PRINT

  action value

### DID_PRINT

    public static final PdfName DID_PRINT

  action value

### PAGE_OPEN

    public static final PdfName PAGE_OPEN

  action value

### PAGE_CLOSE

    public static final PdfName PAGE_CLOSE

  action value

### SIGNATURE_EXISTS

    public static final int SIGNATURE_EXISTS

  signature value

  See Also:
    Constant Field Values

### SIGNATURE_APPEND_ONLY

    public static final int SIGNATURE_APPEND_ONLY

  signature value

  See Also:
    Constant Field Values

### VERSION_1_2

    public static final char VERSION_1_2

  possible PDF version

  See Also:
    Constant Field Values

### VERSION_1_3

    public static final char VERSION_1_3

  possible PDF version

  See Also:
    Constant Field Values

### VERSION_1_4

    public static final char VERSION_1_4

  possible PDF version

  See Also:
    Constant Field Values

### VERSION_1_5

    public static final char VERSION_1_5

  possible PDF version

  See Also:
    Constant Field Values

### VERSION_1_6

    public static final char VERSION_1_6

  possible PDF version

  See Also:
    Constant Field Values

### VPOINT

    private static final int VPOINT

See Also:
  Constant Field Values

### HEADER

    protected byte[] HEADER

  this is the header of a PDF document

### prevxref

    protected int prevxref

### root

    protected PdfPages root

### imageDictionary

    protected PdfDictionary imageDictionary

  Dictionary, containing all the images of the PDF document

### images

    private java.util.HashMap images

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

### formXObjects

    protected java.util.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.

### fontNumber

    protected int fontNumber

  The font number counter for the fonts in the document.

### colorNumber

    protected int colorNumber

  The color number counter for the colors in the document.

### patternNumber

    protected int patternNumber

  The patten number counter for the colors in the document.

### directContent

    protected PdfContentByte directContent

  The direct content in this document.

### directContentUnder

    protected PdfContentByte directContentUnder

  The direct content under in this document.

### documentFonts

    protected java.util.HashMap documentFonts

  The fonts of this document

### documentColors

    protected java.util.HashMap documentColors

  The colors of this document

### documentPatterns

    protected java.util.HashMap documentPatterns

  The patterns of this document

### documentShadings

    protected java.util.HashMap documentShadings

### documentShadingPatterns

    protected java.util.HashMap documentShadingPatterns

### patternColorspaceRGB

    protected ColorDetails patternColorspaceRGB

### patternColorspaceGRAY

    protected ColorDetails patternColorspaceGRAY

### patternColorspaceCMYK

    protected ColorDetails patternColorspaceCMYK

### documentSpotPatterns

    protected java.util.HashMap documentSpotPatterns

### documentExtGState

    protected java.util.HashMap documentExtGState

### documentProperties

    protected java.util.HashMap documentProperties

### documentOCG

    protected java.util.HashSet documentOCG

### documentOCGorder

    protected java.util.ArrayList documentOCGorder

### OCProperties

    protected PdfOCProperties OCProperties

### OCGRadioGroup

    protected PdfArray OCGRadioGroup

### defaultColorspace

    protected PdfDictionary defaultColorspace

### userunit

    protected float userunit

### PDFXNONE

    public static final int PDFXNONE

  PDF/X value

  See Also:
    Constant Field Values

### PDFX1A2001

    public static final int PDFX1A2001

  PDF/X value

  See Also:
    Constant Field Values

### PDFX32002

    public static final int PDFX32002

  PDF/X value

  See Also:
    Constant Field Values

### pdfxConformance

    private int pdfxConformance

### PDFXKEY_COLOR

    static final int PDFXKEY_COLOR

See Also:
  Constant Field Values

### PDFXKEY_CMYK

    static final int PDFXKEY_CMYK

See Also:
  Constant Field Values

### PDFXKEY_RGB

    static final int PDFXKEY_RGB

See Also:
  Constant Field Values

### PDFXKEY_FONT

    static final int PDFXKEY_FONT

See Also:
  Constant Field Values

### PDFXKEY_IMAGE

    static final int PDFXKEY_IMAGE

See Also:
  Constant Field Values

### PDFXKEY_GSTATE

    static final int PDFXKEY_GSTATE

See Also:
  Constant Field Values

### PDFXKEY_LAYER

    static final int PDFXKEY_LAYER

See Also:
  Constant Field Values

### body

    protected PdfWriter.PdfBody body

  body of the PDF document

### pdf

    protected PdfDocument pdf

  the pdfdocument object.

### pageEvent

    private PdfPageEvent pageEvent

  The `PdfPageEvent` for this document.

### crypto

    protected PdfEncryption crypto

### importedPages

    protected java.util.HashMap importedPages

### currentPdfReaderInstance

    protected PdfReaderInstance currentPdfReaderInstance

### pageReferences

    protected java.util.ArrayList pageReferences

  The PdfIndirectReference to the pages.

### currentPageNumber

    protected int currentPageNumber

### group

    protected PdfDictionary group

### SPACE_CHAR_RATIO_DEFAULT

    public static final float SPACE_CHAR_RATIO_DEFAULT

  The default space-char ratio.

  See Also:
    Constant Field Values

### NO_SPACE_CHAR_RATIO

    public static final float NO_SPACE_CHAR_RATIO

  Disable the inter-character spacing.

  See Also:
    Constant Field Values

### RUN_DIRECTION_DEFAULT

    public static final int RUN_DIRECTION_DEFAULT

  Use the default run direction.

  See Also:
    Constant Field Values

### RUN_DIRECTION_NO_BIDI

    public static final int RUN_DIRECTION_NO_BIDI

  Do not use bidirectional reordering.

  See Also:
    Constant Field Values

### RUN_DIRECTION_LTR

    public static final int RUN_DIRECTION_LTR

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

  See Also:
    Constant Field Values

### RUN_DIRECTION_RTL

    public static final int RUN_DIRECTION_RTL

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

  See Also:
    Constant Field Values

### runDirection

    protected int runDirection

### 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.

### extraCatalog

    private PdfDictionary extraCatalog

  Holds value of property extraCatalog.

### xmpMetadata

    protected byte[] xmpMetadata

  XMP Metadata for the document.

### fullCompression

    protected boolean fullCompression

  Holds value of property fullCompression.

### tagged

    protected boolean tagged

### structureTreeRoot

    protected PdfStructureTreeRoot structureTreeRoot

Constructor Detail

### PdfWriter

    protected PdfWriter()

### PdfWriter

    protected PdfWriter(PdfDocument document,
                        java.io.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

### getInstance

    public static PdfWriter getInstance(Document document,
                                        java.io.OutputStream os)
                                 throws DocumentException

  Gets 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,
                                        java.io.OutputStream os,
                                        DocListener listener)
                                 throws DocumentException

  Gets 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

### add

    PdfIndirectReference add(PdfPage page,
                             PdfContents contents)
                       throws PdfException

  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

### addDirectImageSimple

    public PdfName addDirectImageSimple(Image image)
                                 throws PdfException,
                                        DocumentException

  Adds an image to the document but not to the page resources. It is used with templates and `Document.add(Image)`.

  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)
                                 throws PdfException,
                                        DocumentException

  Adds an image to the document but not to the page resources. It is used with templates and `Document.add(Image)`.

  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

### add

    PdfIndirectReference add(PdfImage pdfImage,
                             PdfIndirectReference fixedRef)
                       throws PdfException

  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)
                                throws PdfException

  Throws:
    `PdfException`

### 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`

### 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.

  Specified by:
    `open` in interface `DocListener`
  Overrides:
    `open` in class `DocWriter`

### getOCGOrder

    private static void getOCGOrder(PdfArray order,
                                    PdfLayer layer)

### addASEvent

    private void addASEvent(PdfName event,
                            PdfName category)

### fillOCProperties

    private void fillOCProperties(boolean erase)

### getCatalog

    protected PdfDictionary getCatalog(PdfIndirectReference rootObj)

### addSharedObjectsToBody

    protected void addSharedObjectsToBody()
                                   throws java.io.IOException

  Throws:
    `java.io.IOException`

### 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.

  Specified by:
    `close` in interface `DocListener`
  Overrides:
    `close` in class `DocWriter`

### getTableBottom

    public float getTableBottom(Table table)

  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

### getPdfTable

    public PdfTable getPdfTable(Table table)

  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

### breakTableIfDoesntFit

    public boolean breakTableIfDoesntFit(PdfTable table)
                                  throws DocumentException

  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(Table)`
  Returns:
    true if the table is rendered and emptied.
  Throws:
    `DocumentException`
  See Also:
    `getPdfTable(Table)`

### fitsPage

    public boolean fitsPage(Table table,
                            float margin)

  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)

  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)

  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)

  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.

### getVerticalPosition

    public float getVerticalPosition(boolean ensureNewLine)

  Gets 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.

### isPaused

    boolean isPaused()

  Checks if writing is paused.

  Returns:
    `true` if writing temporarely has to be paused, `false` otherwise.

### getDirectContent

    public PdfContentByte getDirectContent()

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

  Returns:
    the direct content

### getDirectContentUnder

    public PdfContentByte getDirectContentUnder()

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

  Returns:
    the direct content

### resetContent

    void resetContent()

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

### getAcroForm

    public PdfAcroForm getAcroForm()

  Gets the AcroForm object.

  Returns:
    the `PdfAcroForm`

### getRootOutline

    public PdfOutline getRootOutline()

  Gets the root outline.

  Returns:
    the root outline

### getOs

    public OutputStreamCounter getOs()

  Returns the outputStreamCounter.

  Returns:
    the outputStreamCounter

### 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`

### eliminateFontSubset

    void eliminateFontSubset(PdfDictionary fonts)

### getColorspaceName

    PdfName getColorspaceName()

### 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`

### addSimplePatternColorspace

    ColorDetails addSimplePatternColorspace(java.awt.Color color)

### addSimpleShadingPattern

    void addSimpleShadingPattern(PdfShadingPattern shading)

### addSimpleShading

    void addSimpleShading(PdfShading shading)

### addSimpleExtGState

    PdfObject[] addSimpleExtGState(PdfDictionary gstate)

### registerLayer

    void registerLayer(PdfOCG layer)

### addSimpleProperty

    PdfObject[] addSimpleProperty(java.lang.Object prop,
                                  PdfIndirectReference refi)

### propertyExists

    boolean propertyExists(java.lang.Object prop)

### getPdfDocument

    PdfDocument getPdfDocument()

  Gets the `PdfDocument` associated with this writer.

  Returns:
    the `PdfDocument`

### getPdfIndirectReference

    public PdfIndirectReference getPdfIndirectReference()

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

  Returns:
    the `PdfIndirectReference`

### getIndirectReferenceNumber

    int getIndirectReferenceNumber()

### addSimplePattern

    PdfName addSimplePattern(PdfPatternPainter painter)

### 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

### setPageEvent

    public void setPageEvent(PdfPageEvent event)

  Sets the `PdfPageEvent` for this document.

  Parameters:
    `event` - the `PdfPageEvent` for this document

### 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

### addLocalDestinations

    void addLocalDestinations(java.util.TreeMap dest)
                        throws java.io.IOException

  Adds the local destinations to the body of the document.

  Parameters:
    `dest` - the `HashMap` containing the destinations
  Throws:
    `java.io.IOException` - on error

### getPageNumber

    public int getPageNumber()

  Gets the current pagenumber of this document.

  Returns:
    a page number

### setViewerPreferences

    public void setViewerPreferences(int preferences)

  Sets the viewer preferences by ORing some constants.

  - The page layout to be used when the document is opened (choose one).
    - PageLayoutSinglePage - Display one page at a time. (default)
    - PageLayoutOneColumn - Display the pages in one column.
    - PageLayoutTwoColumnLeft - Display the pages in two columns, with oddnumbered pages on the left.
    - PageLayoutTwoColumnRight - Display the pages in two columns, with oddnumbered pages on the right.
    - PageLayoutTwoPageLeft - Display the pages two at a time, with oddnumbered pages on the left.
    - PageLayoutTwoPageRight - Display the pages two at a time, with oddnumbered pages on the right.
  - The page mode how the document should be displayed when opened (choose one).
    - PageModeUseNone - Neither document outline nor thumbnail images visible. (default)
    - PageModeUseOutlines - Document outline visible.
    - PageModeUseThumbs - Thumbnail images visible.
    - PageModeFullScreen - Full-screen mode, with no menu bar, window controls, or any other window visible.
    - PageModeUseOC - Optional content group panel visible
    - PageModeUseAttachments - Attachments panel visible
  - HideToolbar - A flag specifying whether to hide the viewer application's tool bars when the document is active.
  - HideMenubar - A flag specifying whether to hide the viewer application's menu bar when the document is active.
  - HideWindowUI - A flag specifying whether to hide user interface elements in the document's window (such as scroll bars and navigation controls), leaving only the document's contents displayed.
  - FitWindow - A flag specifying whether to resize the document's window to fit the size of the first displayed page.
  - CenterWindow - A flag specifying whether to position the document's window in the center of the screen.
  - DisplayDocTitle - A flag specifying whether to display the document's title in the top bar.
  - The predominant reading order for text. This entry has no direct effect on the document's contents or page numbering, but can be used to determine the relative positioning of pages when displayed side by side or printed n-up (choose one).
    - DirectionL2R - Left to right
    - DirectionR2L - Right to left (including vertical writing systems such as Chinese, Japanese, and Korean)
  - The document's page mode, specifying how to display the document on exiting full-screen mode. It is meaningful only if the page mode is PageModeFullScreen (choose one).
    - NonFullScreenPageModeUseNone - Neither document outline nor thumbnail images visible
    - NonFullScreenPageModeUseOutlines - Document outline visible
    - NonFullScreenPageModeUseThumbs - Thumbnail images visible
    - NonFullScreenPageModeUseOC - Optional content group panel visible
  - PrintScalingNone - Indicates that the print dialog should reflect no page scaling.

  Parameters:
    `preferences` - the viewer preferences

### setEncryption

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

  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,
                              java.lang.String userPassword,
                              java.lang.String ownerPassword,
                              int permissions)
                       throws DocumentException

  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

### addToBody

    public PdfIndirectObject addToBody(PdfObject object)
                                throws java.io.IOException

  Adds an object to the PDF body.

  Parameters:
    `object` -
  Returns:
    a PdfIndirectObject
  Throws:
    `java.io.IOException`

### addToBody

    public PdfIndirectObject addToBody(PdfObject object,
                                       boolean inObjStm)
                                throws java.io.IOException

  Adds an object to the PDF body.

  Parameters:
    `object` -
    `inObjStm` -
  Returns:
    a PdfIndirectObject
  Throws:
    `java.io.IOException`

### addToBody

    public PdfIndirectObject addToBody(PdfObject object,
                                       PdfIndirectReference ref)
                                throws java.io.IOException

  Adds an object to the PDF body.

  Parameters:
    `object` -
    `ref` -
  Returns:
    a PdfIndirectObject
  Throws:
    `java.io.IOException`

### addToBody

    public PdfIndirectObject addToBody(PdfObject object,
                                       PdfIndirectReference ref,
                                       boolean inObjStm)
                                throws java.io.IOException

  Adds an object to the PDF body.

  Parameters:
    `object` -
    `ref` -
    `inObjStm` -
  Returns:
    a PdfIndirectObject
  Throws:
    `java.io.IOException`

### addToBody

    public PdfIndirectObject addToBody(PdfObject object,
                                       int refNumber)
                                throws java.io.IOException

  Adds an object to the PDF body.

  Parameters:
    `object` -
    `refNumber` -
  Returns:
    a PdfIndirectObject
  Throws:
    `java.io.IOException`

### addToBody

    public PdfIndirectObject addToBody(PdfObject object,
                                       int refNumber,
                                       boolean inObjStm)
                                throws java.io.IOException

  Adds an object to the PDF body.

  Parameters:
    `object` -
    `refNumber` -
    `inObjStm` -
  Returns:
    a PdfIndirectObject
  Throws:
    `java.io.IOException`

### setOpenAction

    public void setOpenAction(java.lang.String name)

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

  Parameters:
    `name` - the name of the destination to jump to

### setAdditionalAction

    public void setAdditionalAction(PdfName actionType,
                                    PdfAction action)
                             throws PdfException

  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`.

  Parameters:
    `actionType` - the action type
    `action` - the action to execute in response to the trigger
  Throws:
    `PdfException` - on invalid action type

### setOpenAction

    public void setOpenAction(PdfAction action)

  When the document opens this `action` will be invoked.

  Parameters:
    `action` - the action to be invoked

### setPageLabels

    public void setPageLabels(PdfPageLabels pageLabels)

  Sets the page labels

  Parameters:
    `pageLabels` - the page labels

### getEncryption

    PdfEncryption getEncryption()

### getReaderFile

    RandomAccessFileOrArray getReaderFile(PdfReader reader)

### getNewObjectNumber

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

### getImportedPage

    public PdfImportedPage getImportedPage(PdfReader reader,
                                           int pageNumber)

  Gets 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

### addJavaScript

    public void addJavaScript(PdfAction js)

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

  Parameters:
    `js` - The JavaScrip action

### addJavaScript

    public void addJavaScript(java.lang.String code,
                              boolean unicode)

  Adds 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(java.lang.String code)

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

  Parameters:
    `code` - the JavaScript code

### addFileAttachment

    public void addFileAttachment(java.lang.String description,
                                  byte[] fileStore,
                                  java.lang.String file,
                                  java.lang.String fileDisplay)
                           throws java.io.IOException

  Adds 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:
    `java.io.IOException` - on error

### addFileAttachment

    public void addFileAttachment(java.lang.String description,
                                  PdfFileSpecification fs)
                           throws java.io.IOException

  Adds a file attachment at the document level.

  Parameters:
    `description` - the file description
    `fs` - the file specification
  Throws:
    `java.io.IOException`

### setCropBoxSize

    public void setCropBoxSize(Rectangle crop)

  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.

  Parameters:
    `crop` - the crop box

### getPageReference

    public PdfIndirectReference getPageReference(int page)

  Gets 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

### getCurrentPage

    PdfIndirectReference getCurrentPage()

### getCurrentPageNumber

    int getCurrentPageNumber()

### addCalculationOrder

    public void addCalculationOrder(PdfFormField annot)

  Adds the `PdfAnnotation` to the calculation order array.

  Parameters:
    `annot` - the `PdfAnnotation` to be added

### setSigFlags

    public void setSigFlags(int f)

  Set the signature flags.

  Parameters:
    `f` - the flags. This flags are ORed with current ones

### addAnnotation

    public void addAnnotation(PdfAnnotation annot)

  Adds a `PdfAnnotation` or a `PdfFormField` to the document. Only the top parent of a `PdfFormField` needs to be added.

  Parameters:
    `annot` - the `PdfAnnotation` or the `PdfFormField` to add

### addAnnotation

    void addAnnotation(PdfAnnotation annot,
                       int page)

### setPdfVersion

    public void setPdfVersion(char version)

  Sets the PDF version. Must be used right before the document is opened. Valid options are VERSION_1_2, VERSION_1_3, VERSION_1_4, VERSION_1_5 and VERSION_1_6. VERSION_1_4 is the default.

  Parameters:
    `version` - the version number

### reorderPages

    public int reorderPages(int[] order)
                     throws DocumentException

  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

### getSpaceCharRatio

    public float getSpaceCharRatio()

  Gets the space/character extra spacing ratio for fully justified text.

  Returns:
    the space/character extra spacing ratio

### setSpaceCharRatio

    public void setSpaceCharRatio(float 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.

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

### setRunDirection

    public void setRunDirection(int runDirection)

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

  Parameters:
    `runDirection` - the run direction

### getRunDirection

    public int getRunDirection()

  Gets the run direction.

  Returns:
    the run direction

### setDuration

    public void setDuration(int seconds)

  Sets the display duration for the page (for presentations)

  Parameters:
    `seconds` - the number of seconds to display the page

### setTransition

    public void setTransition(PdfTransition transition)

  Sets the transition for the page

  Parameters:
    `transition` - the Transition object

### freeReader

    public void freeReader(PdfReader reader)
                    throws java.io.IOException

  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.

  Parameters:
    `reader` - the `PdfReader` to free
  Throws:
    `java.io.IOException` - on error

### setPageAction

    public void setPageAction(PdfName actionType,
                              PdfAction action)
                       throws PdfException

  Sets the open and close page additional action.

  Parameters:
    `actionType` - the action type. It can be `PdfWriter.PAGE_OPEN` or `PdfWriter.PAGE_CLOSE`
    `action` - the action to perform
  Throws:
    `PdfException` - if the action type is invalid

### getCurrentDocumentSize

    public int getCurrentDocumentSize()

  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

### isStrictImageSequence

    public boolean isStrictImageSequence()

  Getter for property strictImageSequence.

  Returns:
    value of property strictImageSequence

### setStrictImageSequence

    public void setStrictImageSequence(boolean strictImageSequence)

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

  Parameters:
    `strictImageSequence` - new value of property strictImageSequence

### setPageEmpty

    public void setPageEmpty(boolean pageEmpty)

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

  Parameters:
    `pageEmpty` - the state

### getInfo

    public PdfDictionary getInfo()

  Gets the info dictionary for changing.

  Returns:
    the info dictionary

### getExtraCatalog

    public PdfDictionary getExtraCatalog()

  Sets extra keys to the catalog.

  Returns:
    the catalog to change

### setLinearPageMode

    public void setLinearPageMode()

  Sets the document in a suitable way to do page reordering.

### getGroup

    public PdfDictionary getGroup()

  Getter for property group.

  Returns:
    Value of property group.

### setGroup

    public void setGroup(PdfDictionary group)

  Setter for property group.

  Parameters:
    `group` - New value of property group.

### setPDFXConformance

    public void setPDFXConformance(int pdfxConformance)

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

  Parameters:
    `pdfxConformance` - the conformance level

### getPDFXConformance

    public int getPDFXConformance()

  Gets the PDFX conformance level.

  Returns:
    the PDFX conformance level

### checkPDFXConformance

    static void checkPDFXConformance(PdfWriter writer,
                                     int key,
                                     java.lang.Object obj1)

### setOutputIntents

    public void setOutputIntents(java.lang.String outputConditionIdentifier,
                                 java.lang.String outputCondition,
                                 java.lang.String registryName,
                                 java.lang.String info,
                                 byte[] destOutputProfile)
                          throws java.io.IOException

  Sets 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:
    `java.io.IOException` - on error

### getNameString

    private static java.lang.String getNameString(PdfDictionary dic,
                                                  PdfName key)

### setOutputIntents

    public boolean setOutputIntents(PdfReader reader,
                                    boolean checkExistence)
                             throws java.io.IOException

  Copies the output intent dictionary from other 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:
    `java.io.IOException` - on error

### setBoxSize

    public void setBoxSize(java.lang.String boxName,
                           Rectangle size)

  Sets the page box sizes. Allowed names are: "crop", "trim", "art" and "bleed".

  Parameters:
    `boxName` - the box size
    `size` - the size

### getBoxSize

    public Rectangle getBoxSize(java.lang.String boxName)

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

  Parameters:
    `boxName` - crop, trim, art or bleed

### getPageSize

    public Rectangle getPageSize()

  Gives the size of the media box.

  Returns:
    a Rectangle

### getDefaultColorspace

    public PdfDictionary getDefaultColorspace()

  Gets the default colorspaces.

  Returns:
    the default colorspaces

### setDefaultColorspace

    public void setDefaultColorspace(PdfName key,
                                     PdfObject cs)

  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

### isFullCompression

    public boolean isFullCompression()

  Gets the 1.5 compression status.

  Returns:
    `true` if the 1.5 compression is on

### setFullCompression

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

### getOCProperties

    public PdfOCProperties getOCProperties()

  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.

  Returns:
    the Optional Content Properties Dictionary

### addOCGRadioGroup

    public void addOCGRadioGroup(java.util.ArrayList group)

  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.

  Parameters:
    `group` - the radio group

### setThumbnail

    public void setThumbnail(Image image)
                      throws PdfException,
                             DocumentException

  Sets the the thumbnail image for the current page.

  Parameters:
    `image` - the image
  Throws:
    `PdfException` - on error
    `DocumentException` - or error

### getUserunit

    public float getUserunit()

  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. Remark that this userunit only works starting with PDF1.6!

  Returns:
    Returns the userunit.

### setUserunit

    public void setUserunit(float userunit)
                     throws DocumentException

  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. Remark that this userunit only works starting with PDF1.6!

  Parameters:
    `userunit` - The userunit to set.
  Throws:
    `DocumentException`

### setXmpMetadata

    public void setXmpMetadata(byte[] xmpMetadata)

  Sets XMP Metadata.

  Parameters:
    `xmpMetadata` - The xmpMetadata to set.

### createXmpMetadata

    public void createXmpMetadata()

  Creates XMP Metadata based on the metadata in the PdfDocument.

### releaseTemplate

    public void releaseTemplate(PdfTemplate tp)
                         throws java.io.IOException

  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.

  Parameters:
    `tp` - the template to release
  Throws:
    `java.io.IOException` - on error

### setTagged

    public void setTagged()

  Mark this document for tagging. It must be called before open.

### isTagged

    public boolean isTagged()

  Check if the document is marked for tagging.

  Returns:
    `true` if the document is marked for tagging

### 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