Class PdfWriter
- java.lang.Object
-
- com.aowagie.text.DocWriter
-
- com.aowagie.text.pdf.PdfWriter
-
- All Implemented Interfaces:
DocListener,ElementListener,PdfAnnotations,PdfDocumentActions,PdfEncryptionSettings,PdfPageActions,PdfRunDirection,PdfVersion,PdfViewerPreferences,PdfXConformance,java.util.EventListener
- Direct Known Subclasses:
FdfWriter.Wrt,PdfCopy,PdfCopyFieldsImp,PdfStamperImp
public class PdfWriter extends DocWriter implements PdfViewerPreferences, PdfEncryptionSettings, PdfVersion, PdfDocumentActions, PdfPageActions, PdfXConformance, PdfRunDirection, PdfAnnotations
ADocWriterclass for PDF.When this
PdfWriteris added to a certainPdfDocument, the PDF representation of every Element added to this Document will be written to the outputstream.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classPdfWriter.PdfBodyThis class generates the structure of a PDF document.(package private) static classPdfWriter.PdfTrailerPdfTraileris the PDF Trailer object.
-
Field Summary
Fields Modifier and Type Field Description (package private) static intALLOW_ASSEMBLYThe operation permitted when the document is opened with the user password(package private) static intALLOW_COPYThe operation permitted when the document is opened with the user password(package private) static intALLOW_DEGRADED_PRINTINGThe operation permitted when the document is opened with the user password(package private) static intALLOW_FILL_INThe operation permitted when the document is opened with the user password(package private) static intALLOW_MODIFY_ANNOTATIONSThe operation permitted when the document is opened with the user password(package private) static intALLOW_MODIFY_CONTENTSThe operation permitted when the document is opened with the user password(package private) static intALLOW_PRINTINGThe operation permitted when the document is opened with the user password(package private) static intALLOW_SCREENREADERSThe operation permitted when the document is opened with the user passwordprotected PdfWriter.PdfBodybodybody of the PDF documentstatic intCenterWindowA viewer preferenceprivate intcolorNumberThe color number counter for the colors in the document.protected intcompressionLevelThe compression level of the content streams.protected PdfEncryptioncryptoContains the business logic for cryptography.private intcurrentPageNumberThe current page number.protected PdfReaderInstancecurrentPdfReaderInstanceprivate PdfDictionarydefaultColorspace(package private) static PdfNameDID_PRINTaction value(package private) static PdfNameDID_SAVEaction valueprivate PdfContentBytedirectContentThe direct content in this document.private PdfContentBytedirectContentUnderThe direct content under in this document.static intDirectionL2RA viewer preferencestatic intDirectionR2LA viewer preferencestatic intDisplayDocTitleA viewer preference(package private) static intDO_NOT_ENCRYPT_METADATAAdd this to the mode to keep the metadata in clear text(package private) static PdfNameDOCUMENT_CLOSEaction valueprivate java.util.HashMapdocumentColorsThe colors of this documentprivate java.util.HashMapdocumentExtGStateprivate java.util.LinkedHashMapdocumentFontsThe fonts of this documentprotected java.util.HashSetdocumentOCGA hashSet containing all the PdfLayer objects.private java.util.ArrayListdocumentOCGorderAn array list used to define the order of an OCG tree.private java.util.HashMapdocumentPatternsThe patterns of this documentprivate java.util.HashMapdocumentPropertiesprivate java.util.HashMapdocumentShadingPatternsprivate java.util.HashMapdocumentShadingsprivate java.util.HashMapdocumentSpotPatterns(package private) static intEMBEDDED_FILES_ONLYAdd this to the mode to keep encrypt only the embedded files.(package private) static intENCRYPTION_AES_128Type of encryption(package private) static intENCRYPTION_MASKMask to separate the encryption type from the encryption mode.private PdfDictionaryextraCatalogHolds value of property extraCatalog this is used for Output Intents.static intFitWindowA viewer preferenceprivate intfontNumberThe font number counter for the fonts in the document.private java.util.HashMapformXObjectsThe form XObjects in this document.private intformXObjectsCounterThe name counter for the form XObjects name.protected booleanfullCompressionHolds value of property fullCompression.(package private) static intGENERATION_MAXThe highest generation number possible.private PdfDictionarygroupA group attributes dictionary specifying the attributes of the page's page group for use in the transparent imaging modelstatic intHideMenubarA viewer preferencestatic intHideToolbarA viewer preferencestatic intHideWindowUIA viewer preferenceprivate PdfDictionaryimageDictionaryDictionary, containing all the images of the PDF documentprivate java.util.HashMapimagesThis is the list with all the images in the document.private java.util.HashMapimportedPagesprivate java.util.HashMapJBIG2GlobalsA HashSet with Stream objects containing JBIG2 Globalsprotected java.util.ListnewBookmarksstatic intNonFullScreenPageModeUseNoneA viewer preferencestatic intNonFullScreenPageModeUseOCA viewer preferencestatic intNonFullScreenPageModeUseOutlinesA viewer preferencestatic intNonFullScreenPageModeUseThumbsA viewer preferenceprotected PdfArrayOCGLockedThe locked array in an OCG dictionaryprotected PdfArrayOCGRadioGroupThe RBGroups array in an OCG dictionaryprotected PdfOCPropertiesOCPropertiesThe OCProperties in a catalog dictionary.private static PdfNamePAGE_CLOSEaction valueprivate static PdfNamePAGE_OPENaction valueprivate PdfPageEventpageEventThePdfPageEventfor this document.static intPageLayoutOneColumnA viewer preferencestatic intPageLayoutSinglePageA viewer preferencestatic intPageLayoutTwoColumnLeftA viewer preferencestatic intPageLayoutTwoColumnRightA viewer preferencestatic intPageLayoutTwoPageLeftA viewer preferencestatic intPageLayoutTwoPageRightA viewer preferencestatic intPageModeFullScreenA viewer preferencestatic intPageModeUseAttachmentsA viewer preferencestatic intPageModeUseNoneA viewer preferencestatic intPageModeUseOCA viewer preferencestatic intPageModeUseOutlinesA viewer preferencestatic intPageModeUseThumbsA viewer preferenceprivate java.util.ArrayListpageReferencesThe PdfIndirectReference to the pages.private ColorDetailspatternColorspaceCMYKprivate ColorDetailspatternColorspaceGRAYprivate ColorDetailspatternColorspaceRGBprivate intpatternNumberThe pattern number counter for the colors in the document.protected PdfDocumentpdfthe pdfdocument object.protected PdfVersionImppdf_versionStores the version information for the header and the catalog.static PdfNamePDF_VERSION_1_2possible PDF version (catalog)static PdfNamePDF_VERSION_1_3possible PDF version (catalog)static PdfNamePDF_VERSION_1_4possible PDF version (catalog)static PdfNamePDF_VERSION_1_5possible PDF version (catalog)static PdfNamePDF_VERSION_1_6possible PDF version (catalog)static PdfNamePDF_VERSION_1_7possible PDF version (catalog)static intPDFA1APDFA-1A level.static intPDFA1BPDFA-1B level.static intPDFA2APDFA-2A level.static intPDFA2BPDFA-2B level.static intPDFX1A2001A PDF/X level.static intPDFX32002A PDF/X level.private PdfXConformanceImppdfxConformanceStores the PDF/X level.static intPDFXNONEA PDF/X level.protected intprevxrefA number referring to the previous Cross-Reference Table.static intPrintScalingNoneA viewer preferenceprivate booleanrgbTransparencyBlendingHolds value of property RGBTranparency.protected PdfPagesrootThe root of the page tree.static intRUN_DIRECTION_DEFAULTUse the default run direction.(package private) static intRUN_DIRECTION_LTRUse bidirectional reordering with left-to-right preferential run direction.(package private) static intRUN_DIRECTION_NO_BIDIDo not use bidirectional reordering.(package private) static intRUN_DIRECTION_RTLUse bidirectional reordering with right-to-left preferential run direction.private intrunDirectionprivate static floatSPACE_CHAR_RATIO_DEFAULTThe default space-char ratio.private floatspaceCharRatioThe ratio between the extra word spacing and the extra character spacing.(package private) static intSTANDARD_ENCRYPTION_128Type of encryption(package private) static intSTANDARD_ENCRYPTION_40Type of encryptionprivate PdfStructureTreeRootstructureTreeRootprivate PdfNametabsThe value of the Tabs entry in the page dictionary.private booleantaggedprivate booleanuserPropertiesA flag indicating the presence of structure elements that contain user properties attributes.private floatuserunitstatic charVERSION_1_2possible PDF version (header)static charVERSION_1_3possible PDF version (header)static charVERSION_1_4possible PDF version (header)static charVERSION_1_5possible PDF version (header)static charVERSION_1_6possible PDF version (header)static charVERSION_1_7possible PDF version (header)(package private) static PdfNameWILL_PRINTaction value(package private) static PdfNameWILL_SAVEaction valueprotected byte[]xmpMetadataXMP Metadata for the document.
-
Constructor Summary
Constructors Modifier Constructor Description protectedPdfWriter()Constructs aPdfWriter.protectedPdfWriter(PdfDocument document, java.io.OutputStream os)Constructs aPdfWriter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private PdfIndirectReferenceadd(PdfICCBased icc)private PdfIndirectReferenceadd(PdfImage pdfImage, PdfIndirectReference fixedRef)Writes aPdfImageto the outputstream.(package private) PdfIndirectReferenceadd(PdfPage page, PdfContents contents)Adds somePdfContentsto this Writer.voidaddAnnotation(PdfAnnotation annot)Use this methods to add aPdfAnnotationor aPdfFormFieldto the document.(package private) voidaddAnnotation(PdfAnnotation annot, int page)private voidaddASEvent(PdfName event, PdfName category)voidaddDeveloperExtension(PdfDeveloperExtension de)Adds a developer extension to the Extensions dictionary in the Catalog.(package private) PdfNameaddDirectImageSimple(Image image)Use this method to adds an image to the document but not to the page resources.private PdfNameaddDirectImageSimple(Image image, PdfIndirectReference fixedRef)Adds an image to the document but not to the page resources.(package private) PdfNameaddDirectTemplateSimple(PdfTemplate template, PdfName forcedName)Adds a template to the document but not to the page resources.voidaddFileAttachment(java.lang.String description, byte[] fileStore, java.lang.String file, java.lang.String fileDisplay)Use this method to add a file attachment at the document level.(package private) voidaddFileAttachment(java.lang.String description, PdfFileSpecification fs)Use this method to add a file attachment at the document level.private voidaddJavaScript(PdfAction js)Use this method to add a JavaScript action at the document level.(package private) voidaddJavaScript(java.lang.String code, boolean unicode)Use this method to add a JavaScript action at the document level.private voidaddJavaScript(java.lang.String name, PdfAction js)Use this method to add a JavaScript action at the document level.private voidaddJavaScript(java.lang.String name, java.lang.String code, boolean unicode)Use this method to add a JavaScript action at the document level.(package private) voidaddLocalDestinations(java.util.TreeMap dest)Adds the local destinations to the body of the document.protected voidaddSharedObjectsToBody()(package private) FontDetailsaddSimple(BaseFont bf)Adds aBaseFontto the document but not to the page resources.(package private) ColorDetailsaddSimple(PdfSpotColor spc)Adds aSpotColorto the document but not to the page resources.(package private) PdfObject[]addSimpleExtGState(PdfDictionary gstate)(package private) PdfNameaddSimplePattern(PdfPatternPainter painter)(package private) ColorDetailsaddSimplePatternColorspace(java.awt.Color color)(package private) PdfObject[]addSimpleProperty(java.lang.Object prop, PdfIndirectReference refi)(package private) voidaddSimpleShading(PdfShading shading)(package private) voidaddSimpleShadingPattern(PdfShadingPattern shading)(package private) PdfIndirectObjectaddToBody(PdfObject object)Use this method to add a PDF object to the PDF body.PdfIndirectObjectaddToBody(PdfObject object, boolean inObjStm)Use this method to add a PDF object to the PDF body.(package private) PdfIndirectObjectaddToBody(PdfObject object, int refNumber)Use this method to add a PDF object to the PDF body.(package private) PdfIndirectObjectaddToBody(PdfObject object, int refNumber, boolean inObjStm)Use this method to add a PDF object to the PDF body.PdfIndirectObjectaddToBody(PdfObject object, PdfIndirectReference ref)Use this method to add a PDF object to the PDF body.(package private) PdfIndirectObjectaddToBody(PdfObject object, PdfIndirectReference ref, boolean inObjStm)Use this method to add a PDF object to the PDF body.voidaddViewerPreference(PdfName key, PdfObject value)Adds a viewer preference.voidclose()Signals that theDocumentwas closed and that no otherElementswill be added.voidcreateXmpMetadata()private byte[]createXmpMetadataBytes()(package private) voideliminateFontSubset(PdfDictionary fonts)protected voidfillOCProperties(boolean erase)private booleanfitsPage(Table table, float margin)Checks if aTablefits the current page of thePdfDocument.voidfreeReader(PdfReader reader)Use this method to writes the reader to the document and free the memory used by it.PdfAcroFormgetAcroForm()Use this methods to get the AcroForm object.protected PdfDictionarygetCatalog(PdfIndirectReference rootObj)(package private) PdfNamegetColorspaceName()intgetCompressionLevel()Returns the compression level used for streams written by this writer.intgetCurrentDocumentSize()Use this method to gets the current document size.(package private) PdfIndirectReferencegetCurrentPage()intgetCurrentPageNumber()PdfDictionarygetDefaultColorspace()Use this method to get the default colorspaces.PdfContentBytegetDirectContent()Use this method to get the direct content for this document.PdfContentBytegetDirectContentUnder()Use this method to get the direct content under for this document.(package private) PdfEncryptiongetEncryption()PdfDictionarygetExtraCatalog()Sets extra keys to the catalog.PdfDictionarygetGroup()Use this method to get the group dictionary.(package private) PdfIndirectReferencegetImageReference(PdfName name)return thePdfIndirectReferenceto the image with a given name.PdfImportedPagegetImportedPage(PdfReader reader, int pageNumber)Use this method to get a page from other PDF document.(package private) intgetIndirectReferenceNumber()PdfDictionarygetInfo()Use this method to get the info dictionary if you want to change it directly (add keys and values to the info dictionary).static PdfWritergetInstance(Document document, java.io.OutputStream os)Use this method to get an instance of thePdfWriter.private static java.lang.StringgetNameString(PdfDictionary dic, PdfName key)protected intgetNewObjectNumber(PdfReader reader, int number, int generation)private static voidgetOCGOrder(PdfArray order, PdfLayer layer)PdfOCPropertiesgetOCProperties()Use this method to get the Optional Content Properties Dictionary.private OutputStreamCountergetOs()Returns the outputStreamCounter.PdfPageEventgetPageEvent()Gets thePdfPageEventfor this document ornullif none is set.intgetPageNumber()Gets the pagenumber of this document.PdfIndirectReferencegetPageReference(int page)Use this method to get a reference to a page existing or not.RectanglegetPageSize()Use this method to get the size of the media box.(package private) PdfDocumentgetPdfDocument()Gets thePdfDocumentassociated with this writer.PdfIndirectReferencegetPdfIndirectReference()Use this to get anPdfIndirectReferencefor an object that will be created in the future.(package private) PdfVersionImpgetPdfVersion()Returns the version information.intgetPDFXConformance()Getter for the PDF/X Conformance value.(package private) RandomAccessFileOrArraygetReaderFile(PdfReader reader)protected PdfIndirectReferencegetReferenceJBIG2Globals(byte[] content)Gets an indirect reference to a JBIG2 Globals stream.PdfOutlinegetRootOutline()Use this method to get the root outline and construct bookmarks.intgetRunDirection()Use this method to set the run direction.floatgetSpaceCharRatio()Use this method to gets the space/character extra spacing ratio for fully justified text.PdfStructureTreeRootgetStructureTreeRoot()Gets the structure tree root.PdfNamegetTabs()Returns the value to be used for the Tabs entry in the page tree.floatgetUserunit()Use this method to get the user unit.booleanisFullCompression()Use this method to find out if 1.5 compression is on.booleanisPdfX()Checks if the PDF/X Conformance is necessary.booleanisRgbTransparencyBlending()Gets the transparency blending colorspace.booleanisStrictImageSequence()Use this method to get the strictImageSequence status.booleanisTagged()Check if the document is marked for tagging.booleanisUserProperties()Gets the flag indicating the presence of structure elements that contain user properties attributes.voidopen()Signals that theDocumenthas been opened and thatElementscan be added.(package private) booleanpropertyExists(java.lang.Object prop)(package private) voidregisterLayer(PdfOCG layer)(package private) voidreleaseTemplate(PdfTemplate tp)Use this method to releases the memory used by a template.(package private) voidresetContent()Resets all the direct contents to empty.voidsetAdditionalAction(PdfName actionType, PdfAction action)voidsetAtLeastPdfVersion(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.voidsetCollection(PdfCollection collection)Use this method to add the Collection dictionary.voidsetCompressionLevel(int compressionLevel)Sets the compression level to be used for streams written by this writer.voidsetCropBoxSize(Rectangle crop)Use this method to set the crop box.private voidsetDefaultColorspace(PdfName key, PdfObject cs)Use this method to sets the default colorspace that will be applied to all the document.voidsetDuration(int seconds)Sets the display duration for the page (for presentations)voidsetEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionType)Sets the encryption options for this document.voidsetEncryption(java.security.cert.Certificate[] certs, int[] permissions, int encryptionType)Sets the certificate encryption options for this document.(package private) voidsetFullCompression()Use this method to set the document's compression to the PDF 1.5 mode with object streams and xref streams.voidsetGroup(PdfDictionary group)Use this method to set the group dictionary.voidsetInitialLeading(float leading)Sets the initial leading for the PDF document.voidsetOpenAction(PdfAction action)When the document opens thisactionwill be invoked.voidsetOpenAction(java.lang.String name)When the document opens it will jump to the destination with this name.voidsetOutlines(java.util.List outlines)Sets the bookmarks.private voidsetOutputIntents(java.lang.String outputConditionIdentifier, java.lang.String outputCondition, java.lang.String registryName, java.lang.String info, byte[] destOutputProfile)Sets the values of the output intent dictionary.voidsetOutputIntents(java.lang.String outputConditionIdentifier, java.lang.String outputCondition, java.lang.String registryName, java.lang.String info, java.awt.color.ICC_Profile colorProfile)Sets the values of the output intent dictionary.voidsetPageAction(PdfName actionType, PdfAction action)voidsetPageEmpty(boolean pageEmpty)Use this method to make sure a page is added, even if it's empty.voidsetPageEvent(PdfPageEvent event)Sets thePdfPageEventfor this document.voidsetPageLabels(PdfPageLabels pageLabels)Use this method to add page labelsvoidsetPageXmpMetadata(byte[] xmpMetadata)Use this method to set the XMP Metadata for each page.voidsetPdfVersion(char version)If the PDF Header hasn't been written yet, this changes the version as it will appear in the PDF Header.voidsetPdfVersion(PdfName version)Sets the PDF version as it will appear in the Catalog.voidsetPDFXConformance(int pdfx)Sets the PDF/X conformance level.voidsetRgbTransparencyBlending(boolean rgbTransparencyBlending)Sets the transparency blending colorspace to RGB.voidsetRunDirection(int runDirection)Use this method to set the run direction.voidsetSigFlags(int f)Use this method to set the signature flags.voidsetSpaceCharRatio(float spaceCharRatio)Use this method to set the ratio between the extra word spacing and the extra character spacing when the text is fully justified.voidsetStrictImageSequence(boolean strictImageSequence)Use this method to set the image sequence, so that it follows the text in strict order (or not).voidsetTabs(PdfName tabs)Sets the value for the Tabs entry in the page tree.voidsetTagged()Mark this document for tagging.voidsetThumbnail(Image image)Use this method to set the thumbnail image for the current page.voidsetTransition(PdfTransition transition)Sets the transition for the pagevoidsetUserProperties(boolean userProperties)Sets the flag indicating the presence of structure elements that contain user properties attributes.voidsetUserunit(float userunit)Use this method to set the user unit.voidsetViewerPreferences(int preferences)Sets the page layout and page mode preferences by ORing one or two of these constants.voidsetXmpMetadata(byte[] xmpMetadata)Use this method to set the XMP Metadata.protected voidwriteOutlines(PdfDictionary catalog, boolean namedAsNames)-
Methods inherited from class com.aowagie.text.DocWriter
add, getISOBytes, isCloseStream, isPaused, newPage, resetFooter, resetHeader, resetPageCount, setCloseStream, setFooter, setHeader, setMarginMirroring, setMarginMirroringTopBottom, setMargins, setPageCount, setPageSize
-
-
-
-
Field Detail
-
GENERATION_MAX
static final int GENERATION_MAX
The highest generation number possible.- Since:
- iText 2.1.6
- See Also:
- Constant Field Values
-
pdf
protected PdfDocument pdf
the pdfdocument object.
-
directContent
private PdfContentByte directContent
The direct content in this document.
-
directContentUnder
private PdfContentByte directContentUnder
The direct content under in this document.
-
body
protected PdfWriter.PdfBody body
body of the PDF document
-
extraCatalog
private PdfDictionary extraCatalog
Holds value of property extraCatalog this is used for Output Intents.
-
root
protected PdfPages root
The root of the page tree.
-
pageReferences
private final java.util.ArrayList pageReferences
The PdfIndirectReference to the pages.
-
currentPageNumber
private int currentPageNumber
The current page number.
-
tabs
private PdfName tabs
The value of the Tabs entry in the page dictionary.- Since:
- 2.1.5
-
pageEvent
private PdfPageEvent pageEvent
ThePdfPageEventfor this document.
-
prevxref
protected int prevxref
A number referring to the previous Cross-Reference Table.
-
newBookmarks
protected java.util.List 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
static final PdfName DOCUMENT_CLOSE
action value
-
WILL_SAVE
static final PdfName WILL_SAVE
action value
-
DID_SAVE
static final PdfName DID_SAVE
action value
-
WILL_PRINT
static final PdfName WILL_PRINT
action value
-
DID_PRINT
static final PdfName DID_PRINT
action value
-
xmpMetadata
protected byte[] xmpMetadata
XMP Metadata for the document.
-
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
-
PDFA1A
public static final int PDFA1A
PDFA-1A level.- See Also:
- Constant Field Values
-
PDFA1B
public static final int PDFA1B
PDFA-1B level.- See Also:
- Constant Field Values
-
PDFA2A
public static final int PDFA2A
PDFA-2A level.- See Also:
- Constant Field Values
-
PDFA2B
public static final int PDFA2B
PDFA-2B level.- See Also:
- Constant Field Values
-
pdfxConformance
private final PdfXConformanceImp pdfxConformance
Stores the PDF/X level.
-
STANDARD_ENCRYPTION_40
static final int STANDARD_ENCRYPTION_40
Type of encryption- See Also:
- Constant Field Values
-
STANDARD_ENCRYPTION_128
static final int STANDARD_ENCRYPTION_128
Type of encryption- See Also:
- Constant Field Values
-
ENCRYPTION_AES_128
static final int ENCRYPTION_AES_128
Type of encryption- See Also:
- Constant Field Values
-
ENCRYPTION_MASK
static final int ENCRYPTION_MASK
Mask to separate the encryption type from the encryption mode.- See Also:
- Constant Field Values
-
DO_NOT_ENCRYPT_METADATA
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
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
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
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
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
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
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
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
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
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
-
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
private final java.util.LinkedHashMap documentFonts
The fonts of this document
-
fontNumber
private int fontNumber
The font number counter for the fonts in the document.
-
formXObjects
private final java.util.HashMap formXObjects
The form XObjects in this document. The key is the xref and the value is Object[]{PdfName, template}.
-
formXObjectsCounter
private int formXObjectsCounter
The name counter for the form XObjects name.
-
importedPages
private final java.util.HashMap importedPages
-
currentPdfReaderInstance
protected PdfReaderInstance currentPdfReaderInstance
-
documentColors
private final java.util.HashMap documentColors
The colors of this document
-
colorNumber
private int colorNumber
The color number counter for the colors in the document.
-
documentPatterns
private final java.util.HashMap documentPatterns
The patterns of this document
-
patternNumber
private int patternNumber
The pattern number counter for the colors in the document.
-
documentShadingPatterns
private final java.util.HashMap documentShadingPatterns
-
documentShadings
private final java.util.HashMap documentShadings
-
documentExtGState
private final java.util.HashMap documentExtGState
-
documentProperties
private final java.util.HashMap documentProperties
-
tagged
private boolean tagged
-
structureTreeRoot
private PdfStructureTreeRoot structureTreeRoot
-
documentOCG
protected java.util.HashSet documentOCG
A hashSet containing all the PdfLayer objects.
-
documentOCGorder
private final java.util.ArrayList 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
private static final PdfName PAGE_OPEN
action value
-
PAGE_CLOSE
private static final PdfName PAGE_CLOSE
action value
-
group
private 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
private static final float SPACE_CHAR_RATIO_DEFAULT
The default space-char ratio.- See Also:
- Constant Field Values
-
spaceCharRatio
private float spaceCharRatio
The ratio between the extra word spacing and the extra character spacing. Extra word spacing will growratiotimes more than extra character spacing.
-
RUN_DIRECTION_DEFAULT
public static final int RUN_DIRECTION_DEFAULT
Use the default run direction.- See Also:
- Constant Field Values
-
RUN_DIRECTION_NO_BIDI
static final int RUN_DIRECTION_NO_BIDI
Do not use bidirectional reordering.- See Also:
- Constant Field Values
-
RUN_DIRECTION_LTR
static final int RUN_DIRECTION_LTR
Use bidirectional reordering with left-to-right preferential run direction.- See Also:
- Constant Field Values
-
RUN_DIRECTION_RTL
static final int RUN_DIRECTION_RTL
Use bidirectional reordering with right-to-left preferential run direction.- See Also:
- Constant Field Values
-
runDirection
private int runDirection
-
userunit
private float userunit
-
defaultColorspace
private final PdfDictionary defaultColorspace
-
documentSpotPatterns
private final java.util.HashMap documentSpotPatterns
-
patternColorspaceRGB
private ColorDetails patternColorspaceRGB
-
patternColorspaceGRAY
private ColorDetails patternColorspaceGRAY
-
patternColorspaceCMYK
private ColorDetails patternColorspaceCMYK
-
imageDictionary
private final PdfDictionary imageDictionary
Dictionary, containing all the images of the PDF document
-
images
private final java.util.HashMap images
This is the list with all the images in the document.
-
JBIG2Globals
private final java.util.HashMap JBIG2Globals
A HashSet with Stream objects containing JBIG2 Globals- Since:
- 2.1.5
-
userProperties
private boolean userProperties
A flag indicating the presence of structure elements that contain user properties attributes.
-
rgbTransparencyBlending
private boolean rgbTransparencyBlending
Holds value of property RGBTranparency.
-
-
Constructor Detail
-
PdfWriter
protected PdfWriter()
Constructs aPdfWriter.
-
PdfWriter
protected PdfWriter(PdfDocument document, java.io.OutputStream os)
Constructs aPdfWriter.Remark: a PdfWriter can only be constructed by calling the method
getInstance(Document document, OutputStream os).- Parameters:
document- ThePdfDocumentthat has to be writtenos- TheOutputStreamthe writer has to write to.
-
-
Method Detail
-
getInstance
public static PdfWriter getInstance(Document document, java.io.OutputStream os) throws DocumentException
Use this method to get an instance of thePdfWriter.- Parameters:
document- TheDocumentthat has to be writtenos- TheOutputStreamthe writer has to write to.- Returns:
- a new
PdfWriter - Throws:
DocumentException- on error
-
getPdfDocument
PdfDocument getPdfDocument()
Gets thePdfDocumentassociated with this writer.- Returns:
- the
PdfDocument
-
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
-
setInitialLeading
public void setInitialLeading(float leading) throws DocumentExceptionSets 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
-
resetContent
void resetContent()
Resets all the direct contents to empty. This happens when a new page is started.
-
addLocalDestinations
void addLocalDestinations(java.util.TreeMap dest) throws java.io.IOExceptionAdds the local destinations to the body of the document.- Parameters:
dest- theHashMapcontaining the destinations- Throws:
java.io.IOException- on error
-
addToBody
PdfIndirectObject addToBody(PdfObject object) throws java.io.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:
java.io.IOException
-
addToBody
public PdfIndirectObject addToBody(PdfObject object, boolean inObjStm) throws java.io.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- object to addinObjStm- info about inObjStm property- Returns:
- a PdfIndirectObject
- Throws:
java.io.IOException- Exception with a IO error
-
addToBody
public PdfIndirectObject addToBody(PdfObject object, PdfIndirectReference ref) throws java.io.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- object to addref- reference to add- Returns:
- a PdfIndirectObject
- Throws:
java.io.IOException- Exception with information about a IO error
-
addToBody
PdfIndirectObject addToBody(PdfObject object, PdfIndirectReference ref, boolean inObjStm) throws java.io.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:
java.io.IOException
-
addToBody
PdfIndirectObject addToBody(PdfObject object, int refNumber) throws java.io.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:
java.io.IOException
-
addToBody
PdfIndirectObject addToBody(PdfObject object, int refNumber, boolean inObjStm) throws java.io.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:
java.io.IOException
-
getPdfIndirectReference
public PdfIndirectReference getPdfIndirectReference()
Use this to get anPdfIndirectReferencefor an object that will be created in the future. Use this method only if you know what you're doing!- Returns:
- the
PdfIndirectReference
-
getIndirectReferenceNumber
int getIndirectReferenceNumber()
-
getOs
private OutputStreamCounter getOs()
Returns the outputStreamCounter.- Returns:
- the outputStreamCounter
-
getCatalog
protected PdfDictionary getCatalog(PdfIndirectReference rootObj)
-
getExtraCatalog
public PdfDictionary getExtraCatalog()
Sets extra keys to the catalog.- Returns:
- the catalog to change
-
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
-
getCurrentPage
PdfIndirectReference getCurrentPage()
-
getCurrentPageNumber
public int getCurrentPageNumber()
-
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
- Since:
- 2.1.5
-
add
PdfIndirectReference add(PdfPage page, PdfContents contents) throws PdfException
Adds somePdfContentsto this Writer.The document has to be open before you can begin to add content to the body of the document.
- Parameters:
page- thePdfPageto addcontents- thePdfContentsof the page- Returns:
- a
PdfIndirectReference - Throws:
PdfException- on error
-
setPageEvent
public void setPageEvent(PdfPageEvent event)
Sets thePdfPageEventfor this document.- Parameters:
event- thePdfPageEventfor this document
-
getPageEvent
public PdfPageEvent getPageEvent()
Gets thePdfPageEventfor this document ornullif none is set.- Returns:
- the
PdfPageEventfor this document ornullif none is set
-
open
public void open()
Signals that theDocumenthas been opened and thatElementscan be added.When this method is called, the PDF-document header is written to the outputstream.
- Specified by:
openin interfaceDocListener- Overrides:
openin classDocWriter- See Also:
DocWriter.open()
-
close
public void close()
Signals that theDocumentwas closed and that no otherElementswill 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:
closein interfaceDocListener- Overrides:
closein classDocWriter- See Also:
DocWriter.close()
-
addSharedObjectsToBody
protected void addSharedObjectsToBody() throws java.io.IOException- Throws:
java.io.IOException
-
getRootOutline
public PdfOutline getRootOutline()
Use this method to get the root outline and construct bookmarks.- Returns:
- the root outline
-
setOutlines
public void setOutlines(java.util.List outlines)
Sets the bookmarks. The list structure is defined inSimpleBookmark.- Parameters:
outlines- the bookmarks ornullto remove any
-
writeOutlines
protected void writeOutlines(PdfDictionary catalog, boolean namedAsNames) throws java.io.IOException
- Throws:
java.io.IOException
-
setPdfVersion
public void setPdfVersion(char version)
Description copied from interface:PdfVersionIf 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:
setPdfVersionin interfacePdfVersion- Parameters:
version- a character representing the PDF version- See Also:
PdfVersion.setPdfVersion(char)
-
setAtLeastPdfVersion
public void setAtLeastPdfVersion(char version)
Description copied from interface:PdfVersionIf 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:
setAtLeastPdfVersionin interfacePdfVersion- Parameters:
version- a character representing the PDF version- See Also:
PdfVersion.setAtLeastPdfVersion(char)
-
setPdfVersion
public void setPdfVersion(PdfName version)
Description copied from interface:PdfVersionSets 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.- Specified by:
setPdfVersionin interfacePdfVersion- Parameters:
version- the PDF name that will be used for the Version key in the catalog- See Also:
PdfVersion.setPdfVersion(com.aowagie.text.pdf.PdfName)
-
addDeveloperExtension
public void addDeveloperExtension(PdfDeveloperExtension de)
Description copied from interface:PdfVersionAdds a developer extension to the Extensions dictionary in the Catalog.- Specified by:
addDeveloperExtensionin interfacePdfVersion- Parameters:
de- an object that contains the extensions prefix and dictionary- Since:
- 2.1.6
- See Also:
PdfVersion.addDeveloperExtension(com.aowagie.text.pdf.PdfDeveloperExtension)
-
getPdfVersion
PdfVersionImp getPdfVersion()
Returns the version information.
-
setViewerPreferences
public void setViewerPreferences(int preferences)
Description copied from interface:PdfViewerPreferencesSets the page layout and page mode preferences by ORing one or two of these constants.- The page layout to be used when the document is opened (choose one).
- PAGE_LAYOUT_SINGLE_PAGE - Display one page at a time. (default)
- PAGE_LAYOUT_ONE_COLUMN - Display the pages in one column.
- PAGE_LAYOUT_TWO_COLUMN_LEFT - Display the pages in two columns, with oddnumbered pages on the left.
- PAGE_LAYOUT_TWO_COLUMN_RIGHT - Display the pages in two columns, with oddnumbered pages on the right.
- PAGE_LAYOUT_TWO_PAGE_LEFT - Display the pages two at a time, with oddnumbered pages on the left.
- PAGE_LAYOUT_TWO_PAGE_RIGHT - Display the pages two at a time, with oddnumbered pages on the right.
- The page mode how the document should be displayed
when opened (choose one).
- PAGE_MODE_USE_NONE - Neither document outline nor thumbnail images visible. (default)
- PAGE_MODE_USE_OUTLINES - Document outline visible.
- PAGE_MODE_USE_THUMBS - Thumbnail images visible.
- PAGE_MODE_FULL_SCREEN - Full-screen mode, with no menu bar, window controls, or any other window visible.
- PAGE_MODE_USE_OC - Optional content group panel visible
- PAGE_MODE_USE_ATTACHMENTS - Attachments panel visible
addViewerPreference(key, value)if you want to change the following preferences:- HIDE_TOOLBAR - A flag specifying whether to hide the viewer application's tool bars when the document is active.
- HIDE_MENUBAR - A flag specifying whether to hide the viewer application's menu bar when the document is active.
- HIDE_WINDOW_UI - A flag specifying whether to hide user interface elements in the document's window (such as scroll bars and navigation controls), leaving only the document's contents displayed.
- FIT_WINDOW - A flag specifying whether to resize the document's window to fit the size of the first displayed page.
- CENTER_WINDOW - A flag specifying whether to position the document's window in the center of the screen.
- DISPLAY_DOC_TITLE - A flag specifying whether to display the document's title in the top bar.
- The predominant reading order for text. This entry has no direct effect on the
document's contents or page numbering, but can be used to determine the relative
positioning of pages when displayed side by side or printed n-up (choose one).
- DIRECTION_L2R - Left to right
- DIRECTION_R2L - Right to left (including vertical writing systems such as Chinese, Japanese, and Korean)
- The document's page mode, specifying how to display the
document on exiting full-screen mode. It is meaningful only
if the page mode is PageModeFullScreen (choose one).
- NON_FULL_SCREEN_PAGE_MODE_USE_NONE - Neither document outline nor thumbnail images visible
- NON_FULL_SCREEN_PAGE_MODE_USE_OUTLINES - Document outline visible
- NON_FULL_SCREEN_PAGE_MODE_USE_THUMBS - Thumbnail images visible
- NON_FULL_SCREEN_PAGE_MODE_USE_OC - Optional content group panel visible
- PRINT_SCALING_NONE - Indicates that the print dialog should reflect no page scaling.
- Specified by:
setViewerPreferencesin interfacePdfViewerPreferences- Parameters:
preferences- the viewer preferences- See Also:
PdfViewerPreferences.setViewerPreferences(int)
- The page layout to be used when the document is opened (choose one).
-
addViewerPreference
public void addViewerPreference(PdfName key, PdfObject value)
Description copied from interface:PdfViewerPreferencesAdds a viewer preference.- In case the key is one of these values:
- PdfName.HIDETOOLBAR
- PdfName.HIDEMENUBAR
- PdfName.HIDEWINDOWUI
- PdfName.FITWINDOW
- PdfName.CENTERWINDOW
- PdfName.DISPLAYDOCTITLE
- In case the key is PdfName.NONFULLSCREENPAGEMODE,
the value must be one of these names:
- PdfName.USENONE
- PdfName.USEOUTLINES
- PdfName.USETHUMBS
- PdfName.USEOC
- In case the key is PdfName.DIRECTION,
the value must be one of these names:
- PdfName.L2R
- PdfName.R2L
- In case the key is one of these values:
- PdfName.VIEWAREA
- PdfName.VIEWCLIP
- PdfName.PRINTAREA
- PdfName.PRINTCLIP
- PdfName.MEDIABOX
- PdfName.CROPBOX
- PdfName.BLEEDBOX
- PdfName.TRIMBOX
- PdfName.ARTBOX
- In case the key is PdfName.PRINTSCALING, the value can be
- PdfName.APPDEFAULT
- PdfName.NONE
- In case the key is PdfName.DUPLEX, the value can be:
- PdfName.SIMPLEX
- PdfName.DUPLEXFLIPSHORTEDGE
- PdfName.DUPLEXFLIPLONGEDGE
- In case the key is PdfName.PICKTRAYBYPDFSIZE, the value must be of type PdfBoolean.
- In case the key is PdfName.PRINTPAGERANGE, the value must be of type PdfArray.
- In case the key is PdfName.NUMCOPIES, the value must be of type PdfNumber.
- Specified by:
addViewerPreferencein interfacePdfViewerPreferences- Parameters:
key- the name of the viewer preferencevalue- the value of the viewer preference- See Also:
PdfViewerPreferences.addViewerPreference(com.aowagie.text.pdf.PdfName, com.aowagie.text.pdf.PdfObject)
- In case the key is one of these values:
-
setPageLabels
public void setPageLabels(PdfPageLabels pageLabels)
Use this method to add page labels- Parameters:
pageLabels- the page labels
-
addJavaScript
private 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
void addJavaScript(java.lang.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 codeunicode- select JavaScript unicode. Note that the internal Acrobat JavaScript engine does not support unicode, so this may or may not work for you
-
addJavaScript
private void addJavaScript(java.lang.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 treejs- The JavaScript action
-
addJavaScript
private void addJavaScript(java.lang.String name, java.lang.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 treecode- the JavaScript codeunicode- select JavaScript unicode. Note that the internal Acrobat JavaScript engine does not support unicode, so this may or may not work for you
-
addFileAttachment
public void addFileAttachment(java.lang.String description, byte[] fileStore, java.lang.String file, java.lang.String fileDisplay) throws java.io.IOExceptionUse this method to add a file attachment at the document level.- Parameters:
description- the file descriptionfileStore- an array with the file. If it'snullthe file will be read from the diskfile- the path to the file. It will only be used iffileStoreis notnullfileDisplay- the actual file name stored in the pdf- Throws:
java.io.IOException- on error
-
addFileAttachment
void addFileAttachment(java.lang.String description, PdfFileSpecification fs) throws java.io.IOExceptionUse this method to add a file attachment at the document level.- Parameters:
description- the file descriptionfs- the file specification- Throws:
java.io.IOException
-
setOpenAction
public void setOpenAction(java.lang.String name)
Description copied from interface:PdfDocumentActionsWhen the document opens it will jump to the destination with this name.- Specified by:
setOpenActionin interfacePdfDocumentActions- 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:PdfDocumentActionsWhen the document opens thisactionwill be invoked.- Specified by:
setOpenActionin interfacePdfDocumentActions- Parameters:
action- the action to be invoked- See Also:
PdfDocumentActions.setOpenAction(com.aowagie.text.pdf.PdfAction)
-
setAdditionalAction
public void setAdditionalAction(PdfName actionType, PdfAction action) throws DocumentException
- Throws:
DocumentException
-
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:PdfAnnotationsUse this methods to get the AcroForm object. Use this method only if you know what you're doing- Specified by:
getAcroFormin interfacePdfAnnotations- Returns:
- the PdfAcroform object of the PdfDocument
- See Also:
PdfAnnotations.getAcroForm()
-
addAnnotation
public void addAnnotation(PdfAnnotation annot)
Description copied from interface:PdfAnnotationsUse this methods to add aPdfAnnotationor aPdfFormFieldto the document. Only the top parent of aPdfFormFieldneeds to be added.- Specified by:
addAnnotationin interfacePdfAnnotations- Parameters:
annot- thePdfAnnotationor thePdfFormFieldto add- See Also:
PdfAnnotations.addAnnotation(com.aowagie.text.pdf.PdfAnnotation)
-
addAnnotation
void addAnnotation(PdfAnnotation annot, int page)
-
setSigFlags
public void setSigFlags(int f)
Description copied from interface:PdfAnnotationsUse this method to set the signature flags.- Specified by:
setSigFlagsin interfacePdfAnnotations- Parameters:
f- the flags. This flags are ORed with current ones- See Also:
PdfAnnotations.setSigFlags(int)
-
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)
Use this method to set the XMP Metadata for each page.- Parameters:
xmpMetadata- The xmpMetadata to set.
-
createXmpMetadata
public void createXmpMetadata()
-
createXmpMetadataBytes
private byte[] createXmpMetadataBytes()
- Returns:
- an XmpMetadata byte array
-
setPDFXConformance
public void setPDFXConformance(int pdfx)
Description copied from interface:PdfXConformanceSets the PDF/X conformance level. Allowed values are PDFX1A2001, PDFX32002, PDFA1A and PDFA1B. It must be called before opening the document.- Specified by:
setPDFXConformancein interfacePdfXConformance- Parameters:
pdfx- the conformance level- See Also:
PdfXConformance.setPDFXConformance(int)
-
getPDFXConformance
public int getPDFXConformance()
Description copied from interface:PdfXConformanceGetter for the PDF/X Conformance value.- Specified by:
getPDFXConformancein interfacePdfXConformance- Returns:
- the pdfxConformance
- See Also:
PdfXConformance.getPDFXConformance()
-
isPdfX
public boolean isPdfX()
Description copied from interface:PdfXConformanceChecks if the PDF/X Conformance is necessary.- Specified by:
isPdfXin interfacePdfXConformance- Returns:
- true if the PDF has to be in conformance with any of the PDF/X specifications
- See Also:
PdfXConformance.isPdfX()
-
setOutputIntents
public void setOutputIntents(java.lang.String outputConditionIdentifier, java.lang.String outputCondition, java.lang.String registryName, java.lang.String info, java.awt.color.ICC_Profile colorProfile) throws java.io.IOExceptionSets the values of the output intent dictionary. Null values are allowed to suppress any key.- Parameters:
outputConditionIdentifier- a valueoutputCondition- a value, "PDFA/A" to force GTS_PDFA1, otherwise cued by pdfxConformance.registryName- a valueinfo- a valuecolorProfile- a value- Throws:
java.io.IOException- on error- Since:
- 2.1.5
-
setOutputIntents
private void setOutputIntents(java.lang.String outputConditionIdentifier, java.lang.String outputCondition, java.lang.String registryName, java.lang.String info, byte[] destOutputProfile) throws java.io.IOExceptionSets the values of the output intent dictionary. Null values are allowed to suppress any key. Prefer theICC_Profile-based version of this method.- Parameters:
outputConditionIdentifier- a valueoutputCondition- a value, "PDFA/A" to force GTS_PDFA1, otherwise cued by pdfxConformance.registryName- a valueinfo- a valuedestOutputProfile- a value- Throws:
java.io.IOException- Since:
- 1.x
-
getNameString
private static java.lang.String getNameString(PdfDictionary dic, PdfName key)
-
getEncryption
PdfEncryption getEncryption()
-
setEncryption
public void setEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionType) throws DocumentExceptionDescription copied from interface:PdfEncryptionSettingsSets 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:
setEncryptionin interfacePdfEncryptionSettings- Parameters:
userPassword- the user password. Can be null or emptyownerPassword- the owner password. Can be null or emptypermissions- the user permissionsencryptionType- 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(java.security.cert.Certificate[] certs, int[] permissions, int encryptionType) throws DocumentExceptionDescription copied from interface:PdfEncryptionSettingsSets 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:
setEncryptionin interfacePdfEncryptionSettings- Parameters:
certs- the public certificates to be used for the encryptionpermissions- the user permissions for each of the certificatesencryptionType- 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)
-
isFullCompression
public boolean isFullCompression()
Use this method to find out if 1.5 compression is on.- Returns:
- the 1.5 compression status
-
setFullCompression
void setFullCompression()
Use this method to set the document's compression to the PDF 1.5 mode with object streams and xref streams. It can be set at any time but once set it can't be unset.If set before opening the document it will also set the pdf version to 1.5.
-
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
-
addSimple
FontDetails addSimple(BaseFont bf)
Adds aBaseFontto the document but not to the page resources. It is used for templates.- Parameters:
bf- theBaseFontto add- Returns:
- an
Object[]where position 0 is aPdfNameand position 1 is anPdfIndirectReference
-
eliminateFontSubset
void eliminateFontSubset(PdfDictionary fonts)
-
addDirectTemplateSimple
PdfName addDirectTemplateSimple(PdfTemplate template, PdfName forcedName)
Adds a template to the document but not to the page resources.- Parameters:
template- the template to addforcedName- the template name, rather than a generated one. Can be null- Returns:
- the
PdfNamefor this template
-
releaseTemplate
void releaseTemplate(PdfTemplate tp) throws java.io.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:
java.io.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 ispageNumber- the page number. The first page is 1- Returns:
- the template representing the imported page
-
freeReader
public void freeReader(PdfReader reader) throws java.io.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- thePdfReaderto free- Throws:
java.io.IOException- on error
-
getCurrentDocumentSize
public int 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 withfreeReader()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)
-
getReaderFile
RandomAccessFileOrArray getReaderFile(PdfReader reader)
-
getColorspaceName
PdfName getColorspaceName()
-
addSimple
ColorDetails addSimple(PdfSpotColor spc)
Adds aSpotColorto the document but not to the page resources.- Parameters:
spc- theSpotColorto add- Returns:
- an
Object[]where position 0 is aPdfNameand position 1 is anPdfIndirectReference
-
addSimplePattern
PdfName addSimplePattern(PdfPatternPainter painter)
-
addSimpleShadingPattern
void addSimpleShadingPattern(PdfShadingPattern shading)
-
addSimpleShading
void addSimpleShading(PdfShading shading)
-
addSimpleExtGState
PdfObject[] addSimpleExtGState(PdfDictionary gstate)
-
addSimpleProperty
PdfObject[] addSimpleProperty(java.lang.Object prop, PdfIndirectReference refi)
-
propertyExists
boolean propertyExists(java.lang.Object prop)
-
setTagged
public void setTagged()
Mark this document for tagging. It must be called before open.
-
isTagged
public boolean isTagged()
Check if the document is marked for tagging.- Returns:
trueif the document is marked for tagging
-
getStructureTreeRoot
public PdfStructureTreeRoot getStructureTreeRoot()
Gets the structure tree root. If the document is not marked for tagging it will returnnull.- 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
-
fillOCProperties
protected void fillOCProperties(boolean erase)
- Since:
- 2.1.2
-
registerLayer
void registerLayer(PdfOCG layer)
-
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
-
setPageEmpty
public void setPageEmpty(boolean pageEmpty)
Use this method to make sure a page is added, even if it's empty. If you use setPageEmpty(false), invoking newPage() after a blank page will add a newPage.- Parameters:
pageEmpty- the state
-
setPageAction
public void setPageAction(PdfName actionType, PdfAction action) throws DocumentException
- Throws:
DocumentException
-
setDuration
public void setDuration(int seconds)
Description copied from interface:PdfPageActionsSets the display duration for the page (for presentations)- Specified by:
setDurationin interfacePdfPageActions- 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:PdfPageActionsSets the transition for the page- Specified by:
setTransitionin interfacePdfPageActions- Parameters:
transition- the Transition object- See Also:
PdfPageActions.setTransition(com.aowagie.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 errorDocumentException- 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 growspaceCharRatiotimes more than extra character spacing. If the ratio isPdfWriter.NO_SPACE_CHAR_RATIOthen 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:
setRunDirectionin interfacePdfRunDirection- Parameters:
runDirection- the run direction
-
getRunDirection
public int getRunDirection()
Use this method to set the run direction.- Specified by:
getRunDirectionin interfacePdfRunDirection- Returns:
- the run direction
-
getUserunit
public float getUserunit()
Use this method to get the user unit. A user unit is a value that defines the default user space unit. The minimum UserUnit is 1 (1 unit = 1/72 inch). The maximum UserUnit is 75,000. Note that this userunit only works starting with PDF1.6!- Returns:
- Returns the userunit.
-
setUserunit
public void setUserunit(float userunit) throws DocumentExceptionUse 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
private 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 bePdfName.DEFAULTGRAY,PdfName.DEFAULTRGBorPdfName.DEFAULTCMYKcs- the colorspace. AnullorPdfNullremoves any colorspace with the same name
-
addSimplePatternColorspace
ColorDetails addSimplePatternColorspace(java.awt.Color color)
-
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
-
addDirectImageSimple
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 andDocument.add(Image). Use this method only if you know what you're doing!- Parameters:
image- theImageto add- Returns:
- the name of the image added
- Throws:
PdfException- on errorDocumentException- on error
-
addDirectImageSimple
private 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 andDocument.add(Image). Use this method only if you know what you're doing!- Parameters:
image- theImageto addfixedRef- the reference to used. It may benull, aPdfIndirectReferenceor aPRIndirectReference.- Returns:
- the name of the image added
- Throws:
PdfException- on errorDocumentException- on error
-
add
private PdfIndirectReference add(PdfImage pdfImage, PdfIndirectReference fixedRef) throws PdfException
Writes aPdfImageto the outputstream.- Parameters:
pdfImage- the image to be added- Returns:
- a
PdfIndirectReferenceto the encapsulated image - Throws:
PdfException- when a document isn't open yet, or has been closed
-
getImageReference
PdfIndirectReference getImageReference(PdfName name)
return thePdfIndirectReferenceto the image with a given name.- Parameters:
name- the name of the image- Returns:
- a
PdfIndirectReference
-
add
private 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.- Since:
- 2.1.5
-
fitsPage
private boolean fitsPage(Table table, float margin)
Checks if aTablefits the current page of thePdfDocument.- Parameters:
table- the table that has to be checkedmargin- a certain margin- Returns:
trueif theTablefits the page,falseotherwise.
-
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:
trueif the transparency blending colorspace is RGB,falseif 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-trueto set the transparency blending colorspace to RGB,falseto use the default blending colorspace- Since:
- 2.1.0
-
-