com.itextpdf.text.pdf
Class PdfWriter

java.lang.Object
  extended by com.itextpdf.text.DocWriter
      extended by com.itextpdf.text.pdf.PdfWriter
All Implemented Interfaces:
DocListener, ElementListener, PdfAnnotations, PdfDocumentActions, PdfEncryptionSettings, PdfPageActions, PdfRunDirection, PdfVersion, PdfViewerPreferences, EventListener
Direct Known Subclasses:
PdfCopy

public class PdfWriter
extends DocWriter
implements PdfViewerPreferences, PdfEncryptionSettings, PdfVersion, PdfDocumentActions, PdfPageActions, 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 class PdfWriter.PdfBody
          This class generates the structure of a PDF document.
static class PdfWriter.PdfTrailer
          PdfTrailer is the PDF Trailer object.
 
Field Summary
static int ALLOW_ASSEMBLY
          The operation permitted when the document is opened with the user password
static int ALLOW_COPY
          The operation permitted when the document is opened with the user password
static int ALLOW_DEGRADED_PRINTING
          The operation permitted when the document is opened with the user password
static int ALLOW_FILL_IN
          The operation permitted when the document is opened with the user password
static int ALLOW_MODIFY_ANNOTATIONS
          The operation permitted when the document is opened with the user password
static int ALLOW_MODIFY_CONTENTS
          The operation permitted when the document is opened with the user password
static int ALLOW_PRINTING
          The operation permitted when the document is opened with the user password
static int ALLOW_SCREENREADERS
          The operation permitted when the document is opened with the user password
static int AllowAssembly
          Deprecated. As of iText 2.0.7, use ALLOW_ASSEMBLY instead. Scheduled for removal at or after 2.2.0
static int AllowCopy
          Deprecated. As of iText 2.0.7, use ALLOW_COPY instead. Scheduled for removal at or after 2.2.0
static int AllowDegradedPrinting
          Deprecated. As of iText 2.0.7, use ALLOW_DEGRADED_PRINTING instead. Scheduled for removal at or after 2.2.0
static int AllowFillIn
          Deprecated. As of iText 2.0.7, use ALLOW_FILL_IN instead. Scheduled for removal at or after 2.2.0
static int AllowModifyAnnotations
          Deprecated. As of iText 2.0.7, use ALLOW_MODIFY_ANNOTATIONS instead. Scheduled for removal at or after 2.2.0
static int AllowModifyContents
          Deprecated. As of iText 2.0.7, use ALLOW_MODIFY_CONTENTS instead. Scheduled for removal at or after 2.2.0
static int AllowPrinting
          Deprecated. As of iText 2.0.7, use ALLOW_PRINTING instead. Scheduled for removal at or after 2.2.0
static int AllowScreenReaders
          Deprecated. As of iText 2.0.7, use ALLOW_SCREENREADERS instead. Scheduled for removal at or after 2.2.0
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  ICC_Profile colorProfile
           
protected  int compressionLevel
          The compression level of the content streams.
protected static Counter COUNTER
           
protected  PdfEncryption crypto
          Contains the business logic for cryptography.
protected  int currentPageNumber
          The current page number.
protected  com.itextpdf.text.pdf.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 int DO_NOT_ENCRYPT_METADATA
          Add this to the mode to keep the metadata in clear text
static PdfName DOCUMENT_CLOSE
          action value
protected  HashMap<ICachedColorSpace,com.itextpdf.text.pdf.ColorDetails> documentColors
          The colors of this document
protected  HashMap<PdfDictionary,PdfObject[]> documentExtGState
           
protected  LinkedHashMap<BaseFont,com.itextpdf.text.pdf.FontDetails> documentFonts
          The fonts of this document
protected  HashSet<PdfOCG> documentOCG
          A hashSet containing all the PdfLayer objects.
protected  ArrayList<PdfOCG> documentOCGorder
          An array list used to define the order of an OCG tree.
protected  HashMap<PdfPatternPainter,PdfName> documentPatterns
          The patterns of this document
protected  HashMap<Object,PdfObject[]> documentProperties
           
protected  HashSet<PdfShadingPattern> documentShadingPatterns
           
protected  HashSet<PdfShading> documentShadings
           
protected  HashMap<com.itextpdf.text.pdf.ColorDetails,com.itextpdf.text.pdf.ColorDetails> documentSpotPatterns
           
static int EMBEDDED_FILES_ONLY
          Add this to the mode to keep encrypt only the embedded files.
static int ENCRYPTION_AES_128
          Type of encryption
static int ENCRYPTION_AES_256
          Type of encryption
protected  PdfDictionary extraCatalog
          Holds value of property extraCatalog this is used for Output Intents.
static int FitWindow
          A viewer preference
protected  int fontNumber
          The font number counter for the fonts in the document.
protected  HashMap<PdfIndirectReference,Object[]> 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.
static int GENERATION_MAX
          The highest generation number possible.
protected  PdfDictionary group
          A group attributes dictionary specifying the attributes of the page's page group for use in the transparent imaging model
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
protected  HashMap<PdfStream,PdfIndirectReference> JBIG2Globals
          A HashSet with Stream objects containing JBIG2 Globals
static int markAll
           
static int markInlineElementsOnly
           
protected  List<HashMap<String,Object>> newBookmarks
           
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 OCGLocked
          The locked array in an OCG dictionary
protected  PdfArray OCGRadioGroup
          The RBGroups array in an OCG dictionary
protected  PdfOCProperties OCProperties
          The OCProperties in a catalog dictionary.
protected  byte[] originalFileID
          The original file ID (if present).
static PdfName PAGE_CLOSE
          action value
static PdfName PAGE_OPEN
          action value
protected  PdfDictionary pageDictEntries
          Additional page dictionary entries.
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  ArrayList<PdfIndirectReference> pageReferences
          The PdfIndirectReference to the pages.
protected  com.itextpdf.text.pdf.ColorDetails patternColorspaceCMYK
           
protected  com.itextpdf.text.pdf.ColorDetails patternColorspaceGRAY
           
protected  com.itextpdf.text.pdf.ColorDetails patternColorspaceRGB
           
protected  int patternNumber
          The pattern number counter for the colors in the document.
protected  PdfDocument pdf
          the pdfdocument object.
protected  PdfVersionImp pdf_version
          Stores the version information for the header and the catalog.
static PdfName PDF_VERSION_1_2
          possible PDF version (catalog)
static PdfName PDF_VERSION_1_3
          possible PDF version (catalog)
static PdfName PDF_VERSION_1_4
          possible PDF version (catalog)
static PdfName PDF_VERSION_1_5
          possible PDF version (catalog)
static PdfName PDF_VERSION_1_6
          possible PDF version (catalog)
static PdfName PDF_VERSION_1_7
          possible PDF version (catalog)
protected  PdfIsoConformance pdfIsoConformance
          Stores the PDF ISO conformance.
static int PDFX1A2001
          A PDF/X level.
static int PDFX32002
          A PDF/X level.
static int PDFXNONE
          A PDF/X level.
protected  long prevxref
          A number referring to the previous Cross-Reference Table.
static int PrintScalingNone
          A viewer preference
