When it comes to adding content to a PDF page, requirements vary widely: Sometimes it is needed to add some object like a logo, in other cases two PDF pages should be overlayed to create a final print document. There is no end to the requirements, e.g. to create a complex approval sheet that includes dynamic PDF-specific content, such as spot colors or dimension indicators, combined with job-specific information from an external source, like an MIS system or a web shop.
The good news is that almost anything is possible with pdfToolbox. The "bad" news is that it is sometimes hard to find the best approach in all of the various possibilities that pdfToolbox offers (ok, not exactly 50, but still…). While some approaches are straightforward and easy to configure, others are more complex but offer greater flexibility.
This blog post will give you an overview of the different approaches available in pdfToolbox and help you decide which one meets your needs best.
The easiest and fully interactive approach is the Switchboard.
Switchboard: Decorate Group
The "Decorate" group of the Switchboard offers several Actions to add different types of content to your PDFs, such as text, page numbers, images or logos. If you're familiar with the Switchboard, you'll know that the available Actions are very user-friendly - you only need to set a few parameters, such as the path to the file you want to place and the position on the page. You can even use "mouse selection" in many of these Actions to easily specify a custom area on a page.
Pros: Easy to use and configure.
Cons: Limited parameters available for placing content, e.g. content cannot be placed on a layer, and blend mode or transparency group settings cannot be configured.
Switchboard: Import as Layer
Another Switchboard Action is "Import as layer" ("Layers" group), which allows you to import content as a layer with a specified layer name. This is useful if the newly added content should always be placed on a separate layer.
Pros: Easy configuration; just specify the file path and the layer name.
Cons: Limited parameters. Can only be used to place PDF files and does not support multiple file formats.
So, for basic tasks like placing static content on a PDF file, the Switchboard is the way to go. For more flexibility and additional parameters to place content on a PDF file in a customized way, you should use one of the "Place Content" Fixups.
"Place content" technology in pdfToolbox
The "Place Content" technology is based on HTML templates. In some Fixups that technology is used, but the user does not have to deal with the HTML template itself. Configurable Fixups allow you to place barcodes, circles/ellipses, lines, page numbers, rectangles and text. With "Place text on path" it is even possible to place text along any path object on a PDF page (internally, this Fixup is an exception in that it uses SVG instead of HTML).
In addition to these configurable Fixups pdfToolbox comes with a set of predefined Place Content Fixups that cover common use cases such as adding dynamic text like a job ID or today's date, a color bar for CMYK, Gray or spot colors, or a small square or circle at a specific position for registration marks for cutting or printing. All of these predefined Fixups can be found in the "Shapes, Variables, JavaScript, Place content" library.
However, pdfToolbox can go much further with the "Place content on page" Fixup, which gives you access to the HTML-based layout engine inside of pdfToolbox. HTML snippets are internally converted to PDF and added to your documents. The possibilities of this engine are endless, allowing you to add complex and fully dynamic content to your PDF files. Of course this approach is also more demanding in terms of knowledge.
Pros: Super flexible and powerful Fixup. pdfToolbox already comes with predefined Fixups for common use cases. For complex use cases, you can create a custom HTML template.
Cons: Not easy to configure. Knowledge of HTML, CSS, and JavaScript is advantageous, otherwise it can be tricky to set up the Fixup.
Since this Fixup is quite powerful and complex, a deep dive into its functionality would be beyond the scope of this blog. For more detailed explanations and tutorials on "Place Content on Page" Fixups and HTML templates, we recommend the following resources:
- YouTube: Decorating PDF files with HTML
- Online documentation: Place content
The input for "Place content on page" must be a folder, because an HTML template usually consists of more than one file. In this folder you can also place a single image or PDF or any other file type that can be converted to PDF by pdfToolbox. But normally you would want to avoid using a folder in that case. In such a case you should consider to use:
Fixup "Place File on Page"
This Fixup was released with pdfToolbox 15.1 and can be used to add a file to a PDF page by referencing only the file itself (and not a folder). You may use a variable for the file, in which case the value can be, for example, a file path to a network volume where the content that you want to add is stored. Again, the file can be any of the input formats supported by pdfToolbox. It provides the same parameters as the "Place content on page" Fixup, so the placement can be configured much more precisely than with the
Pros: Supports multiple file formats and offers many parameters to configure the Fixup as needed. The file to be placed can be referenced directly in the Fixup.
Cons: Only static files can be placed (no dynamic input).