Package org.apache.pdfbox.pdmodel
Class PDDocumentCatalog
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.PDDocumentCatalog
-
- All Implemented Interfaces:
COSObjectable
public class PDDocumentCatalog extends java.lang.Object implements COSObjectable
The Document Catalog of a PDF.
-
-
Field Summary
Fields Modifier and Type Field Description private PDDocumentFixup
acroFormFixupApplied
private PDAcroForm
cachedAcroForm
private PDDocument
document
private static org.apache.commons.logging.Log
LOG
private COSDictionary
root
-
Constructor Summary
Constructors Constructor Description PDDocumentCatalog(PDDocument doc)
Constructor.PDDocumentCatalog(PDDocument doc, COSDictionary rootDictionary)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addOutputIntent(PDOutputIntent outputIntent)
Add an OutputIntent to the list.PDPageDestination
findNamedDestinationPage(PDNamedDestination namedDest)
Find the page destination from a named destination.PDAcroForm
getAcroForm()
Get the documents AcroForm.PDAcroForm
getAcroForm(PDDocumentFixup acroFormFixup)
Get the documents AcroForm.PDDocumentCatalogAdditionalActions
getActions()
COSDictionary
getCOSObject()
Convert this standard java object to a COS object.PDDocumentNameDestinationDictionary
getDests()
PDDocumentOutline
getDocumentOutline()
Get the outline associated with this document or null if it does not exist.java.lang.String
getLanguage()
Returns the language for the document, or null.PDMarkInfo
getMarkInfo()
Get info about doc's usage of tagged features.PDMetadata
getMetadata()
Get the metadata that is part of the document catalog.PDDocumentNameDictionary
getNames()
PDOptionalContentProperties
getOCProperties()
Get the optional content properties dictionary associated with this document.PDDestinationOrAction
getOpenAction()
Get the Document Open Action for this object.java.util.List<PDOutputIntent>
getOutputIntents()
Get the list of OutputIntents defined in the document.PDPageLabels
getPageLabels()
Returns the page labels descriptor of the document.PageLayout
getPageLayout()
Returns the page layout.PageMode
getPageMode()
Returns the page display mode.PDPageTree
getPages()
Returns all pages in the document, as a page tree.PDStructureTreeRoot
getStructureTreeRoot()
Get the document's structure tree root, or null if none exists.java.util.List<PDThread>
getThreads()
Returns the document's article threads.PDURIDictionary
getURI()
Returns the document-level URI.java.lang.String
getVersion()
Returns the PDF specification version this document conforms to.PDViewerPreferences
getViewerPreferences()
Get the viewer preferences associated with this document or null if they do not exist.void
setAcroForm(PDAcroForm acroForm)
Sets the AcroForm for this catalog.void
setActions(PDDocumentCatalogAdditionalActions actions)
Sets the additional actions for the document.void
setDocumentOutline(PDDocumentOutline outlines)
Sets the document outlines.void
setLanguage(java.lang.String language)
Sets the Language for the document.void
setMarkInfo(PDMarkInfo markInfo)
Set information about the doc's usage of tagged features.void
setMetadata(PDMetadata meta)
Sets the metadata for this object.void
setNames(PDDocumentNameDictionary names)
Sets the names dictionary for the document.void
setOCProperties(PDOptionalContentProperties ocProperties)
Sets the optional content properties dictionary.void
setOpenAction(PDDestinationOrAction action)
Sets the Document Open Action for this object.void
setOutputIntents(java.util.List<PDOutputIntent> outputIntents)
Replace the list of OutputIntents of the document.void
setPageLabels(PDPageLabels labels)
Sets the page label descriptor for the document.void
setPageLayout(PageLayout layout)
Sets the page layout.void
setPageMode(PageMode mode)
Sets the page mode.void
setStructureTreeRoot(PDStructureTreeRoot treeRoot)
Sets the document's structure tree root.void
setThreads(java.util.List<PDThread> threads)
Sets the list of threads for this pdf document.void
setURI(PDURIDictionary uri)
Sets the document level URI.void
setVersion(java.lang.String version)
Sets the PDF specification version this document conforms to.void
setViewerPreferences(PDViewerPreferences prefs)
Sets the viewer preferences.
-
-
-
Field Detail
-
LOG
private static final org.apache.commons.logging.Log LOG
-
root
private final COSDictionary root
-
document
private final PDDocument document
-
acroFormFixupApplied
private PDDocumentFixup acroFormFixupApplied
-
cachedAcroForm
private PDAcroForm cachedAcroForm
-
-
Constructor Detail
-
PDDocumentCatalog
public PDDocumentCatalog(PDDocument doc)
Constructor. Internal PDFBox use only! If you need to get the document catalog, callPDDocument.getDocumentCatalog()
.- Parameters:
doc
- The document that this catalog is part of.
-
PDDocumentCatalog
public PDDocumentCatalog(PDDocument doc, COSDictionary rootDictionary)
Constructor. Internal PDFBox use only! If you need to get the document catalog, callPDDocument.getDocumentCatalog()
.- Parameters:
doc
- The document that this catalog is part of.rootDictionary
- The root dictionary that this object wraps.
-
-
Method Detail
-
getCOSObject
public COSDictionary getCOSObject()
Convert this standard java object to a COS object.- Specified by:
getCOSObject
in interfaceCOSObjectable
- Returns:
- The cos object that matches this Java object.
-
getAcroForm
public PDAcroForm getAcroForm()
Get the documents AcroForm. This will return null if no AcroForm is part of the document.- Returns:
- The document's AcroForm.
-
getAcroForm
public PDAcroForm getAcroForm(PDDocumentFixup acroFormFixup)
Get the documents AcroForm. This will return null if no AcroForm is part of the document. Dependent on settingacroFormFixup
some fixing/changes will be done to the AcroForm. If you need to ensure that there are no fixes applied callgetAcroForm
withnull
. UsinggetAcroForm(PDDocumentFixup acroFormFixup)
might change the original content and subsequent calls withgetAcroForm(null)
will return the changed content.- Parameters:
acroFormFixup
- the fix up action or null- Returns:
- The document's AcroForm.
-
setAcroForm
public void setAcroForm(PDAcroForm acroForm)
Sets the AcroForm for this catalog.- Parameters:
acroForm
- The new AcroForm.
-
getPages
public PDPageTree getPages()
Returns all pages in the document, as a page tree.- Returns:
- the page tree of all pages
-
getViewerPreferences
public PDViewerPreferences getViewerPreferences()
Get the viewer preferences associated with this document or null if they do not exist.- Returns:
- The document's viewer preferences.
-
setViewerPreferences
public void setViewerPreferences(PDViewerPreferences prefs)
Sets the viewer preferences.- Parameters:
prefs
- The new viewer preferences.
-
getDocumentOutline
public PDDocumentOutline getDocumentOutline()
Get the outline associated with this document or null if it does not exist.- Returns:
- The document's outline.
-
setDocumentOutline
public void setDocumentOutline(PDDocumentOutline outlines)
Sets the document outlines.- Parameters:
outlines
- The new document outlines.
-
getThreads
public java.util.List<PDThread> getThreads()
Returns the document's article threads.- Returns:
- a list containing all article threads.
-
setThreads
public void setThreads(java.util.List<PDThread> threads)
Sets the list of threads for this pdf document.- Parameters:
threads
- The list of threads, or null to clear it.
-
getMetadata
public PDMetadata getMetadata()
Get the metadata that is part of the document catalog. This will return null if there is no meta data for this object.- Returns:
- The metadata for this object.
-
setMetadata
public void setMetadata(PDMetadata meta)
Sets the metadata for this object. This can be null.- Parameters:
meta
- The meta data for this object.
-
setOpenAction
public void setOpenAction(PDDestinationOrAction action)
Sets the Document Open Action for this object.- Parameters:
action
- The action you want to perform.
-
getOpenAction
public PDDestinationOrAction getOpenAction() throws java.io.IOException
Get the Document Open Action for this object.- Returns:
- The action to perform when the document is opened.
- Throws:
java.io.IOException
- If there is an error creating the destination or action.
-
getActions
public PDDocumentCatalogAdditionalActions getActions()
- Returns:
- The Additional Actions for this Document
-
setActions
public void setActions(PDDocumentCatalogAdditionalActions actions)
Sets the additional actions for the document.- Parameters:
actions
- The actions that are associated with this document.
-
getNames
public PDDocumentNameDictionary getNames()
- Returns:
- The names dictionary for this document or null if none exist.
-
getDests
public PDDocumentNameDestinationDictionary getDests()
- Returns:
- The named destinations dictionary for this document or null if none exists.
-
findNamedDestinationPage
public PDPageDestination findNamedDestinationPage(PDNamedDestination namedDest) throws java.io.IOException
Find the page destination from a named destination.- Parameters:
namedDest
- the named destination.- Returns:
- a PDPageDestination object or null if not found.
- Throws:
java.io.IOException
- if there is an error creating the PDPageDestination object.
-
setNames
public void setNames(PDDocumentNameDictionary names)
Sets the names dictionary for the document.- Parameters:
names
- The names dictionary that is associated with this document.
-
getMarkInfo
public PDMarkInfo getMarkInfo()
Get info about doc's usage of tagged features. This will return null if there is no information.- Returns:
- The new mark info.
-
setMarkInfo
public void setMarkInfo(PDMarkInfo markInfo)
Set information about the doc's usage of tagged features.- Parameters:
markInfo
- The new MarkInfo data.
-
getOutputIntents
public java.util.List<PDOutputIntent> getOutputIntents()
Get the list of OutputIntents defined in the document.- Returns:
- The list of PDOutputIntent
-
addOutputIntent
public void addOutputIntent(PDOutputIntent outputIntent)
Add an OutputIntent to the list. If there is not OutputIntent, the list is created and the first element added.- Parameters:
outputIntent
- the OutputIntent to add.
-
setOutputIntents
public void setOutputIntents(java.util.List<PDOutputIntent> outputIntents)
Replace the list of OutputIntents of the document.- Parameters:
outputIntents
- the list of OutputIntents, if the list is empty all OutputIntents are removed.
-
getPageMode
public PageMode getPageMode()
Returns the page display mode.- Returns:
- the page mode.
-
setPageMode
public void setPageMode(PageMode mode)
Sets the page mode.- Parameters:
mode
- The new page mode.
-
getPageLayout
public PageLayout getPageLayout()
Returns the page layout.- Returns:
- the page layout.
-
setPageLayout
public void setPageLayout(PageLayout layout)
Sets the page layout.- Parameters:
layout
- The new page layout.
-
getURI
public PDURIDictionary getURI()
Returns the document-level URI.- Returns:
- the document-level URI
-
setURI
public void setURI(PDURIDictionary uri)
Sets the document level URI.- Parameters:
uri
- The new document level URI.
-
getStructureTreeRoot
public PDStructureTreeRoot getStructureTreeRoot()
Get the document's structure tree root, or null if none exists.- Returns:
- the structure tree root.
-
setStructureTreeRoot
public void setStructureTreeRoot(PDStructureTreeRoot treeRoot)
Sets the document's structure tree root.- Parameters:
treeRoot
- The new structure tree.
-
getLanguage
public java.lang.String getLanguage()
Returns the language for the document, or null.- Returns:
- the language or null.
-
setLanguage
public void setLanguage(java.lang.String language)
Sets the Language for the document.- Parameters:
language
- The new document language.
-
getVersion
public java.lang.String getVersion()
Returns the PDF specification version this document conforms to.- Returns:
- the PDF version (e.g. "1.4")
-
setVersion
public void setVersion(java.lang.String version)
Sets the PDF specification version this document conforms to.- Parameters:
version
- the PDF version (e.g. "1.4")
-
getPageLabels
public PDPageLabels getPageLabels() throws java.io.IOException
Returns the page labels descriptor of the document.- Returns:
- the page labels descriptor of the document.
- Throws:
java.io.IOException
- If there is a problem retrieving the page labels.
-
setPageLabels
public void setPageLabels(PDPageLabels labels)
Sets the page label descriptor for the document.- Parameters:
labels
- the new page label descriptor to set.
-
getOCProperties
public PDOptionalContentProperties getOCProperties()
Get the optional content properties dictionary associated with this document.- Returns:
- the optional properties dictionary or null if it is not present
-
setOCProperties
public void setOCProperties(PDOptionalContentProperties ocProperties)
Sets the optional content properties dictionary. The document version is incremented to 1.5 if lower.- Parameters:
ocProperties
- the optional properties dictionary
-
-