protected  HashMap<PdfReader,com.itextpdf.text.pdf.PdfReaderInstance> readerInstances
          Instances of PdfReader/PdfReaderInstance that are used to import pages.
protected  PdfPages root
          The root of the page tree.
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.
static int STANDARD_ENCRYPTION_128
          Type of encryption
static int STANDARD_ENCRYPTION_40
          Type of encryption
static boolean STRENGTH128BITS
          Deprecated. As of iText 2.0.7, use STANDARD_ENCRYPTION_128 instead. Scheduled for removal at or after 2.2.0
static boolean STRENGTH40BITS
          Deprecated. As of iText 2.0.7, use STANDARD_ENCRYPTION_40 instead. Scheduled for removal at or after 2.2.0
protected  PdfStructureTreeRoot structureTreeRoot
           
protected  PdfName tabs
          The value of the Tabs entry in the page dictionary.
protected  boolean tagged
           
protected  int taggingMode
           
protected  TtfUnicodeWriter ttfUnicodeWriter
           
static char VERSION_1_2
          possible PDF version (header)
static char VERSION_1_3
          possible PDF version (header)
static char VERSION_1_4
          possible PDF version (header)
static char VERSION_1_5
          possible PDF version (header)
static char VERSION_1_6
          possible PDF version (header)
static char VERSION_1_7
          possible PDF version (header)
static PdfName WILL_PRINT
          action value
static PdfName WILL_SAVE
          action value
protected  byte[] xmpMetadata
          XMP Metadata for the document.
protected  XmpWriter xmpWriter
           
 
Fields inherited from class com.itextpdf.text.DocWriter
closeStream, document, EQUALS, FORWARD, GT, LT, NEWLINE, open, os, pageSize, pause, QUOTE, SPACE, TAB
 
Constructor Summary
protected PdfWriter()
          Constructs a PdfWriter.
protected PdfWriter(PdfDocument document, OutputStream os)
          Constructs a PdfWriter.
 
Method Summary
protected  PdfIndirectReference add(PdfICCBased icc)
           
 void addAnnotation(PdfAnnotation annot)
          Use this methods to add a PdfAnnotation or a PdfFormField to the document.
 void addCalculationOrder(PdfFormField annot)
          Use this method to adds the PdfAnnotation to the calculation order array.
 void addDeveloperExtension(PdfDeveloperExtension de)
          Adds a developer extension to the Extensions dictionary in the Catalog.
 PdfName addDirectImageSimple(Image image)
          Use this method to 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.
 void addFileAttachment(PdfFileSpecification fs)
          Use this method to add a file attachment at the document level.
 void addFileAttachment(String description, byte[] fileStore, String file, String fileDisplay)
          Use this method to add a file attachment at the document level.
 void addFileAttachment(String description, PdfFileSpecification fs)
          Use this method to add a file attachment at the document level.
 void addJavaScript(PdfAction js)
          Use this method to add a JavaScript action at the document level.
 void addJavaScript(String code)
          Use this method to adds a JavaScript action at the document level.
 void addJavaScript(String code, boolean unicode)
          Use this method to add a JavaScript action at the document level.
 void addJavaScript(String name, PdfAction js)
          Use this method to add a JavaScript action at the document level.
 void addJavaScript(String name, String code)
          Use this method to adds a JavaScript action at the document level.
 void addJavaScript(String name, String code, boolean unicode)
          Use this method to add a JavaScript action at the document level.
 void addNamedDestination(String name, int page, PdfDestination dest)
          Adds one named destination.
 void addNamedDestinations(Map<String,String> map, int page_offset)
          Adds named destinations in bulk.
 void addOCGRadioGroup(ArrayList<PdfLayer> group)
          Use this method to set a collection of optional content groups whose states are intended to follow a "radio button" paradigm.
 void addPageDictEntry(PdfName key, PdfObject object)
          Adds an additional entry for the page dictionary.
protected  void addSharedObjectsToBody()
           
 PdfIndirectObject addToBody(PdfObject object)
          Use this method to add a PDF object to the PDF body.
 PdfIndirectObject addToBody(PdfObject object, boolean inObjStm)
          Use this method to add a PDF object to the PDF body.
 PdfIndirectObject addToBody(PdfObject object, int refNumber)
          Use this method to add a PDF object to the PDF body.
 PdfIndirectObject addToBody(PdfObject object, int refNumber, boolean inObjStm)
          Use this method to add a PDF object to the PDF body.
 PdfIndirectObject addToBody(PdfObject object, PdfIndirectReference ref)
          Use this method to add a PDF object to the PDF body.
 PdfIndirectObject addToBody(PdfObject object, PdfIndirectReference ref, boolean inObjStm)
          Use this method to add a PDF object to the PDF body.
 void addViewerPreference(PdfName key, PdfObject value)
          Adds a viewer preference.
protected  void addXFormsToBody()
           
protected  void buildStructTreeRootForTagged(PdfDictionary catalog)
           
protected  void cacheObject(PdfIndirectObject iobj)
          Use this method for caching objects.
 void checkElementRole(IAccessibleElement element, IAccessibleElement parent)
           
 void checkPdfIsoConformance(int key, Object obj1)
           
static void checkPdfIsoConformance(PdfWriter writer, int key, Object obj1)
           
 void clearTextWrap()
          Use this method to clear text wrapping around images (if applicable).
 void close()
          Signals that the Document was closed and that no other Elements will be added.
 PdfAnnotation createAnnotation(float llx, float lly, float urx, float ury, PdfAction action, PdfName subtype)
          A wrapper around PdfAnnotation constructor.
 PdfAnnotation createAnnotation(float llx, float lly, float urx, float ury, PdfString title, PdfString content, PdfName subtype)
          A wrapper around PdfAnnotation constructor.
 PdfAnnotation createAnnotation(Rectangle rect, PdfName subtype)
          A wrapper around PdfAnnotation constructor.
 void createXmpMetadata()
          Use this method to creates XMP Metadata based on the metadata in the PdfDocument.
protected  XmpWriter createXmpWriter(ByteArrayOutputStream baos, HashMap<String,String> info)
           
protected  XmpWriter createXmpWriter(ByteArrayOutputStream baos, PdfDictionary info)
           
protected  void fillOCProperties(boolean erase)
           
protected  void flushAcroFields()
           
protected  void flushTaggedObjects()
          Fix structure of tagged document: remove unused objects, remove unused items from class map, fix xref table due to removed objects.
 void freeReader(PdfReader reader)
          Use this method to writes the reader to the document and free the memory used by it.
 PdfAcroForm getAcroForm()
          Use this methods to get the AcroForm object.
 Rectangle getBoxSize(String boxName)
          Use this method to get the size of a trim, art, crop or bleed box, or null if not defined.
 Rectangle getBoxSize(String boxName, Rectangle intersectingRectangle)
          Returns the intersection between the crop, trim art or bleed box and the parameter intersectingRectangle.
protected  PdfDictionary getCatalog(PdfIndirectReference rootObj)
           
 ICC_Profile getColorProfile()
           
 int getCompressionLevel()
          Returns the compression level used for streams written by this writer.
