Generates, reads and rasterises PDF documents for the platform's stored files, wrapping PDFBox behind the platform's blob store and hash store. Reached from JS via fileManager.getPdfManager(). Covers rendering page thumbnails, extracting text or HTML from a PDF, assembling a PDF from a set of images, and converting rendered HTML pages or hrefs into a PDF via the platform's PdfGenerator. Generated and processed output is stored through the BlobStore and HashStore supplied at construction, in the same way as other stored content.
Methods
generatePdfThumbnailsBase64(byte[] bytes, int dpi, String imageType) · generatePdfThumbnailsBase64(InputStream in, int dpi, String imageType) · generatePdfThumbnails(String hash, int dpi, String imageType) · generatePdfThumbnails(String hash, String password, int dpi, String imageType) · generatePdfThumbnails(PdfDocument pdf, int dpi, String imageType) · generatePdfThumbnails(PdfDocument pdf, String password, int dpi, String imageType) · generatePdfThumbnail(String hash, int pageIndex, int dpi, String imageType) · generatePdfThumbnail(String hash, String password, int pageIndex, int dpi, String imageType) · generatePdfFromImages(String[] imageHashes) · generatePdfFromHrefs(String hrefs) · generatePdfFromResource(GetableResource source) · generatePdfFromResource(CommonResource page, View source) · getNumberOfPages(byte[] bytes) · getNumberOfPages(InputStream in) · getFieldType(PDField field) · pdfToText(byte[] bytes) · pdfToText(InputStream in) · pdfToHtml(byte[] bytes) · pdfToHtml(InputStream in)
generatePdfThumbnailsBase64(byte[] bytes, int dpi, String imageType)
Returns: List<String>
Renders every page of a PDF held in memory to an image and returns the images as base64-encoded strings, in page order. Unlike generatePdfThumbnails, the images are returned directly rather than being stored in the blob store.
| Parameter | Description |
|---|---|
bytes | the PDF file content |
dpi | the resolution to render each page at, in dots per inch |
imageType | the target image format, for example "png" |
generatePdfThumbnailsBase64(InputStream in, int dpi, String imageType)
Returns: List<String>
Renders every page of a PDF read from a stream to an image and returns the images as base64-encoded strings, in page order. Unlike generatePdfThumbnails, the images are returned directly rather than being stored in the blob store.
| Parameter | Description |
|---|---|
in | the PDF file content |
dpi | the resolution to render each page at, in dots per inch |
imageType | the target image format, for example "png"; must be a format supported by ImageIO |
generatePdfThumbnails(String hash, int dpi, String imageType)
Returns: List<String>
Renders every page of a stored PDF to an image and stores each rendered page, using no password to open the PDF.
| Parameter | Description |
|---|---|
hash | the content hash of the stored PDF |
dpi | the resolution to render each page at, in dots per inch |
imageType | the target image format, for example "png" |
generatePdfThumbnails(String hash, String password, int dpi, String imageType)
Returns: List<String>
Renders every page of a stored, possibly password-protected PDF to an image and stores each rendered page.
| Parameter | Description |
|---|---|
hash | the content hash of the stored PDF |
password | the password needed to open the PDF, or null if it is not encrypted |
dpi | the resolution to render each page at, in dots per inch |
imageType | the target image format, for example "png" |
generatePdfThumbnails(PdfDocument pdf, int dpi, String imageType)
Returns: List<String>
Renders every page of an already-loaded PDF document to an image and stores each rendered page. Closes the given document once rendering is complete.
| Parameter | Description |
|---|---|
pdf | the PDF document to render |
dpi | the resolution to render each page at, in dots per inch |
imageType | the target image format, for example "png" |
generatePdfThumbnails(PdfDocument pdf, String password, int dpi, String imageType)
Returns: List<String>
Renders every page of an already-loaded PDF document to an image and stores each rendered page. Closes the given document once rendering is complete. The password parameter is not used to open the document, which is expected to already be open.
| Parameter | Description |
|---|---|
pdf | the PDF document to render |
password | unused; the document is expected to already be loaded and decrypted |
dpi | the resolution to render each page at, in dots per inch |
imageType | the target image format, for example "png" |
generatePdfThumbnail(String hash, int pageIndex, int dpi, String imageType)
Returns: String
Renders a single page of a stored PDF to an image and stores the result, using no password to open the PDF.
| Parameter | Description |
|---|---|
hash | the content hash of the stored PDF |
pageIndex | the zero-based index of the page to render |
dpi | the resolution to render the page at, in dots per inch |
imageType | the target image format, for example "png" |
generatePdfThumbnail(String hash, String password, int pageIndex, int dpi, String imageType)
Returns: String
Renders a single page of a stored, possibly password-protected PDF to an image and stores the result.
| Parameter | Description |
|---|---|
hash | the content hash of the stored PDF |
password | password to be used for decryption, or null if the PDF is not encrypted |
pageIndex | the zero-based index of the page to be converted |
dpi | the DPI (dots per inch) to render at |
imageType | the target format, for example "png" |
generatePdfFromImages(String[] imageHashes)
Returns: String
Generates a new PDF from a list of stored images, placing one image per page in the given order, and stores the result.
| Parameter | Description |
|---|---|
imageHashes | the content hashes of the source images, in the order they should appear as pages |
generatePdfFromHrefs(String hrefs)
Returns: String
Renders one or more pages identified by href and combines them into a single PDF, which is stored.
| Parameter | Description |
|---|---|
hrefs | the hrefs of the pages to render and combine into the PDF |
generatePdfFromResource(GetableResource source)
Returns: String
Renders a single resource to HTML and converts it into a PDF, which is stored.
| Parameter | Description |
|---|---|
source | the resource to render and convert |
generatePdfFromResource(CommonResource page, View source)
Returns: String
Renders a view for a given page resource to HTML and converts the result into a PDF, which is stored.
| Parameter | Description |
|---|---|
page | the resource the view is rendered for |
source | the view used to render the page |
getNumberOfPages(byte[] bytes)
Returns: int
Counts the pages in a PDF held in memory, by loading it with PDFBox.
| Parameter | Description |
|---|---|
bytes | the PDF file content |
getNumberOfPages(InputStream in)
Returns: int
Counts the pages in a PDF read from a stream, by loading it with PDFBox.
| Parameter | Description |
|---|---|
in | the PDF file content |
getFieldType(PDField field)
Returns: String
A short type name for an AcroForm field, derived from its PDFBox class name with the leading "PD" stripped, for example "TextField" or "CheckBox".
| Parameter | Description |
|---|---|
field | the field to describe, may be null |
pdfToText(byte[] bytes)
Returns: String
Extracts the plain text content of a PDF held in memory.
| Parameter | Description |
|---|---|
bytes | the PDF file content |
pdfToText(InputStream in)
Returns: String
Extracts the plain text content of a PDF read from a stream. The stream is copied to a temporary file before parsing, which is deleted afterwards.
| Parameter | Description |
|---|---|
in | the PDF file content |
pdfToHtml(byte[] bytes)
Returns: String
Converts a PDF held in memory to an HTML representation of its text content.
| Parameter | Description |
|---|---|
bytes | the PDF file content |
pdfToHtml(InputStream in)
Returns: String
Converts a PDF read from a stream to an HTML representation of its text content. The stream is copied to a temporary file before parsing, which is deleted afterwards.
| Parameter | Description |
|---|---|
in | the PDF file content |