PDFjet C# Examples

Each example links to its source code and to the PDF file it creates. The linked PDF files are created by the Java examples, which produce the same documents. To create the PDF files with the C# examples, run the build-dotnet.cmd or build-dotnet.sh script.

  1. Example_01.cs  Example_01.pdf   Drawing English, Greek and Bulgarian text in TextBlock components with borders, rounded corners and highlighted keywords, in a PDF/UA document.
  2. Example_02.cs  Example_02.pdf   Drawing Simplified and Traditional Chinese text with the embedded IBM Plex Sans SC and TC fonts, in a PDF/UA document.
  3. Example_03.cs  Example_03.pdf   Drawing Japanese and Korean text with the embedded IBM Plex Sans JP and KR fonts, in a PDF/UA document.
  4. Example_04.cs  Example_04.pdf   Drawing Arabic, Hebrew, Persian and Thai text, including right to left text blocks, in a PDF/UA document.
  5. Example_05.cs  Example_05.pdf   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.
  6. Example_06.cs  Example_06.pdf   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.
  7. Example_07.cs  Example_07.pdf   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.
  8. Example_08.cs  Example_08.pdf   The location, ascent, descent and end point of text drawn with the TextBlock component.
  9. Example_09.cs  Example_09.pdf   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.
  10. Example_10.cs  Example_10.pdf   Using the TextBlock component with a fixed height, a background color, a border, highlighted keywords and transparency, in a PDF/UA document.
  11. Example_11.cs  Example_11.pdf   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.
  12. Example_12.cs  Example_12.pdf   Using the TextColumn component to draw centered and justified paragraphs, in IBM Plex Sans with its kerning.
  13. Example_13.cs  Example_13.pdf   Using the AddCJKParagraph method of the TextColumn class to draw Chinese paragraphs, in a PDF/UA document.
  14. Example_14.cs  Example_14.pdf   Using the TextFrame and Paragraph components: paragraphs that mix fonts and colors, numbered paragraphs and highlighted keywords.
  15. Example_15.cs  Example_15.pdf   Using the TextFrame class to flow text through three columns on every page, in a PDF/UA document.
  16. Example_16.cs  Example_16.pdf   Drawing a menu with paragraphs that mix text styles and colors, raised dollar signs and a rotated label, in a PDF/UA document.
  17. Example_17.cs  Example_17.pdf   Setting the whole novel "The Idiot" by Dostoyevsky as a book of 745 A5 pages, with a text frame that flows onto new pages.
  18. Example_18.cs  Example_18.pdf   Paragraphs written with the inline markup of Markdown, **bold**, *italic*, `code` and [links](url), drawn in their fonts by Markup.
  19. Example_19.cs  Example_19.pdf   A Markdown text drawn down the pages by Markdown as a PDF/UA document, with its headings, lists, quote, code, table and image tagged.
  20. Example_20.cs  Example_20.pdf   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.
  21. Example_21.cs  Example_21.pdf   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.
  22. Example_22.cs  Example_22.pdf   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.
  23. Example_23.cs  Example_23.pdf   Links in table cells, in a PDF/A-1a document.
  24. Example_24.cs  Example_24.pdf   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.
  25. Example_25.cs  Example_25.pdf   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.
  26. Example_26.cs  Example_26.pdf   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.
  27. Example_27.cs  Example_27.pdf   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.
  28. Example_28.cs  Example_28.pdf   Drawing a donut chart from the values of its slices.
  29. Example_29.cs  Example_29.pdf   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.
  30. Example_30.cs  Example_30.pdf   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.
  31. Example_31.cs  Example_31.pdf   Using the Stamp and Container components to draw rotated, scaled and nested content.
  32. Example_32.cs  Example_32.pdf   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.
  33. Example_33.cs  Example_33.pdf   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.
  34. Example_34.cs  Example_34.pdf   Drawing a letterhead with a logo read from a PDF file, a maple leaf drawn as a path with curves, and a QR code.
  35. Example_35.cs  Example_35.pdf   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.
  36. Example_36.cs  Example_36.pdf   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.
  37. Example_37.cs  Example_37.pdf   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.
  38. Example_38.cs  Example_38.pdf   Drawing a PDF417 barcode that holds a whole source file, with an explanation and a caption, in a PDF/UA document.
  39. Example_39.cs  Example_39.pdf   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.
  40. Example_40.cs  Example_40.pdf   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.
  41. Example_41.cs  Example_41.pdf   Adding nested and automatically numbered bookmarks to the outline of a guide to the PDF file structure, in a PDF/UA document.
  42. Example_42.cs  Example_42.pdf   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.
  43. Example_43.cs  Example_43.pdf   Using the CheckBox and RadioButton components to draw a survey.
  44. Example_44.cs  Example_44.pdf   Using the Form and Field classes to draw a shipment request, with rows of fields and a value that continues on a second line.
  45. Example_45.cs  Example_45.pdf   Adding a "DRAFT" watermark to every page of a two-page document that is PDF/A-3a and PDF/UA-1.
  46. Example_46.cs  Example_46.pdf   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.
  47. Example_47.cs  Example_47.pdf   Encrypting a PDF with user and owner passwords and permissions. The passwords are "hello" and "world".
  48. Example_48.cs  Example_48.pdf   Opening an existing PDF and writing semi-transparent text on every page.
  49. Example_49.cs  Example_49.pdf   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.
  50. Example_50.cs  Example_50.pdf   Opening an existing PDF, stamping every page APPROVED with a date, and adding page numbers at the foot.
  51. Example_51.cs  Example_51.pdf   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.
  52. Example_52.cs  Example_52.pdf   Hindi and Khmer: HarfBuzz (the HarfBuzzSharp package) 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.
  53. Example_53.cs  Example_53.pdf   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.
  54. Example_54.cs  Example_54.pdf   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.
  55. Example_55.cs  Example_55.pdf   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.
  56. Example_56.cs  Example_56.pdf   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.
  57. Example_57.cs  Example_57.pdf   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.
  58. Example_58.cs  Example_58.pdf   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.
  59. Example_59.cs  Example_59.pdf   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.
  60. Example_60.cs  Example_60.pdf   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.
  61. Example_61.cs  Example_61.pdf   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.
  62. Example_62.cs  Example_62.pdf   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.
  63. Example_63.cs  Example_63.pdf   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.
  64. Example_64.cs  Example_64.pdf   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.
  65. Example_65.cs  Example_65.pdf   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.
  66. Example_66.cs  Example_66.pdf   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.
  67. Example_67.cs  Example_67.pdf   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.
  68. Example_68.cs  Example_68.pdf   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.
  69. Example_69.cs  Example_69.pdf   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.
  70. Example_70.cs  Example_70.pdf   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.
  71. Example_71.cs  Example_71.pdf   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.
  72. Example_72.cs  Example_72.pdf   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.
  73. Example_73.cs  Example_73.pdf   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.
  74. Example_74.cs  Example_74.pdf   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.
  75. Example_75.cs  Example_75.pdf   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.
  76. Example_76.cs  Example_76.pdf   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.
  77. Example_77.cs  Example_77.pdf   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.
  78. Example_78.cs  Example_78.pdf   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.
  79. Example_79.cs  Example_79.pdf   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.
  80. Example_80.cs  Example_80.pdf   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.
  81. Example_81.cs  Example_81.pdf   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.
  82. Example_82.cs  Example_82.pdf   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.
  83. Example_83.cs  Example_83.pdf   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.
  84. Example_84.cs  Example_84.pdf   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.
  85. Example_85.cs  Example_85.pdf   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.