protected  Counter getCounter()
           
 long getCurrentDocumentSize()
          Use this method to gets the current document size.
 int getCurrentPageNumber()
           
 PdfDictionary getDefaultColorspace()
          Use this method to get the default colorspaces.
 PdfContentByte getDirectContent()
          Use this method to get the direct content for this document.
 PdfContentByte getDirectContentUnder()
          Use this method to get the direct content under for this document.
 PdfDictionary getExtraCatalog()
          Sets extra keys to the catalog.
 PdfDictionary getGroup()
          Use this method to get the group dictionary.
 PdfImportedPage getImportedPage(PdfReader reader, int pageNumber)
          Use this method to get a page from other PDF document.
protected  int getIndirectReferenceNumber()
           
 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).
static PdfWriter getInstance(Document document, OutputStream os)
          Use this method to get an instance of the PdfWriter.
static PdfWriter getInstance(Document document, OutputStream os, DocListener listener)
          Use this method to get an instance of the PdfWriter.
protected  int getNewObjectNumber(PdfReader reader, int number, int generation)
           
 PdfOCProperties getOCProperties()
          Use this method to get the Optional Content Properties Dictionary.
 OutputStreamCounter getOs()
          Returns the outputStreamCounter.
 PdfDictionary getPageDictEntries()
          Gets the additional pageDictEntries.
 PdfPageEvent getPageEvent()
          Gets the PdfPageEvent for this document or null if none is set.
 int getPageNumber()
          Gets the pagenumber of this document.
 PdfIndirectReference getPageReference(int page)
          Use this method to get a reference to a page existing or not.
 Rectangle getPageSize()
          Use this method to get the size of the media box.
 PdfIndirectReference getPdfIndirectReference()
          Use this to get an PdfIndirectReference for an object that will be created in the future.
protected  com.itextpdf.text.pdf.PdfReaderInstance getPdfReaderInstance(PdfReader reader)
          Returns the PdfReaderInstance associated with the specified reader.
 int getPDFXConformance()
           
protected  PdfIndirectReference getReferenceJBIG2Globals(byte[] content)
          Gets an indirect reference to a JBIG2 Globals stream.
 PdfOutline getRootOutline()
          Use this method to get the root outline and construct bookmarks.
 int getRunDirection()
          Use this method to set the run direction.
 float getSpaceCharRatio()
          Use this method to gets the space/character extra spacing ratio for fully justified text.
 List<PdfName> getStandardStructElems()
          Gets the list of the standard structure element names (roles).
 PdfStructureTreeRoot getStructureTreeRoot()
          Gets the structure tree root.
 PdfName getTabs()
          Returns the value to be used for the Tabs entry in the page tree.
protected  TtfUnicodeWriter getTtfUnicodeWriter()
           
 float getVerticalPosition(boolean ensureNewLine)
          Use this method to get the current vertical page position.
 XmpWriter getXmpWriter()
           
protected  PdfIsoConformance initPdfIsoConformance()
           
 boolean isFullCompression()
          Use this method to find out if 1.5 compression is on.
 boolean isPageEmpty()
          Checks if a newPage() will actually generate a new page.
 boolean isPdfIso()
          Checks if any PDF ISO conformance is necessary.
 boolean isPdfX()
           
 boolean isRgbTransparencyBlending()
          Gets the transparency blending colorspace.
 boolean isStrictImageSequence()
          Use this method to get the strictImageSequence status.
 boolean isTagged()
          Check if the document is marked for tagging.
 boolean isUserProperties()
          Gets the flag indicating the presence of structure elements that contain user properties attributes.
 void lockLayer(PdfLayer layer)
          Use this method to lock an optional content group.
 boolean needToBeMarkedInContent(IAccessibleElement element)
           
 void open()
          Signals that the Document has been opened and that Elements can be added.
 void releaseTemplate(PdfTemplate tp)
          Use this method to releases the memory used by a template.
 int reorderPages(int[] order)
          Use this method to reorder the pages in the document.
 void resetPageDictEntries()
          Resets the additional pageDictEntries.
 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 setAtLeastPdfVersion(char version)
          If the PDF Header hasn't been written yet, this changes the version as it will appear in the PDF Header, but only if the parameter refers to a higher version.
 void setBoxSize(String boxName, Rectangle size)
          Use this method to set the page box sizes.
 void setCollection(PdfCollection collection)
          Use this method to add the Collection dictionary.
 void setCompressionLevel(int compressionLevel)
          Sets the compression level to be used for streams written by this writer.
 void setCropBoxSize(Rectangle crop)
          Use this method to set the crop box.
 void setDefaultColorspace(PdfName key, PdfObject cs)
          Use this method to 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, String userPassword, String ownerPassword, int permissions)
          Deprecated. As of iText 2.0.3, replaced by (@link #setEncryption(byte[], byte[], int, int)}. Scheduled for removal at or after 2.2.0
 void setEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, boolean strength128Bits)
          Deprecated. As of iText 2.0.3, replaced by (@link #setEncryption(byte[], byte[], int, int)}. Scheduled for removal at or after 2.2.0
 void setEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionType)
          Sets the encryption options for this document.
 void setEncryption(Certificate[] certs, int[] permissions, int encryptionType)
          Sets the certificate encryption options for this document.
 void setEncryption(int encryptionType, String userPassword, String ownerPassword, int permissions)
          Deprecated. As of iText 2.0.3, replaced by (@link #setEncryption(byte[], byte[], int, int)}. Scheduled for removal at or after 2.2.0
 void setFullCompression()
          Use this method to set the document's compression to the PDF 1.5 mode with object streams and xref streams.
 void setGroup(PdfDictionary group)
          Use this method to set the group dictionary.
 void setInitialLeading(float leading)
          Sets the initial leading for the PDF document.
 void setLanguage(String language)
           
 void setLinearPageMode()
          Use this method to make sure the page tree has a linear structure (every leave is attached directly to the root).
 void setOpenAction(PdfAction action)
          When the document opens this action will be invoked.
 void setOpenAction(String name)
          When the document opens it will jump to the destination with this name.
 void setOutlines(List<HashMap<String,Object>> outlines)
          Sets the bookmarks.
 boolean setOutputIntents(PdfReader reader, boolean checkExistence)
          Use this method to copy the output intent dictionary from another document to this one.
 void setOutputIntents(String outputConditionIdentifier, String outputCondition, String registryName, String info, byte[] destOutputProfile)
          Sets the values of the output intent dictionary.
 void setOutputIntents(String outputConditionIdentifier, String outputCondition, String registryName, String info, ICC_Profile colorProfile)
          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)
          Use this method to make sure a page is added, even if it's empty.
 void setPageEvent(PdfPageEvent event)
          Sets the PdfPageEvent for this document.
 void setPageLabels(PdfPageLabels pageLabels)
          Use this method to add page labels
 void setPageViewport(PdfArray vp)
          Sets the Viewport for the next page.
 void setPageXmpMetadata(byte[] xmpMetadata)
          Use this method to set the XMP Metadata for each page.
 void setPdfVersion(char version)
          If the PDF Header hasn't been written yet, this changes the version as it will appear in the PDF Header.
 void setPdfVersion(PdfName version)
          Sets the PDF version as it will appear in the Catalog.
 void setPDFXConformance(int pdfx)
           
 void setRgbTransparencyBlending(boolean rgbTransparencyBlending)
          Sets the transparency blending colorspace to RGB.
 void setRunDirection(int runDirection)
          Use this method to set the run direction.
 void setSigFlags(int f)
          Use this method to set the signature flags.
 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.
 void setStrictImageSequence(boolean strictImageSequence)
          Use this method to set the image sequence, so that it follows the text in strict order (or not).
 void setTabs(PdfName tabs)
          Sets the value for the Tabs entry in the page tree.
 void setTagged()
          Mark this document for tagging.
 void setTagged(int taggingMode)
           
 void setThumbnail(Image image)
          Use this method to set the thumbnail image for the current page.
 void setTransition(PdfTransition transition)
          Sets the transition for the page
 void setUserProperties(boolean userProperties)
          Sets the flag indicating the presence of structure elements that contain user properties attributes.
 void setUserunit(float userunit)
          Use this method to set the user unit.
 void setViewerPreferences(int preferences)
          Sets the page layout and page mode preferences by ORing one or two of these constants.
 void setXmpMetadata(byte[] xmpMetadata)
          Use this method to set the XMP Metadata.
