Class DocumentAssembler
- java.lang.Object
-
- com.pdftools.internal.NativeBase
-
- com.pdftools.internal.NativeObject
-
- com.pdftools.documentassembly.DocumentAssembler
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class DocumentAssembler extends NativeObject implements java.lang.AutoCloseable
The class for splitting or merging PDF documents
-
-
Constructor Summary
Constructors Constructor Description DocumentAssembler(Stream outStream)DocumentAssembler(Stream outStream, OutputOptions outOptions)DocumentAssembler(Stream outStream, OutputOptions outOptions, Conformance conformance)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappend(Document inDoc)This method copies document properties and a range of pages frominDoc.voidappend(Document inDoc, java.lang.Integer firstPage)This method copies document properties and a range of pages frominDoc.voidappend(Document inDoc, java.lang.Integer firstPage, java.lang.Integer lastPage)This method copies document properties and a range of pages frominDoc.voidappend(Document inDoc, java.lang.Integer firstPage, java.lang.Integer lastPage, DocumentCopyOptions documentCopyOptions)This method copies document properties and a range of pages frominDoc.voidappend(Document inDoc, java.lang.Integer firstPage, java.lang.Integer lastPage, DocumentCopyOptions documentCopyOptions, PageCopyOptions pageCopyOptions)This method copies document properties and a range of pages frominDoc.Documentassemble()Assemble the input documentsvoidclose()Close the object.-
Methods inherited from class com.pdftools.internal.NativeObject
equals, hashCode
-
-
-
-
Constructor Detail
-
DocumentAssembler
public DocumentAssembler(Stream outStream) throws java.io.IOException, GenericException, LicenseException
- Parameters:
outStream- The stream to which the output PDF is written- Throws:
LicenseException- The license check has failed.java.lang.IllegalArgumentException- An invalid encryption was specified in {@link com.pdftools.documentassembly.DocumentAssembler# outOptions}.java.io.IOException- Unable to write to the stream.GenericException- A generic error occurred.java.lang.IllegalArgumentException- ifoutStreamisnull
-
DocumentAssembler
public DocumentAssembler(Stream outStream, OutputOptions outOptions) throws java.io.IOException, GenericException, LicenseException
- Parameters:
outStream- The stream to which the output PDF is writtenoutOptions- The PDF output options, e.g. to encrypt the output document.- Throws:
LicenseException- The license check has failed.java.lang.IllegalArgumentException- An invalid encryption was specified in {@link com.pdftools.documentassembly.DocumentAssembler# outOptions}.java.io.IOException- Unable to write to the stream.GenericException- A generic error occurred.java.lang.IllegalArgumentException- ifoutStreamisnull
-
DocumentAssembler
public DocumentAssembler(Stream outStream, OutputOptions outOptions, Conformance conformance) throws java.io.IOException, GenericException, LicenseException
- Parameters:
outStream- The stream to which the output PDF is writtenoutOptions- The PDF output options, e.g. to encrypt the output document.conformance-The required conformance level of the PDF document. Adding pages or content from incompatible documents or using incompatible features will lead to a conformance error.
When using
null, the conformance is determined automatically, based on the conformance of the input documents used in theappend(com.pdftools.pdf.Document)method and the requirements of the used features.- Throws:
LicenseException- The license check has failed.java.lang.IllegalArgumentException- An invalid encryption was specified in {@link com.pdftools.documentassembly.DocumentAssembler# outOptions}.java.io.IOException- Unable to write to the stream.GenericException- A generic error occurred.java.lang.IllegalArgumentException- ifoutStreamisnull
-
-
Method Detail
-
append
public void append(Document inDoc) throws LicenseException, ConformanceException, ProcessingException
This method copies document properties and a range of pages frominDoc.- Parameters:
inDoc-- Throws:
LicenseException- The license check has failed.java.lang.IllegalArgumentException- ThefirstPageorlastPageare not in the allowed range.java.lang.IllegalArgumentException- If the method has already been called with any of the following properties set totrue:ConformanceException- The conformance level of the input document is not compatible with the conformance level of the output document.ConformanceException- The explicitly requested conformance level is PDF/A Level A (pdftools.pdf.Conformance.PDF_A1_A,pdftools.pdf.Conformance.PDF_A2_A, orpdftools.pdf.Conformance.PDF_A3_A) and the copy optionPageCopyOptions.getCopyLogicalStructure()is set tofalse.java.lang.IllegalStateException- Ifassemble()has already been called.ProcessingException- The processing has failed.java.lang.IllegalArgumentException- ifinDocisnull
-
append
public void append(Document inDoc, java.lang.Integer firstPage) throws LicenseException, ConformanceException, ProcessingException
This method copies document properties and a range of pages frominDoc.- Parameters:
inDoc-firstPage-Optional parameter denoting the index of the first page to be copied. This index is one-based. If set, the number must be in the range of
1(first page) topdftools.pdf.Document.getPageCount(last page).If not set,
1is used.- Throws:
LicenseException- The license check has failed.java.lang.IllegalArgumentException- ThefirstPageorlastPageare not in the allowed range.java.lang.IllegalArgumentException- If the method has already been called with any of the following properties set totrue:ConformanceException- The conformance level of the input document is not compatible with the conformance level of the output document.ConformanceException- The explicitly requested conformance level is PDF/A Level A (pdftools.pdf.Conformance.PDF_A1_A,pdftools.pdf.Conformance.PDF_A2_A, orpdftools.pdf.Conformance.PDF_A3_A) and the copy optionPageCopyOptions.getCopyLogicalStructure()is set tofalse.java.lang.IllegalStateException- Ifassemble()has already been called.ProcessingException- The processing has failed.java.lang.IllegalArgumentException- ifinDocisnull
-
append
public void append(Document inDoc, java.lang.Integer firstPage, java.lang.Integer lastPage) throws LicenseException, ConformanceException, ProcessingException
This method copies document properties and a range of pages frominDoc.- Parameters:
inDoc-firstPage-Optional parameter denoting the index of the first page to be copied. This index is one-based. If set, the number must be in the range of
1(first page) topdftools.pdf.Document.getPageCount(last page).If not set,
1is used.lastPage-Optional parameter denoting the index of the last page to be copied. This index is one-based. If set, the number must be in the range of
1(first page) topdftools.pdf.Document.getPageCount(last page).If not set,
pdftools.pdf.Document.getPageCountis used.- Throws:
LicenseException- The license check has failed.java.lang.IllegalArgumentException- ThefirstPageorlastPageare not in the allowed range.java.lang.IllegalArgumentException- If the method has already been called with any of the following properties set totrue:ConformanceException- The conformance level of the input document is not compatible with the conformance level of the output document.ConformanceException- The explicitly requested conformance level is PDF/A Level A (pdftools.pdf.Conformance.PDF_A1_A,pdftools.pdf.Conformance.PDF_A2_A, orpdftools.pdf.Conformance.PDF_A3_A) and the copy optionPageCopyOptions.getCopyLogicalStructure()is set tofalse.java.lang.IllegalStateException- Ifassemble()has already been called.ProcessingException- The processing has failed.java.lang.IllegalArgumentException- ifinDocisnull
-
append
public void append(Document inDoc, java.lang.Integer firstPage, java.lang.Integer lastPage, DocumentCopyOptions documentCopyOptions) throws LicenseException, ConformanceException, ProcessingException
This method copies document properties and a range of pages frominDoc.- Parameters:
inDoc-firstPage-Optional parameter denoting the index of the first page to be copied. This index is one-based. If set, the number must be in the range of
1(first page) topdftools.pdf.Document.getPageCount(last page).If not set,
1is used.lastPage-Optional parameter denoting the index of the last page to be copied. This index is one-based. If set, the number must be in the range of
1(first page) topdftools.pdf.Document.getPageCount(last page).If not set,
pdftools.pdf.Document.getPageCountis used.documentCopyOptions-- Throws:
LicenseException- The license check has failed.java.lang.IllegalArgumentException- ThefirstPageorlastPageare not in the allowed range.java.lang.IllegalArgumentException- If the method has already been called with any of the following properties set totrue:ConformanceException- The conformance level of the input document is not compatible with the conformance level of the output document.ConformanceException- The explicitly requested conformance level is PDF/A Level A (pdftools.pdf.Conformance.PDF_A1_A,pdftools.pdf.Conformance.PDF_A2_A, orpdftools.pdf.Conformance.PDF_A3_A) and the copy optionPageCopyOptions.getCopyLogicalStructure()is set tofalse.java.lang.IllegalStateException- Ifassemble()has already been called.ProcessingException- The processing has failed.java.lang.IllegalArgumentException- ifinDocisnull
-
append
public void append(Document inDoc, java.lang.Integer firstPage, java.lang.Integer lastPage, DocumentCopyOptions documentCopyOptions, PageCopyOptions pageCopyOptions) throws LicenseException, ConformanceException, ProcessingException
This method copies document properties and a range of pages frominDoc.- Parameters:
inDoc-firstPage-Optional parameter denoting the index of the first page to be copied. This index is one-based. If set, the number must be in the range of
1(first page) topdftools.pdf.Document.getPageCount(last page).If not set,
1is used.lastPage-Optional parameter denoting the index of the last page to be copied. This index is one-based. If set, the number must be in the range of
1(first page) topdftools.pdf.Document.getPageCount(last page).If not set,
pdftools.pdf.Document.getPageCountis used.documentCopyOptions-pageCopyOptions-- Throws:
LicenseException- The license check has failed.java.lang.IllegalArgumentException- ThefirstPageorlastPageare not in the allowed range.java.lang.IllegalArgumentException- If the method has already been called with any of the following properties set totrue:ConformanceException- The conformance level of the input document is not compatible with the conformance level of the output document.ConformanceException- The explicitly requested conformance level is PDF/A Level A (pdftools.pdf.Conformance.PDF_A1_A,pdftools.pdf.Conformance.PDF_A2_A, orpdftools.pdf.Conformance.PDF_A3_A) and the copy optionPageCopyOptions.getCopyLogicalStructure()is set tofalse.java.lang.IllegalStateException- Ifassemble()has already been called.ProcessingException- The processing has failed.java.lang.IllegalArgumentException- ifinDocisnull
-
assemble
public Document assemble()
Assemble the input documents
The input documents appended withappend(com.pdftools.pdf.Document)are assembled into the output PDF.- Returns:
- The assembled PDF, which can be used as a new input for further processing.
- Throws:
java.lang.IllegalStateException- Ifassemble()has already been called.
-
close
public void close() throws PdfToolsException, java.io.IOExceptionClose the object.
Release all resources associated with the object.- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
PdfToolsException- only explicitly stated in a superclassjava.io.IOException
-
-