Class Converter
The class to convert a PDF document to a rasterized image
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertDocument(Document inDoc, Stream outStream, Profile profile) Convert all pages of a PDF document to a rasterized imageconvertPage(Document inDoc, Stream outStream, Profile profile, int pageNumber) Convert a single page of a PDF document to a rasterized imageMethods inherited from class com.pdftools.internal.NativeObject
equals, hashCode
-
Constructor Details
-
Converter
public Converter()
-
-
Method Details
-
convertDocument
public MultiPageDocument convertDocument(Document inDoc, Stream outStream, Profile profile) throws IOException, GenericException, LicenseException, UnsupportedFeatureException, ProcessingException Convert all pages of a PDF document to a rasterized image
- Parameters:
inDoc- The input PDF documentoutStream- The stream to which the rasterized image is written.profile-The profile defines how the PDF pages are rendered and what type of output image is used. Note that the profile's image options must support multi-page images (TIFF). For other profiles, the method
convertPage(com.pdftools.pdf.Document, com.pdftools.sys.Stream, com.pdftools.pdf2image.profiles.Profile, int)should be used.For details, see
profiles.Profile.- Returns:
The output image document. The object can be used as input for further processing.
Note that, this object must be disposed before the output stream object (method argument
outStream).- Throws:
LicenseException- The license is invalid.IOException- Writing to the output image failed.UnsupportedFeatureException- The input PDF is a PDF collection (Portfolio) that has no cover pages.UnsupportedFeatureException- The input PDF contains unrendered XFA form fields. Seepdftools.pdf.Document.getXfafor more information on how to detect and handle XFA documents.GenericException- An unexpected failure occurred.IllegalArgumentException- Theprofiledoes not support multi-page output.ProcessingException- The processing has failed.IllegalStateException- Internal error has occured.IllegalArgumentException- ifinDocisnullIllegalArgumentException- ifoutStreamisnullIllegalArgumentException- ifprofileisnull
-
convertPage
public Document convertPage(Document inDoc, Stream outStream, Profile profile, int pageNumber) throws IOException, GenericException, LicenseException, UnsupportedFeatureException, ProcessingException Convert a single page of a PDF document to a rasterized image
- Parameters:
inDoc- The input PDF documentoutStream- The stream to which the rasterized image is written.profile-The profile defines how the PDF page is rendered and what type of output image is used.
For details, see
profiles.Profile.pageNumber- The PDF page number to be converted. The number must be in the range of1(first page) topdftools.pdf.Document.getPageCount(last page).- Returns:
The image object allowing to open and read the output image and treat it as a new input for further processing.
Note that, this object must be disposed before the output stream object (method argument
outStream).- Throws:
LicenseException- The license is invalid.IllegalArgumentException- ThepageNumberis not in the allowed range.IOException- Writing to the output image failed.UnsupportedFeatureException- The input PDF is a collection that has no cover pages.UnsupportedFeatureException- The input PDF contains unrendered XFA form fields. Seepdftools.pdf.Document.getXfafor more information on how to detect and handle XFA documents.GenericException- An unexpected failure occurred.ProcessingException- The processing has failed.IllegalArgumentException- ifinDocisnullIllegalArgumentException- ifoutStreamisnullIllegalArgumentException- ifprofileisnull
-