protected static void writeKeyInfo(OutputStream os)
           
protected  void writeOutlines(PdfDictionary catalog, boolean namedAsNames)
           
 
Methods inherited from class com.itextpdf.text.DocWriter
add, addTabs, flush, getISOBytes, isCloseStream, isPaused, newPage, pause, resetPageCount, resume, setCloseStream, setMarginMirroring, setMarginMirroringTopBottom, 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

GENERATION_MAX

public static final int GENERATION_MAX
The highest generation number possible.

Since:
iText 2.1.6
See Also:
Constant Field Values

COUNTER

protected static Counter COUNTER

pdf

protected PdfDocument pdf
the pdfdocument object.


directContent

protected PdfContentByte directContent
The direct content in this document.


directContentUnder

protected PdfContentByte directContentUnder
The direct content under in this document.


body

protected PdfWriter.PdfBody body
body of the PDF document


colorProfile

protected ICC_Profile colorProfile

extraCatalog

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


root

protected PdfPages root
The root of the page tree.


pageReferences

protected ArrayList<PdfIndirectReference> pageReferences
The PdfIndirectReference to the pages.


currentPageNumber

protected int currentPageNumber
The current page number.


tabs

protected PdfName tabs
The value of the Tabs entry in the page dictionary.

Since:
2.1.5

pageDictEntries

protected PdfDictionary pageDictEntries
Additional page dictionary entries.

Since:
5.1.0

prevxref

protected long prevxref
A number referring to the previous Cross-Reference Table.


originalFileID

protected byte[] originalFileID
The original file ID (if present).


newBookmarks

protected List<HashMap<String,Object>> newBookmarks

VERSION_1_2

public static final char VERSION_1_2
possible PDF version (header)

See Also:
Constant Field Values

VERSION_1_3

public static final char VERSION_1_3
possible PDF version (header)

See Also:
Constant Field Values

VERSION_1_4

public static final char VERSION_1_4
possible PDF version (header)

See Also:
Constant Field Values

VERSION_1_5

public static final char VERSION_1_5
possible PDF version (header)

See Also:
Constant Field Values

VERSION_1_6

public static final char VERSION_1_6
possible PDF version (header)

See Also:
Constant Field Values

VERSION_1_7

public static final char VERSION_1_7
possible PDF version (header)

See Also:
Constant Field Values

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)


pdf_version

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


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

DisplayDocTitle

public static final int DisplayDocTitle
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

PrintScalingNone

public static final int PrintScalingNone
A viewer preference

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


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

xmpMetadata

protected byte[] xmpMetadata
XMP Metadata for the document.


xmpWriter

protected XmpWriter xmpWriter

PDFXNONE

public static final int PDFXNONE
A PDF/X level.

See Also:
Constant Field Values

PDFX1A2001

public static final int PDFX1A2001
A PDF/X level.

See Also:
Constant Field Values

PDFX32002

public static final int PDFX32002
A PDF/X level.

See Also:
Constant Field Values

pdfIsoConformance

protected PdfIsoConformance pdfIsoConformance
Stores the PDF ISO conformance.


STANDARD_ENCRYPTION_40

public static final int STANDARD_ENCRYPTION_40
Type of encryption

See Also:
Constant Field Values

STANDARD_ENCRYPTION_128

public static final int STANDARD_ENCRYPTION_128
Type of encryption

See Also:
Constant Field Values

ENCRYPTION_AES_128

public static final int ENCRYPTION_AES_128
Type of encryption

See Also:
Constant Field Values

ENCRYPTION_AES_256

public static final int ENCRYPTION_AES_256
Type of encryption

See Also:
Constant Field Values

DO_NOT_ENCRYPT_METADATA

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

See Also:
Constant Field Values

EMBEDDED_FILES_ONLY

public static final int EMBEDDED_FILES_ONLY
Add this to the mode to keep encrypt only the embedded files.

Since:
2.1.3
See Also:
Constant Field Values

ALLOW_PRINTING

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

Since:
2.0.7
See Also:
Constant Field Values

ALLOW_MODIFY_CONTENTS

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

Since:
2.0.7
See Also:
Constant Field Values

ALLOW_COPY

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

Since:
2.0.7
See Also:
Constant Field Values

ALLOW_MODIFY_ANNOTATIONS

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

Since:
2.0.7
See Also:
Constant Field Values

ALLOW_FILL_IN

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

Since:
2.0.7
See Also:
Constant Field Values

ALLOW_SCREENREADERS

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

Since:
2.0.7
See Also:
Constant Field Values

ALLOW_ASSEMBLY

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

Since:
2.0.7
See Also:
Constant Field Values

ALLOW_DEGRADED_PRINTING

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

Since:
2.0.7
See Also:
Constant Field Values

AllowPrinting

@Deprecated
public static final int AllowPrinting
Deprecated. As of iText 2.0.7, use ALLOW_PRINTING instead. Scheduled for removal at or after 2.2.0
See Also:
Constant Field Values

AllowModifyContents

@Deprecated
public static final int AllowModifyContents
Deprecated. As of iText 2.0.7, use ALLOW_MODIFY_CONTENTS instead. Scheduled for removal at or after 2.2.0
See Also:
Constant Field Values

AllowCopy

@Deprecated
public static final int AllowCopy
Deprecated. As of iText 2.0.7, use ALLOW_COPY instead. Scheduled for removal at or after 2.2.0
See Also:
Constant Field Values

AllowModifyAnnotations

@Deprecated
public static final int AllowModifyAnnotations
Deprecated. As of iText 2.0.7, use ALLOW_MODIFY_ANNOTATIONS instead. Scheduled for removal at or after 2.2.0
See Also:
Constant Field Values

AllowFillIn

@Deprecated
public static final int AllowFillIn
Deprecated. As of iText 2.0.7, use ALLOW_FILL_IN instead. Scheduled for removal at or after 2.2.0
See Also:
Constant Field Values

