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.

ParameterDescription
bytesthe PDF file content
dpithe resolution to render each page at, in dots per inch
imageTypethe 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.

ParameterDescription
inthe PDF file content
dpithe resolution to render each page at, in dots per inch
imageTypethe 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.

ParameterDescription
hashthe content hash of the stored PDF
dpithe resolution to render each page at, in dots per inch
imageTypethe 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.

ParameterDescription
hashthe content hash of the stored PDF
passwordthe password needed to open the PDF, or null if it is not encrypted
dpithe resolution to render each page at, in dots per inch
imageTypethe 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.

ParameterDescription
pdfthe PDF document to render
dpithe resolution to render each page at, in dots per inch
imageTypethe 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.

ParameterDescription
pdfthe PDF document to render
passwordunused; the document is expected to already be loaded and decrypted
dpithe resolution to render each page at, in dots per inch
imageTypethe 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.

ParameterDescription
hashthe content hash of the stored PDF
pageIndexthe zero-based index of the page to render
dpithe resolution to render the page at, in dots per inch
imageTypethe 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.

ParameterDescription
hashthe content hash of the stored PDF
passwordpassword to be used for decryption, or null if the PDF is not encrypted
pageIndexthe zero-based index of the page to be converted
dpithe DPI (dots per inch) to render at
imageTypethe 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.

ParameterDescription
imageHashesthe 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.

ParameterDescription
hrefsthe 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.

ParameterDescription
sourcethe 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.

ParameterDescription
pagethe resource the view is rendered for
sourcethe 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.

ParameterDescription
bytesthe PDF file content

getNumberOfPages(InputStream in)

Returns: int

Counts the pages in a PDF read from a stream, by loading it with PDFBox.

ParameterDescription
inthe 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".

ParameterDescription
fieldthe field to describe, may be null

pdfToText(byte[] bytes)

Returns: String

Extracts the plain text content of a PDF held in memory.

ParameterDescription
bytesthe 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.

ParameterDescription
inthe PDF file content

pdfToHtml(byte[] bytes)

Returns: String

Converts a PDF held in memory to an HTML representation of its text content.

ParameterDescription
bytesthe 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.

ParameterDescription
inthe PDF file content
To get full access to the Kademi Hub existing customers can login here, or new customers can register here.