Learn PDFjet for Java by example.

85 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_02

Drawing Simplified and Traditional Chinese text with the embedded IBM Plex Sans SC and TC fonts, in a PDF/UA document.

Example_03

Drawing Japanese and Korean text with the embedded IBM Plex Sans JP and KR fonts, in a PDF/UA document.

Example_04

Drawing Arabic, Hebrew, Persian and Thai text, including right to left text blocks, in a PDF/UA document.

Example_05

Fonts 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_06

Embedded 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_07

Reading 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_08

The location, ascent, descent and end point of text drawn with the TextBlock component.

Example_09

Drawing 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_10

Using the TextBlock component with a fixed height, a background color, a border, highlighted keywords and transparency, in a PDF/UA document.

Example_11

Using 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_12

Using the TextColumn component to draw centered and justified paragraphs, in IBM Plex Sans with its kerning.

Example_13

Using the addCJKParagraph method of the TextColumn class to draw Chinese paragraphs, in a PDF/UA document.

Example_14

Using the TextFrame and Paragraph components: paragraphs that mix fonts and colors, numbered paragraphs and highlighted keywords.

Example_15

Using the TextFrame class to flow text through three columns on every page, in a PDF/UA document.

Example_16

Drawing a menu with paragraphs that mix text styles and colors, raised dollar signs and a rotated label, in a PDF/UA document.

Example_17

Setting the whole novel "The Idiot" by Dostoyevsky as a book of 745 A5 pages, with a text frame that flows onto new pages.

Example_18

Paragraphs written with the inline markup of Markdown, **bold**, *italic*, `code` and [links](url), drawn in their fonts by Markup.

Example_19

A Markdown text drawn down the pages by Markdown as a PDF/UA document, with its headings, lists, quote, code, table and image tagged.

Example_20

A page of results from a CSV file of electric vehicles: two SimpleBarCharts, the five makes and the model years, a table of the same numbers under them, and a table of one car with a picture and its VIN as a barcode in their cells, in a PDF/UA document.

Example_21

Drawing 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_22

Flowing a guide to four countries onto pages with TextFlow: headings, paragraphs and maps added in order, a paragraph broken across pages between its lines, a map moved whole to the next page with its caption, and each heading kept with the text after it, in a PDF/UA document.

Example_23

Links in table cells, in a PDF/A-1a document.

Example_24

Using the BigTable class to draw a CSV file as a table: the 10-page sample, or the full data file given as the first argument, on more than 2,500 pages.

Example_25

A SimpleLineChart of the electric vehicles of the Washington State data by model year and by kind: battery electric highlighted, each line labeled at its end, a dot at each year.

Example_26

A SimpleScatterChart of the life expectancy and the children per woman of 217 countries and economies, from the World Bank's data of 2023, with the trend line and a table of the seven with the fewest children, in a PDF/UA document.

Example_27

Drawing 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_28

Drawing a donut chart from the values of its slices.

Example_29

The 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_30

Drawing 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_31

Using the Stamp and Container components to draw rotated, scaled and nested content.

Example_32

Embedding 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_33

Using 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_34

Drawing a letterhead with a logo read from a PDF file, a maple leaf drawn as a path with curves, and a QR code.

Example_35

Using 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_36

Drawing 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_37

Drawing 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_38

Drawing a PDF417 barcode that holds a whole source file, with an explanation and a caption, in a PDF/UA document.

Example_39

Drawing 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_40

Linking 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_41

Adding nested and automatically numbered bookmarks to the outline of a guide to the PDF file structure, in a PDF/UA document.

Example_42

Attaching 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_43

Using the CheckBox and RadioButton components to draw a survey.

Example_44

Using the Form and Field classes to draw a shipment request, with rows of fields and a value that continues on a second line.

Example_45

Adding a "DRAFT" watermark to every page of a two-page document that is PDF/A-3a and PDF/UA-1.

Example_46

An 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_47

Encrypting a PDF with user and owner passwords and permissions. The passwords are "hello" and "world".

Example_48