AllowScreenReaders

@Deprecated
public static final int AllowScreenReaders
Deprecated. As of iText 2.0.7, use ALLOW_SCREENREADERS instead. Scheduled for removal at or after 2.2.0
See Also:
Constant Field Values

AllowAssembly

@Deprecated
public static final int AllowAssembly
Deprecated. As of iText 2.0.7, use ALLOW_ASSEMBLY instead. Scheduled for removal at or after 2.2.0
See Also:
Constant Field Values

AllowDegradedPrinting

@Deprecated
public static final int AllowDegradedPrinting
Deprecated. As of iText 2.0.7, use ALLOW_DEGRADED_PRINTING instead. Scheduled for removal at or after 2.2.0
See Also:
Constant Field Values

STRENGTH40BITS

@Deprecated
public static final boolean STRENGTH40BITS
Deprecated. As of iText 2.0.7, use STANDARD_ENCRYPTION_40 instead. Scheduled for removal at or after 2.2.0
See Also:
Constant Field Values

STRENGTH128BITS

@Deprecated
public static final boolean STRENGTH128BITS
Deprecated. As of iText 2.0.7, use STANDARD_ENCRYPTION_128 instead. Scheduled for removal at or after 2.2.0
See Also:
Constant Field Values

crypto

protected PdfEncryption crypto
Contains the business logic for cryptography.


fullCompression

protected boolean fullCompression
Holds value of property fullCompression.


compressionLevel

protected int compressionLevel
The compression level of the content streams.

Since:
2.1.3

documentFonts

protected LinkedHashMap<BaseFont,com.itextpdf.text.pdf.FontDetails> documentFonts
The fonts of this document


fontNumber

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


formXObjects

protected HashMap<PdfIndirectReference,Object[]> 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.


readerInstances

protected HashMap<PdfReader,com.itextpdf.text.pdf.PdfReaderInstance> readerInstances
Instances of PdfReader/PdfReaderInstance that are used to import pages.

Since:
5.0.3

currentPdfReaderInstance

protected com.itextpdf.text.pdf.PdfReaderInstance currentPdfReaderInstance

documentColors

protected HashMap<ICachedColorSpace,com.itextpdf.text.pdf.ColorDetails> documentColors
The colors of this document


colorNumber

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


documentPatterns

protected HashMap<PdfPatternPainter,PdfName> documentPatterns
The patterns of this document


patternNumber

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


documentShadingPatterns

protected HashSet<PdfShadingPattern> documentShadingPatterns

documentShadings

protected HashSet<PdfShading> documentShadings

documentExtGState

protected HashMap<PdfDictionary,PdfObject[]> documentExtGState

documentProperties

protected HashMap<Object,PdfObject[]> documentProperties

markAll

public static final int markAll
See Also:
Constant Field Values

markInlineElementsOnly

public static final int markInlineElementsOnly
See Also:
Constant Field Values

tagged

protected boolean tagged

taggingMode

protected int taggingMode

structureTreeRoot

protected PdfStructureTreeRoot structureTreeRoot

documentOCG

protected HashSet<PdfOCG> documentOCG
A hashSet containing all the PdfLayer objects.


documentOCGorder

protected ArrayList<PdfOCG> documentOCGorder
An array list used to define the order of an OCG tree.


OCProperties

protected PdfOCProperties OCProperties
The OCProperties in a catalog dictionary.


OCGRadioGroup

protected PdfArray OCGRadioGroup
The RBGroups array in an OCG dictionary


OCGLocked

protected PdfArray OCGLocked
The locked array in an OCG dictionary

Since:
2.1.2

PAGE_OPEN

public static final PdfName PAGE_OPEN
action value


PAGE_CLOSE

public static final PdfName PAGE_CLOSE
action value


group

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


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

defaultColorspace

protected PdfDictionary defaultColorspace

documentSpotPatterns

protected HashMap<com.itextpdf.text.pdf.ColorDetails,com.itextpdf.text.pdf.ColorDetails> documentSpotPatterns

patternColorspaceRGB

protected com.itextpdf.text.pdf.ColorDetails patternColorspaceRGB

patternColorspaceGRAY

protected com.itextpdf.text.pdf.ColorDetails patternColorspaceGRAY

patternColorspaceCMYK

protected com.itextpdf.text.pdf.ColorDetails patternColorspaceCMYK

imageDictionary

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


JBIG2Globals

protected HashMap<PdfStream,PdfIndirectReference> JBIG2Globals
A HashSet with Stream objects containing JBIG2 Globals

Since:
2.1.5

ttfUnicodeWriter

protected TtfUnicodeWriter ttfUnicodeWriter
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

getCounter

protected Counter getCounter()

getInstance

public static PdfWriter getInstance(Document document,
                                    OutputStream os)
                             throws DocumentException
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)
                             throws DocumentException
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

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

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.

setInitialLeading

public void setInitialLeading(float leading)
                       throws DocumentException
Sets the initial leading for the PDF document. This has to be done before the document is opened.

Parameters:
leading - the initial leading
Throws:
DocumentException - if you try setting the leading after the document was opened.
Since:
2.1.6

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 always retrieve the same object.

Returns:
the direct content

getColorProfile

public ICC_Profile getColorProfile()

addToBody

public PdfIndirectObject addToBody(PdfObject object)
                            throws IOException
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)
                            throws IOException
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)
                            throws IOException
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)
                            throws IOException
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)
                            throws IOException
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)
                            throws IOException
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

cacheObject

protected void cacheObject(PdfIndirectObject iobj)
Use this method for caching objects.

Parameters:
iobj - @see PdfIndirectObject

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

getIndirectReferenceNumber

protected int getIndirectReferenceNumber()

getOs

public OutputStreamCounter getOs()
Returns the outputStreamCounter.

Returns:
the outputStreamCounter

getCatalog

protected PdfDictionary getCatalog(PdfIndirectReference rootObj)

buildStructTreeRootForTagged

protected void buildStructTreeRootForTagged(PdfDictionary catalog)

getExtraCatalog

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

Returns:
the catalog to change

addPageDictEntry

public void addPageDictEntry(PdfName key,
                             PdfObject object)
Adds an additional entry for the page dictionary.

Parameters:
key - the key
object - the PdfObject for the given key
Since:
5.1.0

getPageDictEntries

public PdfDictionary getPageDictEntries()
Gets the additional pageDictEntries.

Returns:
the page dictionary entries
Since:
5.1.0

resetPageDictEntries

public void resetPageDictEntries()
Resets the additional pageDictEntries.

Since:
5.1.0

setLinearPageMode

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


reorderPages

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

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

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

getCurrentPageNumber

public int getCurrentPageNumber()

setPageViewport

public void setPageViewport(PdfArray vp)
Sets the Viewport for the next page.

Parameters:
vp - an array consisting of Viewport dictionaries.
Since:
5.1.0

setTabs

public void setTabs(PdfName tabs)
Sets the value for the Tabs entry in the page tree.

Parameters:
tabs - Can be PdfName.R, PdfName.C or PdfName.S. Since the Adobe Extensions Level 3, it can also be PdfName.A or PdfName.W
Since:
2.1.5

