Learn PDFjet for Java by example.
50 ready-to-run examples, from a first page of text to tables thousands of pages long. Each one shows its complete source code and the PDF it creates. All of them come with PDFjet Core, ready to build and run.
Example_01
Drawing English, Greek and Bulgarian text in TextBlock components with borders, rounded corners and highlighted keywords, in a PDF/UA document.
Example_02Drawing Simplified and Traditional Chinese text with the embedded IBM Plex Sans SC and TC fonts, in a PDF/UA document.
Example_03Drawing Japanese and Korean text with the embedded IBM Plex Sans JP and KR fonts, in a PDF/UA document.
Example_04Drawing Arabic, Hebrew, Persian and Thai text, including right to left text blocks, in a PDF/UA document.
Example_05Fonts that are not embedded: the core fonts, Helvetica, Times and Courier, and Chinese, Japanese and Korean in the Adobe CJK fonts, which keep a document very small, a few kilobytes, and what they cost: the viewer supplies them, so the text does not look the same everywhere, and the document cannot be PDF/A or PDF/UA.
Example_06Embedded fonts: the same words in five weights of IBM Plex Sans, and why embedded fonts are better than the core fonts, in a PDF/UA document.
Example_07Reading fonts from .otf and .ttf files: any OpenType or TrueType file on the computer is a font for PDFjet, and a TrueType font is embedded as a subset of the glyphs a document draws.
Example_08The location, ascent, descent and end point of text drawn with the TextBlock component.
Example_09Drawing chemical formulas with CompositeTextLine: the digits of a formula are subscripts, the charge of an ion and the mass number of an isotope are superscripts, and each formula is one structure element of the tagged document.
Example_10Using the TextBlock component with a fixed height, a background color, a border, highlighted keywords and transparency, in a PDF/UA document.
Example_11Using the TextBlock component to draw a description next to each of two maps, with each row starting below the taller of the image and the text.
Example_12Using the TextColumn component to draw centered and justified paragraphs.
Example_13Using the addCJKParagraph method of the TextColumn class to draw Chinese paragraphs, in a PDF/UA document.
Example_14Using the TextFrame and Paragraph components: paragraphs that mix fonts and colors, numbered paragraphs and highlighted keywords.
Example_15Using the TextFrame class to flow text through three columns on every page, in a PDF/UA document.
Example_16Drawing a menu with paragraphs that mix text styles and colors, raised dollar signs and a rotated label, in a PDF/UA document.
Example_17Setting the whole novel "The Idiot" by Dostoyevsky as a book of 745 A5 pages, with a text frame that flows onto new pages.
Example_18Paragraphs written with the inline markup of Markdown, **bold**, *italic*, `code` and [links](url), drawn in their fonts by Markup.
Example_19A Markdown text drawn down the pages by Markdown as a PDF/UA document, with its headings, lists, quote, code, table and image tagged.
Example_20Using the Table component to draw a CSV file on several pages, with an image and a barcode in its cells and a "Page X of N" footer.
Example_21Drawing two tables: reading scores with two header rows, a header cell that spans two columns and cell background colors, and a table whose cells span columns and rows with setColSpan and setRowSpan.
Example_22Drawing a table whose cells hold text columns of English and Greek paragraphs.
Example_23Links in table cells, in a PDF/A-1a document.
Example_24Using the BigTable class to draw a large CSV file on more than 2,500 pages.
Example_25A line chart: a Chart with a Series for each line, drawn with setDrawPath, of the electric vehicles of the data file by model year and by kind.
Example_26Using the Chart component to draw a scatter chart with a trend line, and a table that lists the chart points.
Example_27Drawing bar charts: a horizontal bar chart of the ten longest rivers with its values inside the bars and a color key, and charts with vertical bars, grouped and stacked.
Example_28Drawing a donut chart from the values of its slices.
Example_29The shapes PDFjet draws, each under its name: lines with dashes and caps, rectangles with square and rounded corners, the markers of charts, an ellipse, an arc, a path of Bézier curves and a filled path, and text at every angle around a point.
Example_30Drawing with transparency: opaque and half transparent rectangles, a fill at four levels of alpha, and strokes and fills that are transparent on their own.
Example_31Using the Stamp and Container components to draw rotated, scaled and nested content.
Example_32Embedding JPEG, PNG and BMP images: a JPEG, a PNG and a BMP at their own sizes, a CMYK JPEG, then a PNG of each color type and bit depth, the two ways a PNG carries transparency, and the pHYs chunk that asks for a size.
Example_33Using the SVGImage component to draw a map of Europe scaled to fit the page, and a set of icons, each labeled with its name.
Example_34Drawing a letterhead with a logo read from a PDF file, a maple leaf drawn as a path with curves, and a QR code.
Example_35Using PDF layers (optional content groups) that can be shown or hidden: a relief map of Europe, lines of latitude and longitude that are not printed, and capital cities.
Example_36Drawing labeled Code 128, Code 39, UPC-A and EAN-13 linear barcodes, and barcodes drawn from top to bottom and from bottom to top.
Example_37Drawing two-dimensional barcodes: a QR code with each of the four error correction levels, GS1 data as a GS1 Digital Link, and Data Matrix symbols of a web address, UTF-8 text, a rectangle, a larger symbol and GS1 data.
Example_38Drawing a PDF417 barcode that holds a whole source file, with an explanation and a caption, in a PDF/UA document.
Example_39Drawing the pages of a document first and finishing them last: the contents page is drawn after the map pages but comes first, and a "Page X of N" footer goes on every page once the number of pages is known.
Example_40Linking a contents page to chapters and back with "Destinations" and "Go To" actions on text, a box and an image, in a PDF/UA document.
Example_41Adding nested and automatically numbered bookmarks to the outline of a guide to the PDF file structure, in a PDF/UA document.
Example_42Attaching an image and a source file to a page, and adding a note, a link and polygon, square and circle annotations, each next to a label.
Example_43Using the CheckBox and RadioButton components to draw a survey.
Example_44Using the Form and Field classes to draw a shipment request, with rows of fields and a value that continues on a second line.
Example_45Adding a "DRAFT" watermark to every page of a two-page document that is PDF/A-3a and PDF/UA-1.
Example_46An invoice that is also data: a PDF/A-3A document that carries factur-x.xml, as the e-invoice standards Factur-X and ZUGFeRD ask, with an SVG logo, a table of items with its totals and a QR code a banking app scans to pay.
Example_47Encrypting a PDF with user and owner passwords and permissions. The passwords are "hello" and "world".
Example_48Opening an existing PDF and writing semi-transparent text on every page.
Example_49Merging existing PDF documents into one after a cover page drawn with PDFjet, and splitting a document into one PDF for each of its pages and into its pages in reverse order.
Example_50Opening an existing PDF form and filling it in.
©2026 PDFjet Software.