java.lang.Object
org.sejda.impl.sambox.component.PDDocumentHandler
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
PdfAlternateMixer
Wrapper over a
PDDocument.- Author:
- Andrea Vacondio
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new handler with an empty underlyingPDDocument.PDDocumentHandler(org.sejda.sambox.pdmodel.PDDocument document) Creates a new handler using the given document as underlyingPDDocument. -
Method Summary
Modifier and TypeMethodDescriptionorg.sejda.sambox.pdmodel.PDPageaddBlankPage(org.sejda.sambox.pdmodel.common.PDRectangle mediaBox) org.sejda.sambox.pdmodel.PDPageaddBlankPageAfter(int pageNumber) org.sejda.sambox.pdmodel.PDPageaddBlankPageBefore(int pageNumber) org.sejda.sambox.pdmodel.PDPageaddBlankPageIfOdd(org.sejda.sambox.pdmodel.common.PDRectangle mediaBox) Adds a blank page if the current total pages number is oddorg.sejda.sambox.pdmodel.PDPageaddPage(org.sejda.sambox.pdmodel.PDPage page) Adds the given page to the underlyingPDDocumentvoidaddWriteOption(org.sejda.sambox.output.WriteOption... opts) Adds the givenWriteOptions to be used when the document is savedorg.sejda.sambox.pdmodel.PDDocumentCatalogcatalog()voidclose()intorg.sejda.sambox.pdmodel.PDPagegetPage(int pageNumber) org.sejda.sambox.pdmodel.PDPageTreegetPages()org.sejda.sambox.pdmodel.PDDocumentorg.sejda.sambox.pdmodel.interactive.viewerpreferences.PDViewerPreferencesorg.sejda.sambox.pdmodel.PDPageimportPage(org.sejda.sambox.pdmodel.PDPage page) Creates a copy of the given page and adds it to the underlyingPDDocumentvoidinitialiseBasedOn(org.sejda.sambox.pdmodel.PDDocument other) booleanvoidmovePageToDocumentEnd(int oldPageNumber) Moves designated page to the end of the document.voidremovePage(int pageNumber) Removes the given page to the underlyingPDDocumentvoidremoveWriteOption(org.sejda.sambox.output.WriteOption... opts) Removes the givenWriteOptions to be used when the document is savedrenderImage(int pageNumber, int dpi, ImageColorType type) voidsavePDDocument(File file) voidsavePDDocument(File file, EncryptionAtRestPolicy encryptionAtRestSecurity) Saves the underlyingPDDocumentto the given file.voidsavePDDocument(File file, org.sejda.sambox.encryption.StandardSecurity security, EncryptionAtRestPolicy encryptionAtRestSecurity) Saves the underlyingPDDocumentto the given file and using the given standard security.voidsetCompress(boolean compress) sets or remove compression options to be used when the resulting document is writtenvoidset the creator on the underlyingPDDocumentvoidsetDocumentAcroForm(org.sejda.sambox.pdmodel.interactive.form.PDAcroForm acroForm) voidsetDocumentInformation(org.sejda.sambox.pdmodel.PDDocumentInformation info) Set the document information on the underlyingPDDocumentvoidsetDocumentOutline(org.sejda.sambox.pdmodel.interactive.documentnavigation.outline.PDDocumentOutline outline) voidsetDocumentTitle(String title) voidsetPageLabelsOnDocument(Map<Integer, PdfPageLabel> labels) Sets the page labels on the underlyingPDDocument.voidsetPageLayoutOnDocument(PdfPageLayout layout) Sets the given page layout on the underlyingPDDocument.voidSets the given page mode on the underlyingPDDocument.voidsetUpdateProducerModifiedDate(boolean updateProducerModifiedDate) voidsetVersionOnPDDocument(PdfVersion version) Sets the version on the underlyingPDDocument.voidsetViewerPreferences(org.sejda.sambox.pdmodel.interactive.viewerpreferences.PDViewerPreferences preferences)
-
Field Details
-
SAMBOX_USE_ASYNC_WRITER
- See Also:
-
-
Constructor Details
-
PDDocumentHandler
public PDDocumentHandler(org.sejda.sambox.pdmodel.PDDocument document) Creates a new handler using the given document as underlyingPDDocument.- Parameters:
document-
-
PDDocumentHandler
public PDDocumentHandler()Creates a new handler with an empty underlyingPDDocument.
-
-
Method Details
-
setCreatorOnPDDocument
public void setCreatorOnPDDocument()set the creator on the underlyingPDDocument -
setDocumentInformation
public void setDocumentInformation(org.sejda.sambox.pdmodel.PDDocumentInformation info) Set the document information on the underlyingPDDocument- Parameters:
info-
-
setDocumentTitle
-
getPermissions
- Returns:
- access permissions granted to this document.
-
setPageLayoutOnDocument
Sets the given page layout on the underlyingPDDocument.- Parameters:
layout-
-
setPageModeOnDocument
Sets the given page mode on the underlyingPDDocument.- Parameters:
mode-
-
setPageLabelsOnDocument
Sets the page labels on the underlyingPDDocument.- Parameters:
labels-
-
setVersionOnPDDocument
Sets the version on the underlyingPDDocument.- Parameters:
version-
-
addWriteOption
public void addWriteOption(org.sejda.sambox.output.WriteOption... opts) Adds the givenWriteOptions to be used when the document is saved- Parameters:
opts-
-
removeWriteOption
public void removeWriteOption(org.sejda.sambox.output.WriteOption... opts) Removes the givenWriteOptions to be used when the document is saved- Parameters:
opts-
-
setCompress
public void setCompress(boolean compress) sets or remove compression options to be used when the resulting document is written -
getViewerPreferences
public org.sejda.sambox.pdmodel.interactive.viewerpreferences.PDViewerPreferences getViewerPreferences()- Returns:
- the view preferences for the underlying
PDDocument.
-
setViewerPreferences
public void setViewerPreferences(org.sejda.sambox.pdmodel.interactive.viewerpreferences.PDViewerPreferences preferences) -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
savePDDocument
- Throws:
TaskException
-
savePDDocument
public void savePDDocument(File file, EncryptionAtRestPolicy encryptionAtRestSecurity) throws TaskException Saves the underlyingPDDocumentto the given file.- Parameters:
file-- Throws:
TaskException
-
savePDDocument
public void savePDDocument(File file, org.sejda.sambox.encryption.StandardSecurity security, EncryptionAtRestPolicy encryptionAtRestSecurity) throws TaskException Saves the underlyingPDDocumentto the given file and using the given standard security.- Parameters:
file-security-- Throws:
TaskException
-
getNumberOfPages
public int getNumberOfPages() -
getUnderlyingPDDocument
public org.sejda.sambox.pdmodel.PDDocument getUnderlyingPDDocument() -
catalog
public org.sejda.sambox.pdmodel.PDDocumentCatalog catalog() -
importPage
public org.sejda.sambox.pdmodel.PDPage importPage(org.sejda.sambox.pdmodel.PDPage page) Creates a copy of the given page and adds it to the underlyingPDDocument- Parameters:
page-- Returns:
- The newly created page
-
addPage
public org.sejda.sambox.pdmodel.PDPage addPage(org.sejda.sambox.pdmodel.PDPage page) Adds the given page to the underlyingPDDocument- Parameters:
page-- Returns:
- the page
-
removePage
public void removePage(int pageNumber) Removes the given page to the underlyingPDDocument- Parameters:
pageNumber-
-
movePageToDocumentEnd
public void movePageToDocumentEnd(int oldPageNumber) Moves designated page to the end of the document.- Parameters:
oldPageNumber- 1-based page number
-
getPage
public org.sejda.sambox.pdmodel.PDPage getPage(int pageNumber) -
getPages
public org.sejda.sambox.pdmodel.PDPageTree getPages() -
initialiseBasedOn
public void initialiseBasedOn(org.sejda.sambox.pdmodel.PDDocument other) -
renderImage
- Throws:
TaskException
-
setDocumentAcroForm
public void setDocumentAcroForm(org.sejda.sambox.pdmodel.interactive.form.PDAcroForm acroForm) -
addBlankPageIfOdd
public org.sejda.sambox.pdmodel.PDPage addBlankPageIfOdd(org.sejda.sambox.pdmodel.common.PDRectangle mediaBox) Adds a blank page if the current total pages number is odd- Parameters:
mediaBox- media box size for the blank page- Returns:
- the added page or null if no page has been added
-
addBlankPage
public org.sejda.sambox.pdmodel.PDPage addBlankPage(org.sejda.sambox.pdmodel.common.PDRectangle mediaBox) -
addBlankPageAfter
public org.sejda.sambox.pdmodel.PDPage addBlankPageAfter(int pageNumber) -
addBlankPageBefore
public org.sejda.sambox.pdmodel.PDPage addBlankPageBefore(int pageNumber) -
isUpdateProducerModifiedDate
public boolean isUpdateProducerModifiedDate() -
setUpdateProducerModifiedDate
public void setUpdateProducerModifiedDate(boolean updateProducerModifiedDate)
-