getTabs

public PdfName getTabs()
Returns the value to be used for the Tabs entry in the page tree.

Returns:
the Tabs PdfName
Since:
2.1.5

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

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
See Also:
DocWriter.open()

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 reference table is composed and everything is written to the outputstream embedded in a Trailer.

Specified by:
close in interface DocListener
Overrides:
close in class DocWriter
See Also:
DocWriter.close()

addXFormsToBody

protected void addXFormsToBody()
                        throws IOException
Throws:
IOException

addSharedObjectsToBody

protected void addSharedObjectsToBody()
                               throws IOException
Throws:
IOException

getRootOutline

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

Returns:
the root outline

setOutlines

public void setOutlines(List<HashMap<String,Object>> outlines)
Sets the bookmarks. The list structure is defined in SimpleBookmark.

Parameters:
outlines - the bookmarks or null to remove any

writeOutlines

protected void writeOutlines(PdfDictionary catalog,
                             boolean namedAsNames)
                      throws IOException
Throws:
IOException

setPdfVersion

public void setPdfVersion(char version)
Description copied from interface: PdfVersion
If the PDF Header hasn't been written yet, this changes the version as it will appear in the PDF Header. If the PDF header was already written to the OutputStream, this changes the version as it will appear in the Catalog.

Specified by:
setPdfVersion in interface PdfVersion
Parameters:
version - a character representing the PDF version
See Also:
PdfVersion.setPdfVersion(char)

setAtLeastPdfVersion

public void setAtLeastPdfVersion(char version)
Description copied from interface: PdfVersion
If the PDF Header hasn't been written yet, this changes the version as it will appear in the PDF Header, but only if the parameter refers to a higher version. If the PDF header was already written to the OutputStream, this changes the version as it will appear in the Catalog.

Specified by:
setAtLeastPdfVersion in interface PdfVersion
Parameters:
version - a character representing the PDF version
See Also:
PdfVersion.setAtLeastPdfVersion(char)

setPdfVersion

public void setPdfVersion(PdfName version)
Description copied from interface: PdfVersion
Sets the PDF version as it will appear in the Catalog. Note that this only has effect if you use a later version than the one that appears in the header. This method ignores the parameter if you try to set a lower version than the one currently set in the Catalog.

Specified by:
setPdfVersion in interface PdfVersion
Parameters:
version - the PDF name that will be used for the Version key in the catalog
See Also:
PdfVersion.setPdfVersion(com.itextpdf.text.pdf.PdfName)

addDeveloperExtension

public void addDeveloperExtension(PdfDeveloperExtension de)
Description copied from interface: PdfVersion
Adds a developer extension to the Extensions dictionary in the Catalog.

Specified by:
addDeveloperExtension in interface PdfVersion
Parameters:
de - an object that contains the extensions prefix and dictionary
Since:
2.1.6
See Also:
PdfVersion.addDeveloperExtension(com.itextpdf.text.pdf.PdfDeveloperExtension)

setViewerPreferences

public void setViewerPreferences(int preferences)
Description copied from interface: PdfViewerPreferences
Sets the page layout and page mode preferences by ORing one or two of these constants.

For backward compatibility these values are also supported, but it's better to use method addViewerPreference(key, value) if you want to change the following preferences:

Specified by:
setViewerPreferences in interface PdfViewerPreferences
Parameters:
preferences - the viewer preferences
See Also:
PdfViewerPreferences.setViewerPreferences(int)

addViewerPreference

public void addViewerPreference(PdfName key,
                                PdfObject value)
Description copied from interface: PdfViewerPreferences
Adds a viewer preference.

setPageLabels

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

Parameters:
pageLabels - the page labels

addNamedDestinations

public void addNamedDestinations(Map<String,String> map,
                                 int page_offset)
Adds named destinations in bulk. Valid keys and values of the map can be found in the map that is created by SimpleNamedDestination.

Parameters:
map - a map with strings as keys for the names, and structured strings as values for the destinations
page_offset - number of pages that has to be added to the page numbers in the destinations (useful if you use this method in combination with PdfCopy).
Since:
iText 5.0

addNamedDestination

public void addNamedDestination(String name,
                                int page,
                                PdfDestination dest)
Adds one named destination.

Parameters:
name - the name for the destination
page - the page number where you want to jump to
dest - an explicit destination
Since:
iText 5.0

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

addJavaScript

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

Parameters:
name - The name of the JS Action in the name tree
js - The JavaScript action

addJavaScript

public void addJavaScript(String name,
                          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:
name - The name of the JS Action in the name tree
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 name,
                          String code)
Use this method to adds a JavaScript action at the document level. When the document opens, all this JavaScript runs.

Parameters:
name - The name of the JS Action in the name tree
code - the JavaScript code

addFileAttachment

public void addFileAttachment(String description,
                              byte[] fileStore,
                              String file,
                              String fileDisplay)
                       throws IOException
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)
                       throws IOException
Use this method to add a file attachment at the document level.

Parameters:
description - the file description
fs - the file specification
Throws:
IOException - if the file attachment could not be added to the document

addFileAttachment

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

Parameters:
fs - the file specification
Throws:
IOException - if the file attachment could not be added to the document

setOpenAction

public void setOpenAction(String name)
Description copied from interface: PdfDocumentActions
When the document opens it will jump to the destination with this name.

Specified by:
setOpenAction in interface PdfDocumentActions
Parameters:
name - the name of the destination to jump to
See Also:
PdfDocumentActions.setOpenAction(java.lang.String)

setOpenAction

public void setOpenAction(PdfAction action)
Description copied from interface: PdfDocumentActions
When the document opens this action will be invoked.

Specified by:
setOpenAction in interface PdfDocumentActions
Parameters:
action - the action to be invoked
See Also:
PdfDocumentActions.setOpenAction(com.itextpdf.text.pdf.PdfAction)

setAdditionalAction

public void setAdditionalAction(PdfName actionType,
                                PdfAction action)
                         throws DocumentException
Description copied from interface: PdfDocumentActions
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.

Specified by:
setAdditionalAction in interface PdfDocumentActions
Parameters:
actionType - the action type
action - the action to execute in response to the trigger
Throws:
DocumentException - on invalid action type
See Also:
PdfDocumentActions.setAdditionalAction(com.itextpdf.text.pdf.PdfName, com.itextpdf.text.pdf.PdfAction)

setCollection

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

Parameters:
collection - a dictionary of type PdfCollection

getAcroForm

public PdfAcroForm getAcroForm()
Description copied from interface: PdfAnnotations
Use this methods to get the AcroForm object. Use this method only if you know what you're doing

Specified by:
getAcroForm in interface PdfAnnotations
Returns:
the PdfAcroform object of the PdfDocument
See Also:
PdfAnnotations.getAcroForm()

addAnnotation

public void addAnnotation(PdfAnnotation annot)
Description copied from interface: PdfAnnotations
Use this methods to add a PdfAnnotation or a PdfFormField to the document. Only the top parent of a PdfFormField needs to be added.

Specified by:
addAnnotation in interface PdfAnnotations
Parameters:
annot - the PdfAnnotation or the PdfFormField to add
See Also:
PdfAnnotations.addAnnotation(com.itextpdf.text.pdf.PdfAnnotation)