Opening an existing PDF and writing semi-transparent text on every page.

Example_49

Merging 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_50

Opening an existing PDF, stamping every page APPROVED with a date, and adding page numbers at the foot.

Example_51

BigTable with wrapping: eight columns of the Electric Vehicle data on portrait pages, the long fields wrapped onto more lines, every row as tall as its tallest field, and no column cut short or lost off the page.

Example_52

Hindi and Khmer: Java's java.awt.font shapes a page of each of the Universal Declaration of Human Rights, and drawGlyphs draws the glyphs it found as outlines, read aloud by screen readers; the text of each page attached with attachText; PDF/UA.

Example_53

An invoice of a small design studio on Letter paper: the seller and the invoice number, the customer, a table of the items that goes on to more pages with its header row on each, the subtotal, the sales tax and the total computed in BigDecimal from the items, the payment terms and "Page 1 of 1"; PDF/A-3a and PDF/UA.

Example_54

A quote to a prospective customer: the date it is valid until, the project, a table of the work in days, the subtotal, the sales tax, the total and the deposit, all computed from the day rate, the terms, and lines for the customer to sign it; PDF/A-3a and PDF/UA.

Example_55

A receipt for a payment: who paid and how, a table of what was paid for, the subtotal, the sales tax and the amount paid, and the invoice the payment settles; PDF/A-3a and PDF/UA.

Example_56

A statement of account: a table of the invoices, credit notes and payments of the period with the running balance after each, from the balance brought forward, and the balance due; PDF/A-3a and PDF/UA.

Example_57

A delivery note that goes in the box with the goods: where they go and how they travel, what was ordered and what is in this delivery, what is still to follow, the weight, and a line for the receiver to sign; no prices; PDF/UA.

Example_58

A purchase order to a supplier: the date to deliver by, the vendor and where to ship, a table of the items with the vendor's codes, the subtotal, the sales tax and the total, the terms, and who approved it; PDF/A-3a and PDF/UA.

Example_59

A business letter: the letterhead, the date, the address, the subject, the paragraphs, the closing and the signature block, each part placed under the one before it from where drawOn says it ended; PDF/UA.

Example_60

A certificate of completion of a workshop on landscape Letter paper: bands of color, the title, the name of the participant, what was completed, and the lines of the signature and the date, every line centered; PDF/UA.

Example_61

A timesheet of one week, filled in: the seven days with the hours and the work done, the total and the overtime computed in BigDecimal, and the lines where the employee and the manager sign; PDF/UA.

Example_62

A price list: a section for each kind of work, each a heading and a table that goes on to the next page with its header row, a heading never left alone at the foot of a page, and a note on taxes and quotes; PDF/UA.

Example_63

An appointment request form to print and fill in by hand: a label above each box, radio buttons that wrap onto more lines when they need to, and a shaded part the office fills in; PDF/UA.

Example_64

A new client form to print and fill in by hand: who the client is, the kind of work and the budget as lists of radio buttons side by side, the dates, and what the project should achieve; PDF/UA.

Example_65

A photo and video consent form to print and sign: the event filled in already, how the photos may be used, whether the guest may be named, and a line for a parent who signs for a child; PDF/UA.

Example_66

A contact details update form mailed to each tenant, one page a tenant as in a mail merge: the name and number printed in, the details on file in gray, and boxes for the new ones; PDF/UA.

Example_67

A credit note that takes back part of the invoice of Example_53: the invoice it corrects and why, a table of what is credited, the subtotal, the sales tax at the rate of the invoice and the total credit; PDF/A-3a and PDF/UA.

Example_68

A customer feedback card to print and fill in by hand: a grid of ratings from 1 to 5 whose radio buttons line up in columns, whether the customer would recommend the shop, and boxes for comments; PDF/UA.

Example_69

An expense report of a business trip, filled in: a table of the expenses, the total of each category and the total to pay back computed in BigDecimal, how to pay it, and the lines to sign; PDF/UA.

Example_70

