public class PdfDocument extends Object implements IEventDispatcher, Closeable, Serializable
Modifier and Type | Field and Description |
---|---|
protected PdfCatalog |
catalog
Document catalog.
|
protected boolean |
closed |
protected boolean |
closeReader |
protected boolean |
closeWriter |
protected PdfPage |
currentPage
Deprecated.
Will be removed in iText 7.2
|
protected PageSize |
defaultPageSize
Default page size.
|
protected EventDispatcher |
eventDispatcher |
protected FingerPrint |
fingerPrint |
protected boolean |
flushUnusedObjects
flag determines whether to write unused objects to result document
|
protected PdfDocumentInfo |
info
Document info.
|
protected boolean |
isClosing |
protected PdfVersion |
pdfVersion
Document version.
|
protected StampingProperties |
properties |
protected PdfReader |
reader
PdfReader associated with the document.
|
protected int |
structParentIndex |
protected PdfStructTreeRoot |
structTreeRoot |
protected TagStructureContext |
tagStructureContext |
protected PdfDictionary |
trailer
Document trailed.
|
protected PdfWriter |
writer
PdfWriter associated with the document.
|
protected byte[] |
xmpMetadata
XMP Metadata for the document.
|
Constructor and Description |
---|
PdfDocument(PdfReader reader)
Open PDF document in reading mode.
|
PdfDocument(PdfReader reader, DocumentProperties properties)
Open PDF document in reading mode.
|
PdfDocument(PdfReader reader, PdfWriter writer)
Opens PDF document in the stamping mode.
|
PdfDocument(PdfReader reader, PdfWriter writer, StampingProperties properties)
Open PDF document in stamping mode.
|
PdfDocument(PdfWriter writer)
Open PDF document in writing mode.
|
PdfDocument(PdfWriter writer, DocumentProperties properties)
Open PDF document in writing mode.
|
Modifier and Type | Method and Description |
---|---|
void |
addAssociatedFile(String description, PdfFileSpec fs)
Adds file associated with PDF document as a whole and identifies the relationship between them.
|
protected void |
addCustomMetadataExtensions(XMPMeta xmpMeta)
Adds custom XMP metadata extension.
|
void |
addEventHandler(String type, IEventHandler handler)
Adds new event handler.
|
void |
addFileAttachment(String key, PdfFileSpec fs)
Adds file attachment at document level.
|
PdfFont |
addFont(PdfFont font)
Adds a PdfFont instance to this document so that this font is flushed automatically on document close.
|
void |
addNamedDestination(String key, PdfObject value)
This methods adds new name in the Dests NameTree.
|
PdfPage |
addNewPage()
Creates and adds new page to the end of document.
|
PdfPage |
addNewPage(int index)
Creates and inserts new page to the document.
|
PdfPage |
addNewPage(int index, PageSize pageSize)
Creates and inserts new page to the document.
|
PdfPage |
addNewPage(PageSize pageSize)
Creates and adds new page with the specified page size.
|
void |
addOutputIntent(PdfOutputIntent outputIntent)
Adds PdfOutputIntent that shall specify the colour characteristics of output devices on which the document might be rendered.
|
PdfPage |
addPage(int index, PdfPage page)
Inserts page to the document.
|
PdfPage |
addPage(PdfPage page)
Adds page to the end of document.
|
protected void |
checkAndAddPage(int index, PdfPage page)
Checks page before adding and add.
|
protected void |
checkAndAddPage(PdfPage page)
Checks page before adding.
|
protected void |
checkClosingStatus()
checks whether a method is invoked at the closed document
|
protected void |
checkIsoConformance()
Checks whether PDF document conforms a specific standard.
|
void |
checkIsoConformance(Object obj, IsoKey key)
Checks whether PDF document conforms a specific standard.
|
void |
checkIsoConformance(Object obj, IsoKey key, PdfResources resources)
Deprecated.
This method will be replaced by
checkIsoConformance in 7.2 release
|
void |
checkIsoConformance(Object obj, IsoKey key, PdfResources resources, PdfStream contentStream)
Checks whether PDF document conforms a specific standard.
|
void |
checkShowTextIsoConformance(CanvasGraphicsState gState, PdfResources resources)
Checks whether PDF document conforms a specific standard.
|
void |
close()
Close PDF document.
|
List<PdfPage> |
copyPagesTo(int pageFrom, int pageTo, PdfDocument toDocument)
Copies a range of pages from current document to toDocument appending copied pages to the end.
|
List<PdfPage> |
copyPagesTo(int pageFrom, int pageTo, PdfDocument toDocument, int insertBeforePage)
Copies a range of pages from current document to toDocument .
|
List<PdfPage> |
copyPagesTo(int pageFrom, int pageTo, PdfDocument toDocument, int insertBeforePage, IPdfPageExtraCopier copier)
Copies a range of pages from current document to toDocument .
|
List<PdfPage> |
copyPagesTo(int pageFrom, int pageTo, PdfDocument toDocument, IPdfPageExtraCopier copier)
Copies a range of pages from current document to toDocument appending copied pages to the end.
|
List<PdfPage> |
copyPagesTo(List<Integer> pagesToCopy, PdfDocument toDocument)
Copies a range of pages from current document to toDocument appending copied pages to the end.
|
List<PdfPage> |
copyPagesTo(List<Integer> pagesToCopy, PdfDocument toDocument, int insertBeforePage)
Copies a range of pages from current document to toDocument .
|
List<PdfPage> |
copyPagesTo(List<Integer> pagesToCopy, PdfDocument toDocument, int insertBeforePage, IPdfPageExtraCopier copier)
Copies a range of pages from current document to toDocument .
|
List<PdfPage> |
copyPagesTo(List<Integer> pagesToCopy, PdfDocument toDocument, IPdfPageExtraCopier copier)
Copies a range of pages from current document to toDocument appending copied pages to the end.
|
PdfIndirectReference |
createNextIndirectReference()
Creates next available indirect reference.
|
void |
dispatchEvent(Event event)
Dispatches an event.
|
void |
dispatchEvent(Event event, boolean delayed)
Dispatches a delayed event.
|
PdfFont |
findFont(String fontProgram, String encoding)
Find PdfFont from loaded fonts with corresponding fontProgram and encoding or CMAP.
|
void |
flushCopiedObjects(PdfDocument sourceDoc)
Flush all copied objects and remove them from copied cache.
|
protected void |
flushFonts()
Flushes all newly added or loaded fonts.
|
protected void |
flushObject(PdfObject pdfObject, boolean canBeInObjStm)
Flush an object.
|
PdfArray |
getAssociatedFiles()
Returns files associated with PDF document.
|
PdfCatalog |
getCatalog()
Gets PDF catalog.
|
protected List<ICounter> |
getCounters()
Deprecated.
|
PdfFont |
getDefaultFont()
Gets default font for the document: Helvetica, WinAnsi.
|
PageSize |
getDefaultPageSize()
Gets default page size.
|
protected Collection<PdfFont> |
getDocumentFonts()
List all newly added or loaded fonts
|
PdfDocumentInfo |
getDocumentInfo()
Gets document information dictionary.
|
PdfEncryptedPayloadDocument |
getEncryptedPayloadDocument()
Gets the encrypted payload of this document, or returns null if this document isn't an unencrypted wrapper document.
|
FingerPrint |
getFingerPrint()
Returns the object containing the registered products.
|
PdfPage |
getFirstPage()
Get the first page of the document.
|
PdfFont |
getFont(PdfDictionary dictionary)
Create a new instance of PdfFont or load already created one.
|
PdfPage |
getLastPage()
Gets the last page of the document.
|
PdfString |
getModifiedDocumentId()
Gets modified document id In order to set modifiedDocumentId WriterProperties.setModifiedDocumentId(com.itextpdf.kernel.pdf.PdfString) should be used
|
int |
getNextStructParentIndex()
Gets next parent index of tagged document.
|
int |
getNumberOfPages()
Gets number of pages of the document.
|
int |
getNumberOfPdfObjects()
Get number of indirect objects in the document.
|
PdfString |
getOriginalDocumentId()
Gets original document id In order to set originalDocumentId WriterProperties.setInitialDocumentId(com.itextpdf.kernel.pdf.PdfString) should be used
|
PdfOutline |
getOutlines(boolean updateOutlines)
This method returns a complete outline tree of the whole document.
|
PdfPage |
getPage(int pageNum)
Gets the page by page number.
|
PdfPage |
getPage(PdfDictionary pageDictionary)
Gets the PdfPage instance by PdfDictionary .
|
protected IPdfPageFactory |
getPageFactory()
Returns the factory for creating page instances.
|
String[] |
getPageLabels()
This method retrieves the page labels from a document as an array of String objects.
|
int |
getPageNumber(PdfDictionary pageDictionary)
Gets page number by PdfDictionary .
|
int |
getPageNumber(PdfPage page)
Gets page number by page.
|
PdfObject |
getPdfObject(int objNum)
Gets PdfObject by object number.
|
PdfVersion |
getPdfVersion()
Gets PDF version.
|
PdfReader |
getReader()
Gets PdfReader associated with the document.
|
PdfStructTreeRoot |
getStructTreeRoot()
Gets PdfStructTreeRoot of tagged document.
|
TagStructureContext |
getTagStructureContext()
Gets document TagStructureContext .
|
PdfDictionary |
getTrailer()
Gets document trailer.
|
PdfWriter |
getWriter()
Gets PdfWriter associated with the document.
|
byte[] |
getXmpMetadata()
Gets XMPMetadata.
|
byte[] |
getXmpMetadata(boolean createNew)
Gets XMPMetadata or create a new one.
|
boolean |
hasEventHandler(String type)
Checks if event dispatcher as an event handler assigned for a certain event type.
|
boolean |
hasOutlines()
Indicates if the document has any outlines
|
void |
initializeOutlines()
This method initializes an outline tree of the document and sets outline mode to true.
|
protected void |
initTagStructureContext()
Initialize TagStructureContext .
|
boolean |
isAppendMode()
Returns true if the document is opened in append mode, and false otherwise.
|
boolean |
isClosed()
Gets close status of the document.
|
boolean |
isCloseReader()
Checks, whether close() method will close associated PdfReader.
|
boolean |
isCloseWriter()
Checks, whether close() method will close associated PdfWriter.
|
boolean |
isFlushUnusedObjects()
Checks, whether close() will flush unused objects, e.g.
|
boolean |
isTagged()
Gets tagged status of the document.
|
List<PdfIndirectReference> |
listIndirectReferences()
Gets static copy of cross reference table.
|
protected void |
markObjectAsMustBeFlushed(PdfObject pdfObject)
Mark an object with PdfObject.MUST_BE_FLUSHED .
|
void |
markStreamAsEmbeddedFile(PdfStream stream)
Marks PdfStream object as embedded file stream.
|
void |
movePage(int pageNumber, int insertBefore)
Moves page to new place in same document with all it tag structure
|
boolean |
movePage(PdfPage page, int insertBefore)
Moves page to new place in same document with all it tag structure
|
protected void |
open(PdfVersion newPdfVersion)
Initializes document.
|
boolean |
registerProduct(ProductInfo productInfo)
Registers a product for debugging purposes.
|
void |
removeAllHandlers()
Remove all event handlers.
|
void |
removeEventHandler(String type, IEventHandler handler)
Removes event handler.
|
void |
removePage(int pageNum)
Removes page from the document by page number.
|
boolean |
removePage(PdfPage page)
Removes the first occurrence of the specified page from this document, if it is present.
|
void |
setCloseReader(boolean closeReader)
Sets, whether close() method shall close associated PdfReader.
|
void |
setCloseWriter(boolean closeWriter)
Sets, whether close() method shall close associated PdfWriter.
|
void |
setDefaultPageSize(PageSize pageSize)
Sets default page size.
|
void |
setEncryptedPayload(PdfFileSpec fs)
Sets an encrypted payload, making this document an unencrypted wrapper document.
|
void |
setFlushUnusedObjects(boolean flushUnusedObjects)
Sets, whether close() shall flush unused objects, e.g.
|
PdfDocument |
setTagged()
Specifies that document shall contain tag structure.
|
void |
setUserProperties(boolean userProperties)
Sets the flag indicating the presence of structure elements that contain user properties attributes.
|
protected void |
setXmpMetadata(byte[] xmpMetadata)
Use this method to set the XMP Metadata.
|
void |
setXmpMetadata(XMPMeta xmpMeta)
Sets the XMP Metadata.
|
void |
setXmpMetadata(XMPMeta xmpMeta, SerializeOptions serializeOptions)
Sets the XMP Metadata.
|
protected void |
storeLinkAnnotation(PdfPage page, PdfLinkAnnotation annotation)
Save the link annotation in a temporary storage for further copying.
|
protected void |
tryInitTagStructure(PdfDictionary str)
Initializes the new instance of document's structure tree root PdfStructTreeRoot .
|
protected XMPMeta |
updateDefaultXmpMetadata()
Update XMP metadata values from PdfDocumentInfo .
|
protected void |
updateXmpMetadata()
Updates XMP metadata.
|
@Deprecated protected PdfPage currentPage
protected PageSize defaultPageSize
protected transient EventDispatcher eventDispatcher
protected PdfWriter writer
protected PdfReader reader
protected byte[] xmpMetadata
protected PdfCatalog catalog
protected PdfDictionary trailer
protected PdfDocumentInfo info
protected PdfVersion pdfVersion
protected FingerPrint fingerPrint
protected final StampingProperties properties
protected PdfStructTreeRoot structTreeRoot
protected int structParentIndex
protected boolean closeReader
protected boolean closeWriter
protected boolean isClosing
protected boolean closed
protected boolean flushUnusedObjects
protected transient TagStructureContext tagStructureContext
public PdfDocument(PdfReader reader)
reader
- PDF reader.
public PdfDocument(PdfReader reader, DocumentProperties properties)
reader
- PDF reader.
properties
- document properties
public PdfDocument(PdfWriter writer)
writer
- PDF writer
public PdfDocument(PdfWriter writer, DocumentProperties properties)
writer
- PDF writer
properties
- document properties
public PdfDocument(PdfReader reader, PdfWriter writer)
reader
- PDF reader.
writer
- PDF writer.
public PdfDocument(PdfReader reader, PdfWriter writer, StampingProperties properties)
reader
- PDF reader.
writer
- PDF writer.
properties
- properties of the stamping process
protected void setXmpMetadata(byte[] xmpMetadata)
xmpMetadata
- The xmpMetadata to set.
public void setXmpMetadata(XMPMeta xmpMeta, SerializeOptions serializeOptions) throws XMPException
xmpMeta
- the xmpMetadata to set
serializeOptions
- serialization options
XMPException
- on serialization errors
public void setXmpMetadata(XMPMeta xmpMeta) throws XMPException
xmpMeta
- the xmpMetadata to set
XMPException
- on serialization errors
public byte[] getXmpMetadata()
public byte[] getXmpMetadata(boolean createNew)
createNew
- if true, create a new empty XMPMetadata if it did not present.
public PdfObject getPdfObject(int objNum)
objNum
- object number.
PdfObject
or null
, if object not found.
public int getNumberOfPdfObjects()
public PdfPage getPage(int pageNum)
pageNum
- page number.
null
in case the page tree is broken
public PdfPage getPage(PdfDictionary pageDictionary)
PdfPage
instance by PdfDictionary
.
pageDictionary
- PdfDictionary
that present page.
PdfDictionary
.
public PdfPage getFirstPage()
public PdfPage getLastPage()
public void markStreamAsEmbeddedFile(PdfStream stream)
PdfStream
object as embedded file stream. Note that this method is for internal usage. To add an embedded file to the PDF document please use specialized API for file attachments. (e.g. addFileAttachment(String, PdfFileSpec)
, PdfPage.addAnnotation(PdfAnnotation)
)
stream
- to be marked as embedded file stream
public PdfPage addNewPage()
public PdfPage addNewPage(PageSize pageSize)
pageSize
- page size of the new page
public PdfPage addNewPage(int index)
index
- position to addPage page to
PdfException
- in case page
is flushed
public PdfPage addNewPage(int index, PageSize pageSize)
index
- position to addPage page to
pageSize
- page size of the new page
PdfException
- in case page
is flushed
public PdfPage addPage(PdfPage page)
page
- page to add.
PdfException
- in case page
is flushed
public PdfPage addPage(int index, PdfPage page)
index
- position to addPage page to
page
- page to addPage
PdfException
- in case page
is flushed
public int getNumberOfPages()
public int getPageNumber(PdfPage page)
page
- the page.
public int getPageNumber(PdfDictionary pageDictionary)
PdfDictionary
.
pageDictionary
- PdfDictionary
that present page.
PdfDictionary
.
public boolean movePage(PdfPage page, int insertBefore)
page
- page to be moved in document if present
insertBefore
- indicates before which page new one will be inserted to
public void movePage(int pageNumber, int insertBefore)
pageNumber
- number of Page that will be moved
insertBefore
- indicates before which page new one will be inserted to
public boolean removePage(PdfPage page)
page
- page to be removed from this document, if present
public void removePage(int pageNum)
pageNum
- the one-based index of the PdfPage to be removed
public PdfDocumentInfo getDocumentInfo()
info
is lazy initialized. It will be initialized during the first call of this method.
public PdfString getOriginalDocumentId()
WriterProperties.setInitialDocumentId(com.itextpdf.kernel.pdf.PdfString)
should be used
public PdfString getModifiedDocumentId()
WriterProperties.setModifiedDocumentId(com.itextpdf.kernel.pdf.PdfString)
should be used
public PageSize getDefaultPageSize()
public void setDefaultPageSize(PageSize pageSize)
pageSize
- page size to be set as default.
public void addEventHandler(String type, IEventHandler handler)
addEventHandler
in interface IEventDispatcher
type
- a type of event to be handled
handler
- event handler
public void dispatchEvent(Event event)
dispatchEvent
in interface IEventDispatcher
event
- the Event
to be dispatched
public void dispatchEvent(Event event, boolean delayed)
dispatchEvent
in interface IEventDispatcher
event
- the Event
to be dispatched
delayed
- flag whether Event
delayed or not
public boolean hasEventHandler(String type)
hasEventHandler
in interface IEventDispatcher
type
- a type of the Event
public void removeEventHandler(String type, IEventHandler handler)
removeEventHandler
in interface IEventDispatcher
type
- a type of the Event
handler
- event handler IEventHandler
public void removeAllHandlers()
removeAllHandlers
in interface IEventDispatcher
public PdfWriter getWriter()
PdfWriter
associated with the document.
public PdfReader getReader()
PdfReader
associated with the document.
public boolean isAppendMode()
true
if the document is opened in append mode, and false
otherwise.
true
if the document is opened in append mode, and false
otherwise.
public PdfIndirectReference createNextIndirectReference()
public PdfVersion getPdfVersion()
public PdfCatalog getCatalog()
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public boolean isClosed()
public boolean isTagged()
public PdfDocument setTagged()
public PdfStructTreeRoot getStructTreeRoot()
PdfStructTreeRoot
of tagged document.
PdfStructTreeRoot
in case document is tagged, otherwise it returns null.
isTagged()
, getNextStructParentIndex()
public int getNextStructParentIndex()
isTagged()
, getNextStructParentIndex()
public TagStructureContext getTagStructureContext()
TagStructureContext
. The document must be tagged, otherwise an exception will be thrown.
TagStructureContext
.
public List<PdfPage> copyPagesTo(int pageFrom, int pageTo, PdfDocument toDocument, int insertBeforePage)
toDocument
. Use this method if you want to copy pages across tagged documents. This will keep resultant PDF structure consistent.
If outlines destination names are the same in different documents, all such outlines will lead to a single location in the resultant document. In this case iText will log a warning. This can be avoided by renaming destinations names in the source document.
pageFrom
- start of the range of pages to be copied.
pageTo
- end of the range of pages to be copied.
toDocument
- a document to copy pages to.
insertBeforePage
- a position where to insert copied pages.
public List<PdfPage> copyPagesTo(int pageFrom, int pageTo, PdfDocument toDocument, int insertBeforePage, IPdfPageExtraCopier copier)
toDocument
. This range is inclusive, both page
and pageTo
are included in list of copied pages. Use this method if you want to copy pages across tagged documents. This will keep resultant PDF structure consistent.
If outlines destination names are the same in different documents, all such outlines will lead to a single location in the resultant document. In this case iText will log a warning. This can be avoided by renaming destinations names in the source document.
pageFrom
- 1-based start of the range of pages to be copied.
pageTo
- 1-based end (inclusive) of the range of pages to be copied. This page is included in list of copied pages.
toDocument
- a document to copy pages to.
insertBeforePage
- a position where to insert copied pages.
copier
- a copier which bears a special copy logic. May be null. It is recommended to use the same instance of IPdfPageExtraCopier
for the same output document.
public List<PdfPage> copyPagesTo(int pageFrom, int pageTo, PdfDocument toDocument)
toDocument
appending copied pages to the end. This range is inclusive, both page
and pageTo
are included in list of copied pages. Use this method if you want to copy pages across tagged documents. This will keep resultant PDF structure consistent.
If outlines destination names are the same in different documents, all such outlines will lead to a single location in the resultant document. In this case iText will log a warning. This can be avoided by renaming destinations names in the source document.
pageFrom
- 1-based start of the range of pages to be copied.
pageTo
- 1-based end (inclusive) of the range of pages to be copied. This page is included in list of copied pages.
toDocument
- a document to copy pages to.
public List<PdfPage> copyPagesTo(int pageFrom, int pageTo, PdfDocument toDocument, IPdfPageExtraCopier copier)
toDocument
appending copied pages to the end. This range is inclusive, both page
and pageTo
are included in list of copied pages. Use this method if you want to copy pages across tagged documents. This will keep resultant PDF structure consistent.
If outlines destination names are the same in different documents, all such outlines will lead to a single location in the resultant document. In this case iText will log a warning. This can be avoided by renaming destinations names in the source document.
pageFrom
- 1-based start of the range of pages to be copied.
pageTo
- 1-based end (inclusive) of the range of pages to be copied. This page is included in list of copied pages.
toDocument
- a document to copy pages to.
copier
- a copier which bears a special copy logic. May be null. It is recommended to use the same instance of IPdfPageExtraCopier
for the same output document.
public List<PdfPage> copyPagesTo(List<Integer> pagesToCopy, PdfDocument toDocument, int insertBeforePage)
toDocument
. Use this method if you want to copy pages across tagged documents. This will keep resultant PDF structure consistent.
If outlines destination names are the same in different documents, all such outlines will lead to a single location in the resultant document. In this case iText will log a warning. This can be avoided by renaming destinations names in the source document.
pagesToCopy
- list of pages to be copied.
toDocument
- a document to copy pages to.
insertBeforePage
- a position where to insert copied pages.
public List<PdfPage> copyPagesTo(List<Integer> pagesToCopy, PdfDocument toDocument, int insertBeforePage, IPdfPageExtraCopier copier)
toDocument
. Use this method if you want to copy pages across tagged documents. This will keep resultant PDF structure consistent.
If outlines destination names are the same in different documents, all such outlines will lead to a single location in the resultant document. In this case iText will log a warning. This can be avoided by renaming destinations names in the source document.
pagesToCopy
- list of pages to be copied.
toDocument
- a document to copy pages to.
insertBeforePage
- a position where to insert copied pages.
copier
- a copier which bears a special copy logic. May be null. It is recommended to use the same instance of IPdfPageExtraCopier
for the same output document.
public List<PdfPage> copyPagesTo(List<Integer> pagesToCopy, PdfDocument toDocument)
toDocument
appending copied pages to the end. Use this method if you want to copy pages across tagged documents. This will keep resultant PDF structure consistent.
If outlines destination names are the same in different documents, all such outlines will lead to a single location in the resultant document. In this case iText will log a warning. This can be avoided by renaming destinations names in the source document.
pagesToCopy
- list of pages to be copied.
toDocument
- a document to copy pages to.
public List<PdfPage> copyPagesTo(List<Integer> pagesToCopy, PdfDocument toDocument, IPdfPageExtraCopier copier)
toDocument
appending copied pages to the end. Use this method if you want to copy pages across tagged documents. This will keep resultant PDF structure consistent.
If outlines destination names are the same in different documents, all such outlines will lead to a single location in the resultant document. In this case iText will log a warning. This can be avoided by renaming destinations names in the source document.
pagesToCopy
- list of pages to be copied.
toDocument
- a document to copy pages to.
copier
- a copier which bears a special copy logic. May be null. It is recommended to use the same instance of IPdfPageExtraCopier
for the same output document.
public void flushCopiedObjects(PdfDocument sourceDoc)
Note, if you will copy objects from the same document, duplicated objects will be created. That's why usually this method is meant to be used when all copying from source document is finished. For other cases one can also consider other flushing mechanisms, e.g. pages-based flushing.
sourceDoc
- source document
public boolean isCloseReader()
close()
method will close associated PdfReader.
close()
method is going to close associated PdfReader, otherwise false.
public void setCloseReader(boolean closeReader)
close()
method shall close associated PdfReader.
closeReader
- true, close()
method shall close associated PdfReader, otherwise false.
public boolean isCloseWriter()
close()
method will close associated PdfWriter.
close()
method is going to close associated PdfWriter, otherwise false.
public void setCloseWriter(boolean closeWriter)
close()
method shall close associated PdfWriter.
closeWriter
- true, close()
method shall close associated PdfWriter, otherwise false.
public boolean isFlushUnusedObjects()
close()
will flush unused objects, e.g. unreachable from PDF Catalog. By default - false.
close()
shall not flush unused objects, otherwise true.
public void setFlushUnusedObjects(boolean flushUnusedObjects)
close()
shall flush unused objects, e.g. unreachable from PDF Catalog.
flushUnusedObjects
- false, if close()
shall not flush unused objects, otherwise true.
public PdfOutline getOutlines(boolean updateOutlines)
updateOutlines
- if the flag is true
, the method reads the whole document and creates outline tree. If the flag is false
, the method gets cached outline tree (if it was cached via calling getOutlines method before).
PdfOutline
object.
public void initializeOutlines()
public void addNamedDestination(String key, PdfObject value)
key
- Name of the destination.
value
- An object destination refers to. Must be an array or a dictionary with key /D and array. See ISO 32000-1 12.3.2.3 for more info.
public List<PdfIndirectReference> listIndirectReferences()
public PdfDictionary getTrailer()
public void addOutputIntent(PdfOutputIntent outputIntent)
PdfOutputIntent
that shall specify the colour characteristics of output devices on which the document might be rendered.
outputIntent
- PdfOutputIntent
to add.
PdfOutputIntent
public void checkIsoConformance(Object obj, IsoKey key)
obj
- An object to conform.
key
- type of object to conform.
@Deprecated public void checkIsoConformance(Object obj, IsoKey key, PdfResources resources)
checkIsoConformance
in 7.2 release
obj
- an object to conform.
key
- type of object to conform.
resources
- PdfResources
associated with an object to check.
public void checkIsoConformance(Object obj, IsoKey key, PdfResources resources, PdfStream contentStream)
obj
- an object to conform.
key
- type of object to conform.
resources
- PdfResources
associated with an object to check.
contentStream
- current content stream
public void checkShowTextIsoConformance(CanvasGraphicsState gState, PdfResources resources)
gState
- a CanvasGraphicsState
object to conform.
resources
- PdfResources
associated with an object to check.
public void addFileAttachment(String key, PdfFileSpec fs)
key
- name of the destination.
fs
- PdfFileSpec
object.
public void addAssociatedFile(String description, PdfFileSpec fs)
Associated files may be used in Pdf/A-3 and Pdf 2.0 documents. The method is very similar to addFileAttachment(String, PdfFileSpec)
. However, besides adding file description to Names tree, it adds file to array value of the AF key in the document catalog.
For associated files their associated file specification dictionaries shall include the AFRelationship key
description
- the file description
fs
- file specification dictionary of associated file
addFileAttachment(String, PdfFileSpec)
public PdfArray getAssociatedFiles()
public PdfEncryptedPayloadDocument getEncryptedPayloadDocument()
null
if this document isn't an unencrypted wrapper document.
public void setEncryptedPayload(PdfFileSpec fs)
fs
- encrypted payload file spec. PdfEncryptedPayloadFileSpecFactory
can produce one.
public String[] getPageLabels()
String
list of page labels if they were found, or null
otherwise
public boolean hasOutlines()
true
, if there are outlines and false
otherwise.
public void setUserProperties(boolean userProperties)
userProperties
- the user properties flag
public PdfFont getFont(PdfDictionary dictionary)
PdfFont
or load already created one.
dictionary
- PdfDictionary
that presents PdfFont
.
PdfFont
Note, PdfFont which created with PdfFontFactory.createFont(PdfDictionary)
won't be cached until it will be added to PdfCanvas
or PdfResources
.
public PdfFont getDefaultFont()
PdfFont
or null
on error.
public PdfFont addFont(PdfFont font)
PdfFont
instance to this document so that this font is flushed automatically on document close. As a side effect, the underlying font dictionary is made indirect if it wasn't the case yet
font
- a PdfFont
instance to add
public boolean registerProduct(ProductInfo productInfo)
productInfo
- product to be registered.
public FingerPrint getFingerPrint()
public PdfFont findFont(String fontProgram, String encoding)
PdfFont
from loaded fonts with corresponding fontProgram and encoding or CMAP.
fontProgram
- a font name or path to a font program
encoding
- an encoding or CMAP
protected void initTagStructureContext()
TagStructureContext
.
protected void storeLinkAnnotation(PdfPage page, PdfLinkAnnotation annotation)
page
- just copied PdfPage
link annotation belongs to.
annotation
- PdfLinkAnnotation
itself.
protected void checkIsoConformance()
protected void markObjectAsMustBeFlushed(PdfObject pdfObject)
PdfObject.MUST_BE_FLUSHED
.
pdfObject
- an object to mark.
protected void flushObject(PdfObject pdfObject, boolean canBeInObjStm) throws IOException
pdfObject
- object to flush.
canBeInObjStm
- indicates whether object can be placed into object stream.
IOException
- on error.
protected void open(PdfVersion newPdfVersion)
newPdfVersion
- new pdf version of the resultant file if stamper is used and the version needs to be changed, or null
otherwise
protected void addCustomMetadataExtensions(XMPMeta xmpMeta)
xmpMeta
- XMPMeta
to add custom metadata to.
protected void updateXmpMetadata()
protected XMPMeta updateDefaultXmpMetadata() throws XMPException
PdfDocumentInfo
.
XMPException
- if the file is not well-formed XML or if parsing fails.
protected Collection<PdfFont> getDocumentFonts()
PdfFont
.
protected void flushFonts()
protected void checkAndAddPage(int index, PdfPage page)
index
- one-base index of the page.
page
- PdfPage
to add.
protected void checkAndAddPage(PdfPage page)
page
- PdfPage
to add.
protected void checkClosingStatus()
@Deprecated protected List<ICounter> getCounters()
ICounter
instances.
ICounter
instances.
protected IPdfPageFactory getPageFactory()
IPdfPageFactory
for current document
protected void tryInitTagStructure(PdfDictionary str)
PdfStructTreeRoot
. See ISO 32000-1, section 14.7.2 Structure Hierarchy.
str
- dictionary to create structure tree root
Copyright © 1998–2023 iText Group NV. All rights reserved.