addCalculationOrder

public void addCalculationOrder(PdfFormField annot)
Description copied from interface: PdfAnnotations
Use this method to adds the PdfAnnotation to the calculation order array.

Specified by:
addCalculationOrder in interface PdfAnnotations
Parameters:
annot - the PdfAnnotation to be added
See Also:
PdfAnnotations.addCalculationOrder(com.itextpdf.text.pdf.PdfFormField)

setSigFlags

public void setSigFlags(int f)
Description copied from interface: PdfAnnotations
Use this method to set the signature flags.

Specified by:
setSigFlags in interface PdfAnnotations
Parameters:
f - the flags. This flags are ORed with current ones
See Also:
PdfAnnotations.setSigFlags(int)

setLanguage

public void setLanguage(String language)

setXmpMetadata

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

Parameters:
xmpMetadata - The xmpMetadata to set.

setPageXmpMetadata

public void setPageXmpMetadata(byte[] xmpMetadata)
                        throws IOException
Use this method to set the XMP Metadata for each page.

Parameters:
xmpMetadata - The xmpMetadata to set.
Throws:
IOException

getXmpWriter

public XmpWriter getXmpWriter()

createXmpMetadata

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

Since:
5.4.4 just creates XmpWriter instance which will be serialized in close.

initPdfIsoConformance

protected PdfIsoConformance initPdfIsoConformance()

setPDFXConformance

public void setPDFXConformance(int pdfx)
See Also:
PdfXConformance.setPDFXConformance(int)

getPDFXConformance

public int getPDFXConformance()
See Also:
PdfXConformance.getPDFXConformance()

isPdfX

public boolean isPdfX()
See Also:
PdfXConformance.isPdfX()

isPdfIso

public boolean isPdfIso()
Checks if any PDF ISO conformance is necessary.

Returns:
true if the PDF has to be in conformance with any of the PDF ISO specifications

setOutputIntents

public void setOutputIntents(String outputConditionIdentifier,
                             String outputCondition,
                             String registryName,
                             String info,
                             ICC_Profile colorProfile)
                      throws 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
colorProfile - a value
Throws:
IOException - on error
Since:
2.1.5

setOutputIntents

public void setOutputIntents(String outputConditionIdentifier,
                             String outputCondition,
                             String registryName,
                             String info,
                             byte[] destOutputProfile)
                      throws IOException
Sets the values of the output intent dictionary. Null values are allowed to suppress any key. Prefer the ICC_Profile-based version of this method.

Parameters:
outputConditionIdentifier - a value
outputCondition - a value, "PDFA/A" to force GTS_PDFA1, otherwise cued by pdfxConformance.
registryName - a value
info - a value
destOutputProfile - a value
Throws:
IOException
Since:
1.x

setOutputIntents

public boolean setOutputIntents(PdfReader reader,
                                boolean checkExistence)
                         throws IOException
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

setEncryption

public void setEncryption(byte[] userPassword,
                          byte[] ownerPassword,
                          int permissions,
                          int encryptionType)
                   throws DocumentException
Description copied from interface: PdfEncryptionSettings
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.

Specified by:
setEncryption in interface PdfEncryptionSettings
Parameters:
userPassword - the user password. Can be null or empty
ownerPassword - the owner password. Can be null or empty
permissions - the user permissions
encryptionType - the type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128. Optionally DO_NOT_ENCRYPT_METADATA can be ored to output the metadata in cleartext
Throws:
DocumentException - if the document is already open
See Also:
PdfEncryptionSettings.setEncryption(byte[], byte[], int, int)

setEncryption

public void setEncryption(Certificate[] certs,
                          int[] permissions,
                          int encryptionType)
                   throws DocumentException
Description copied from interface: PdfEncryptionSettings
Sets the certificate encryption options for this document. An array of one or more public certificates must be provided together with an array of the same size for the permissions for each certificate. The open permissions for the document can be AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations, AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting. The permissions can be combined by ORing them. Optionally DO_NOT_ENCRYPT_METADATA can be ored to output the metadata in cleartext

Specified by:
setEncryption in interface PdfEncryptionSettings
Parameters:
certs - the public certificates to be used for the encryption
permissions - the user permissions for each of the certificates
encryptionType - the type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128.
Throws:
DocumentException - if the document is already open
See Also:
PdfEncryptionSettings.setEncryption(java.security.cert.Certificate[], int[], int)

setEncryption

@Deprecated
public void setEncryption(byte[] userPassword,
                                     byte[] ownerPassword,
                                     int permissions,
                                     boolean strength128Bits)
                   throws DocumentException
