Skip to main content
Skip table of contents

PDF Adapter

Name

⬇️ libPDF

Version

1.5.0

Description

Gets the text from PDF documents, rotates PDF documents, adds images, manipulates PDF forms.

The PDF adapter allows for text extraction and manipulation of PDF documents and PDF forms. It is possible to add images to a PDF at a specific position, or to fill out forms elements in a PDF. These operations can be performed in three different ways:

  • Blob operations: the PDF of interest will be given as a Blob input parameter, the output will (for manipulation operations) be a new Blob containing the manipulated content.

  • File operations: the PDF of interest will be specified by an input file name, the manipulated content will (for manipulation operations) be written to a specified file.

  • Cache operations: if you want to apply several manipulations to your document, this is the way to go. Prior to working with the PDF, the file representing the document must be loaded once first. A document ID will be returned which can be subsequently used to work with the pdf and manipulate it. Finally, after work with the PDF is finished (don't forget to call the save operation), the document must be released.

For each of these ways, a separate library class is provided.

Operations

The following operations are available for all three approaches explained above:

  • getText: returns the text of a PDF document

  • rotate: rotates a document by the given degree (please be aware that rotations which are not a multiple of 90 degrees, may not work)

  • getFormsFieldNames: returns the names of all the fields that can be filled for a PDF forms document

  • setFormsField: using the name of a forms field, you can fill it by a given value

  • addImage: adds an image specified by a file name to a given position in the document

  • addResizedImage: like above, but by using a given height and with

  • addScaledImage: like addImage, but scales the image by a given scale factor

  • convertToFlatDocument: this will generate a one-layer pdf, forms fields will be replaced by their particular content

For the caching approach, there are the following methods available:

  • load: loads a PDF document specified by a filename into cache

  • save: saves a document either to a file or to a Blob

  • saveFlatDocument: like convertToFlatDocument, writes the result to a file or Blob

  • release: the document is removed from cache. MAKE SURE to call this operation after working with the document is finished

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.