An incident report form of two pages to print and fill in by hand: what happened, who was hurt, the witnesses and what was done on the first page, the supervisor's follow-up on the second, "Page 1 of 2" at the foot; PDF/UA.

Example_71

A monthly safety inspection checklist to print: a table of the items of each area, with boxes to tick when an item is in order or needs fixing and room for a note, then the problems found and the signature; PDF/UA.

Example_72

A job application form to print and fill in by hand: a box under each label, sized for handwriting, larger boxes for the address and the experience, radio buttons, check boxes and a box to sign in; PDF/UA.

Example_73

The agenda of a team meeting: when and where, who comes, the topics with the start time of each worked out from the minutes each takes, and the actions from the last meeting; PDF/UA.

Example_74

The minutes of the meeting of Example_73: who was there, what was said on each topic, the actions agreed with who and by when in a table that goes on to more pages, and the next meeting; PDF/UA.

Example_75

A membership application of a community garden to print and fill in by hand: the member, the kind of membership with its fee, what they would like to take part in, the rules to agree to, and a box to sign in; PDF/UA.

Example_76

An order form of a small shop to print and fill in by hand: a table of the items with their prices and empty cells for the size, the quantity and the amount, the subtotal, tax and total lines, and where to deliver; PDF/UA.

Example_77

A payment reminder, a letter about an invoice past due: a friendly paragraph, a small table of what was invoiced, credited and paid, the amount still open computed in BigDecimal, how to pay it, and the signature; PDF/UA.

Example_78

A pro forma invoice to a customer abroad: the date until which the prices hold, the addresses to bill and to ship to, a table of the goods, the country of origin and the weight for customs, the total, and the terms; PDF/A-3a and PDF/UA.

Example_79

A product catalog of two pages: the logo, a grid of products with SVG pictures drawn as vectors, the codes and the prices, the colors, the price list made from the same list of products, how to order, and a QR code of the shop; PDF/UA.

Example_80

A proposal to a customer: the project, the goal, a table of the phases of the work with their weeks, a table of the price, the total computed in BigDecimal, and how to go ahead; PDF/UA.

Example_81

A rental application of two pages to print and fill in by hand: the property, the applicant and where they live now, who will live there, work and income, two references, and the agreement to sign; PDF/UA.

Example_82

A time off request to print and fill in by hand: the kind of leave, the first and the last day and the signature of the employee, and a part of its own for the manager's decision; PDF/UA.

Example_83

A volunteer sign-up sheet for a clipboard: the event at the top and a table of numbered empty rows for each volunteer's name, how to reach them, the times they are free and what they would like to help with; PDF/UA.

Example_84

A workshop registration form to print and fill in by hand: who comes, the sessions with a column to tick, the lunch and the photographs, and how to pay, with a QR code of the payment page; PDF/UA.

Example_85

Shipping labels, thirty to a sheet of the common US 3 x 10 address labels: the name and the address of each customer, and a QR code of the order number for the packer to scan; PDF/UA.

©2026 PDFjet Software.

What our clients are saying:

"... I found the PDFjet source code very simple, clean, logical and easy to understand. ... The commercial version is very reasonably priced and there are NO ROYALTIES. I wish I had discovered this excellent product earlier."

Gary D. Amundson

Android Developer



On the Web:

"[PDFjet] has a simple and intuitive API and supports a wide range of PDF features, including text, images, and tables. PDFjet also has a low memory footprint, which makes it a great choice if you need to generate PDFs in a memory-constrained environment."

Docsfold (2023)



"I went for a lib called PDFJet. This is a fairly mature Java pdf library that has been ported over to .Net. It's fairly cheap and whilst it lacks a lot of in depth examples, there are quite a few available on their website. The support is really good too - if you have a question, the guys are able to provide feedback very quickly. It is very well featured, but I am basically using it to generate tables from datatables. I have been using it in earnest for about a week now, so I will try and post some examples of how it can be used here. There are two ways of creating a table with PDFJet, you can use a delimited text file holding the data you need or you can build a table programatically. Doing it in the code is tricky ... however, I am very impressed with this library and the things it can do."

Raphael's Blog