Deprecated. As of iText 2.0.3, replaced by (@link #setEncryption(byte[], byte[], int, int)}. Scheduled for removal at or after 2.2.0

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

@Deprecated
public void setEncryption(boolean strength,
                                     String userPassword,
                                     String ownerPassword,
                                     int permissions)
                   throws DocumentException
Deprecated. As of iText 2.0.3, replaced by (@link #setEncryption(byte[], byte[], int, int)}. Scheduled for removal at or after 2.2.0

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

@Deprecated
public void setEncryption(int encryptionType,
                                     String userPassword,
                                     String ownerPassword,
                                     int permissions)
                   throws DocumentException
Deprecated. As of iText 2.0.3, replaced by (@link #setEncryption(byte[], byte[], int, int)}. Scheduled for removal at or after 2.2.0

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 STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_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

isFullCompression

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

Returns:
the 1.5 compression status

setFullCompression

public void setFullCompression()
                        throws DocumentException
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.

Throws:
DocumentException

getCompressionLevel

public int getCompressionLevel()
Returns the compression level used for streams written by this writer.

Returns:
the compression level (0 = best speed, 9 = best compression, -1 is default)
Since:
2.1.3

setCompressionLevel

public void setCompressionLevel(int compressionLevel)
Sets the compression level to be used for streams written by this writer.

Parameters:
compressionLevel - a value between 0 (best speed) and 9 (best compression)
Since:
2.1.3

releaseTemplate

public void releaseTemplate(PdfTemplate tp)
                     throws IOException
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

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

getPdfReaderInstance

protected com.itextpdf.text.pdf.PdfReaderInstance getPdfReaderInstance(PdfReader reader)
Returns the PdfReaderInstance associated with the specified reader. Multiple calls with the same reader object will return the same PdfReaderInstance.

Parameters:
reader - the PDF reader that you want an instance for
Returns:
the instance for the provided reader
Since:
5.0.3

freeReader

public void freeReader(PdfReader reader)
                throws IOException
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

getCurrentDocumentSize

public long getCurrentDocumentSize()
Use this method to gets the current document size. This size only includes the data already written to the output stream, it does not include templates or fonts. It is useful 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

getNewObjectNumber

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

setTagged

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


setTagged

public void setTagged(int taggingMode)

needToBeMarkedInContent

public boolean needToBeMarkedInContent(IAccessibleElement element)

checkElementRole

public void checkElementRole(IAccessibleElement element,
                             IAccessibleElement parent)

isTagged

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

Returns:
true if the document is marked for tagging

flushTaggedObjects

protected void flushTaggedObjects()
                           throws IOException
Fix structure of tagged document: remove unused objects, remove unused items from class map, fix xref table due to removed objects.

Throws:
IOException

flushAcroFields

protected void flushAcroFields()
                        throws IOException,
                               BadPdfFormatException
Throws:
IOException
BadPdfFormatException

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

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

addOCGRadioGroup

public void addOCGRadioGroup(ArrayList<PdfLayer> 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

lockLayer

public void lockLayer(PdfLayer layer)
Use this method to lock an optional content group. The state of a locked group cannot be changed through the user interface of a viewer application. Producers can use this entry to prevent the visibility of content that depends on these groups from being changed by users.

Parameters:
layer - the layer that needs to be added to the array of locked OCGs
Since:
2.1.2

fillOCProperties

protected void fillOCProperties(boolean erase)
Parameters:
erase - true to erase the PdfName.OCGS and PdfName.D from the OCProperties first.
Since:
2.1.2

getPageSize

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

Returns:
a Rectangle

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

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

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

getBoxSize

public Rectangle getBoxSize(String boxName,
                            Rectangle intersectingRectangle)
Returns the intersection between the crop, trim art or bleed box and the parameter intersectingRectangle. This method returns null when - there is no intersection - any of the above boxes are not defined - the parameter intersectingRectangle is null

Parameters:
boxName - crop, trim, art, bleed
intersectingRectangle - the rectangle that intersects the rectangle associated to the boxName
Returns:
the intersection of the two rectangles

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. setPageEmpty(true) won't have any effect.

Parameters:
pageEmpty - the state

isPageEmpty

public boolean isPageEmpty()
Checks if a newPage() will actually generate a new page.

Returns:
true if a new page will be generated, false otherwise
Since:
5.0.0

setPageAction

public void setPageAction(PdfName actionType,
                          PdfAction action)
                   throws DocumentException
Description copied from interface: PdfPageActions
Sets the open and close page additional action.

Specified by:
setPageAction in interface PdfPageActions
Parameters:
actionType - the action type. It can be PdfWriter.PAGE_OPEN or PdfWriter.PAGE_CLOSE
action - the action to perform
Throws:
DocumentException - if the action type is invalid
See Also:
PdfPageActions.setPageAction(com.itextpdf.text.pdf.PdfName, com.itextpdf.text.pdf.PdfAction)

setDuration

public void setDuration(int seconds)
Description copied from interface: PdfPageActions
Sets the display duration for the page (for presentations)

Specified by:
setDuration in interface PdfPageActions
Parameters:
seconds - the number of seconds to display the page
See Also:
PdfPageActions.setDuration(int)

setTransition

public void setTransition(PdfTransition transition)
Description copied from interface: PdfPageActions
Sets the transition for the page

Specified by:
setTransition in interface PdfPageActions
Parameters:
transition - the Transition object
See Also:
PdfPageActions.setTransition(com.itextpdf.text.pdf.PdfTransition)

setThumbnail

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

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

getGroup

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

Returns:
Value of property group.

setGroup

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

Parameters:
group - New value of property group.

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

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

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.

Specified by:
setRunDirection in interface PdfRunDirection
Parameters:
runDirection - the run direction

getRunDirection

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

Specified by:
getRunDirection in interface PdfRunDirection
Returns:
the run direction

setUserunit

public void setUserunit(float userunit)
                 throws DocumentException
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

getDefaultColorspace

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

Returns:
the default colorspaces

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

isStrictImageSequence

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

Returns:
value of property strictImageSequence

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

clearTextWrap

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

Throws:
DocumentException

addDirectImageSimple

public PdfName addDirectImageSimple(Image image)
                             throws PdfException,
                                    DocumentException
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)
                             throws PdfException,
                                    DocumentException
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

add

protected PdfIndirectReference add(PdfICCBased icc)

getReferenceJBIG2Globals

protected PdfIndirectReference getReferenceJBIG2Globals(byte[] content)
Gets an indirect reference to a JBIG2 Globals stream. Adds the stream if it hasn't already been added to the writer.

Parameters:
content - a byte array that may already been added to the writer inside a stream object.
Returns:
the PdfIndirectReference of the stream
Since:
2.1.5

isUserProperties

public boolean isUserProperties()
Gets the flag indicating the presence of structure elements that contain user properties attributes.

Returns:
the user properties flag

setUserProperties

public void setUserProperties(boolean userProperties)
Sets the flag indicating the presence of structure elements that contain user properties attributes.

Parameters:
userProperties - the user properties flag

isRgbTransparencyBlending

public boolean isRgbTransparencyBlending()
Gets the transparency blending colorspace.

Returns:
true if the transparency blending colorspace is RGB, false if it is the default blending colorspace
Since:
2.1.0

setRgbTransparencyBlending

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

Parameters:
rgbTransparencyBlending - true to set the transparency blending colorspace to RGB, false to use the default blending colorspace
Since:
2.1.0

writeKeyInfo

protected static void writeKeyInfo(OutputStream os)
                            throws IOException
Throws:
IOException

getTtfUnicodeWriter

protected TtfUnicodeWriter getTtfUnicodeWriter()

createXmpWriter

protected XmpWriter createXmpWriter(ByteArrayOutputStream baos,
                                    PdfDictionary info)
                             throws IOException
Throws:
IOException

createXmpWriter

protected XmpWriter createXmpWriter(ByteArrayOutputStream baos,
                                    HashMap<String,String> info)
                             throws IOException
Throws:
IOException

createAnnotation

public PdfAnnotation createAnnotation(Rectangle rect,
                                      PdfName subtype)
A wrapper around PdfAnnotation constructor. It is recommended to use this wrapper instead of direct constructor as this is a convenient way to override PdfAnnotation construction when needed.

Parameters:
rect -
subtype -
Returns:

createAnnotation

public PdfAnnotation createAnnotation(float llx,
                                      float lly,
                                      float urx,
                                      float ury,
                                      PdfString title,
                                      PdfString content,
                                      PdfName subtype)
A wrapper around PdfAnnotation constructor. It is recommended to use this wrapper instead of direct constructor as this is a convenient way to override PdfAnnotation construction when needed.

Parameters:
llx -
lly -
urx -
ury -
title -
content -
subtype -
Returns:

createAnnotation

public PdfAnnotation createAnnotation(float llx,
                                      float lly,
                                      float urx,
                                      float ury,
                                      PdfAction action,
                                      PdfName subtype)
A wrapper around PdfAnnotation constructor. It is recommended to use this wrapper instead of direct constructor as this is a convenient way to override PdfAnnotation construction when needed.

Parameters:
llx -
lly -
urx -
ury -
action -
subtype -
Returns:

checkPdfIsoConformance

public static void checkPdfIsoConformance(PdfWriter writer,
                                          int key,
                                          Object obj1)

checkPdfIsoConformance

public void checkPdfIsoConformance(int key,
                                   Object obj1)

getStandardStructElems

public List<PdfName> getStandardStructElems()
Gets the list of the standard structure element names (roles).

Returns:


Copyright © 2014. All Rights Reserved.