The Xojo VNS FPDF Thread

Followup to the first Xojo FPDF port in the november contest here:

Xojo FPDF v1.1.1 - Major Update: Drop-in PDFDocument Replacement + Premium Modules

Hi everyone,

Big update on Xojo FPDF! Lots of new features, important bug fixes thanks to community testing, and the premium modules are now available on the website.
The github repo for free files is here :


VNSPDFDocument - True Drop-in Replacement for Xojo PDFDocument

The headline feature of this release: VNSPDFDocument is now fully compatible with Xojo’s native PDFDocument API. You can migrate with minimal code changes:

// Before (Xojo PDFDocument)
Dim pdf As New PDFDocument(PDFDocument.PageSizes.A4)
pdf.Title = "My Document"
Dim g As Graphics = pdf.Graphics
g.DrawingColor = Color.Blue
g.FillRectangle(100, 100, 200, 50)
g.LineCap = Graphics.LineCapTypes.Round
g.LineDash = Array(5.0, 5.0)
g.DrawText("Hello World", 100, 200)
pdf.Save(file)

// After (VNS PDF) - Nearly identical!
Dim pdf As New VNSPDFDocument()
pdf.Title = "My Document"
Dim g As VNSPDFGraphics = pdf.Graphics  // Only type name changes
g.DrawingColor = Color.Blue
g.FillRectangle(100, 100, 200, 50)
g.LineCap = Graphics.LineCapTypes.Round  // Same Xojo enums!
g.LineDash = Array(5.0, 5.0)            // Same syntax!
g.DrawText("Hello World", 100, 200)
pdf.Save(file)

Same properties: Title, Author, Subject, Keywords, Creator, Language, CurrentPage, PageHeight, PageWidth, Landscape, Compressed, Graphics

Same methods: Save(file), ToData(), AddFonts(), ClearCache(), Template()

VNSPDFGraphics is 100% complete - all 43 features from Xojo’s PDFGraphics API work:

  • Drawing: DrawLine, DrawRectangle, FillRectangle, DrawOval, FillOval, DrawPolygon, FillPolygon, DrawPath, FillPath, DrawPicture
  • Text: DrawText (with rotation), DrawTextBlock (word-wrap with CJK support), TextWidth, TextHeight
  • Object2D: RectShape, OvalShape, RoundRectShape, ArcShape, CurveShape, FigureShape, TextShape (with HorizontalAlignment), PixmapShape, Group2D (with rotation)
  • Transforms: Rotate, Translate, Scale, Transform (matrix)
  • State: SaveState, RestoreState
  • Clipping: ClipToRectangle, ClipEnd
  • Properties: Bold, Italic, Underline, FontName, FontSize, DrawingColor, PenSize, LineCap, LineJoin, LineDash, Brush

But you also get everything Xojo PDFDocument can’t do - on the same object:

// Advanced FPDF methods available on VNSPDFDocument
pdf.AddUTF8Font("Arial", "", fontPath)           // Full Unicode
pdf.MultiCell(180, 5, longText, "1", "J", False)  // Justified text
pdf.ImportPage(sourcePDF, 1)                       // PDF import
pdf.SetProtection("user", "owner", perms, 3)      // Encryption
pdf.AddAttachment("data.xml", xmlContent, "desc")  // File attachments

File Attachments - E-Invoice Ready

You can now embed files directly in your PDFs, both at the document level (visible in the PDF sidebar) and as clickable page annotations:

// Document-level attachment
pdf.AddAttachment("factur-x.xml", xmlInvoice, "Factur-X invoice data")

// Clickable icon on a specific page
pdf.AddAttachmentAnnotation("data.xml", xmlContent, 150, 20, 10, 10, "Click to open")

This is the foundation for Factur-X/ZUGFeRD hybrid PDF/XML e-invoicing.


Multi-Stop Gradients

Complex gradients with unlimited color stops, plus full Xojo Brush support:

// Rainbow gradient
Dim stops() As Pair
stops.Add(0.0 : Color.Red)
stops.Add(0.25 : Color.Yellow)
stops.Add(0.5 : Color.Green)
stops.Add(0.75 : Color.Cyan)
stops.Add(1.0 : Color.Blue)
pdf.LinearGradientMultiStop(10, 10, 180, 40, stops, 0, 0, 1, 0)

// Or use Xojo-compatible Brush property
Dim lgb As New LinearGradientBrush
lgb.GradientStops.Add(0.0 : Color.Red)
lgb.GradientStops.Add(1.0 : Color.Blue)
g.Brush = lgb
g.FillRectangle(10, 60, 100, 40)

LinearGradientBrush, RadialGradientBrush, and PictureBrush are all supported.


Complete Transformation Suite

All 18 transformation methods are now implemented: TransformRotate, TransformScale, TransformTranslate, TransformMirrorHorizontal, TransformMirrorVertical, TransformMirrorPoint, TransformMirrorLine, TransformSkew, and more. Example 21 demonstrates every single one.


Bounds Checking

New optional safety feature - catch drawing operations outside page boundaries:

VNSPDFModule.gkRaiseExceptionOnOutOfBounds = True
pdf.Rect(-10, -10, 100, 100)  // Raises RuntimeException!

Affected methods: Rect, Line, Ellipse, Image, Text, Cell, MultiCell, annotations. In normal mode it logs warnings via System.DebugLog without interrupting execution.


Bug Fixes Thanks to Community Feedback

A big thank you to the Xojo users who tested the library on their machines and reported real-world issues. Their feedback led to five important fixes:

MultiCell single-line bottom border - A single-line MultiCell with border=1 was missing its bottom border on all platforms. Fixed.

First character missing in long word wrapping - When a long word wrapped to the next line, the first character was dropped. Classic off-by-one error, now fixed.

Newlines ignored in MultiCell - Explicit newlines (Chr(10)) and CRLF sequences were completely ignored, all text appeared on one line. SplitTextToLines now handles paragraph breaks properly.

MultiCell positioning - The cell following a MultiCell was offset to the right instead of returning to the left margin. Cursor position now resets correctly.

ImageFromPicture corruption on Windows and Linux - The most visible bug. ImageFromPicture produced corrupted images (multi-colored noise) on Windows 11 and Linux. Root cause: Picture.ToData(PNG) on these platforms produces RGBA (4 channels) while PDF expects RGB (3 channels). Fix: force JPEG format on Windows/Linux - JPEG auto-converts RGBA to RGB cleanly. Verified on macOS, Windows 11, and Ubuntu 22.04 ARM64.

Example 26 provides a visual test suite for all five fixes.


Premium Modules Now Available

The first three premium modules are ready and available on the website: Premium Modules - Professional PDF Features

Encryption Module - EUR 50

AES-256/128 encryption with dual password protection and granular permissions (print, copy, modify, annotate, etc.). The free core only includes RC4-40 (40-bit). If you handle sensitive documents, you need at least AES-128.

Table Module - EUR 50

Three table engines (SimpleTable, ImprovedTable, FancyTable) with automatic column sizing, auto pagination with header repetition, alternating row colors, and smart number alignment. What takes 50+ lines of Cell() calls takes one line with this module.

Zlib Module - EUR 50

Pure Xojo deflate/inflate compression (27-60% file size reduction). Particularly important for iOS developers: without this module, iOS PDFs have zero compression while Desktop PDFs get 27-60% reduction. This module eliminates that gap completely.

Bundle: Buy 2, Get 1 Free = EUR 100

Every module includes:

  • Full source code (unencrypted, readable, modifiable)
  • Lifetime license, no subscriptions
  • All platforms (Desktop, Web, iOS, Console)
  • 12 months free updates
  • Payment via PayPal, delivery within 2-3 business days

Current Status

Xojo FPDF v1.1.1 - Production release

  • 23 working examples covering all features
  • Cross-platform: Desktop, Web, iOS, Console (Xojo 2025r3.1 API2)
  • Drop-in replacement for Xojo’s PDFDocument
  • Full UTF-8 with Arabic text shaping and CJK wrapping
  • PDF Import, File Attachments, Encryption, Multi-Stop Gradients
  • 100% open source core (MIT license)

Coming next:

  • PDF/A Module - ISO-compliant archival PDFs
  • Forms Module - Interactive AcroForms
  • E-Invoice Module - Factur-X/ZUGFeRD compliance

Questions? Just ask in this thread. And keep the bug reports coming - community feedback directly improves the library for everyone.

11 Likes

Really nice! Any chance of getting html → pdf soon? And preferably not with some outdated code.

2 Likes

Yes.
but it will be a “simple” one : styled text, lists, tables, pictures only at first release
mainly for outputting some html text to a pdf (not a full web page with javascript or so)
and it will be a premium module.
as you get the full source code you will be able to add your own processing in it.

edit: I will also provide a free compiled app to select your html file and see how it gets converted to pdf.

2 Likes

That’s a good start but my html is as complex as it gets.

1 Like

you will be able to add your own html tags

 //Custom HTML Tags

 pdf.RegisterHTMLTagHandler("company-header", AddressOf CompanyHeaderHandler)
 pdf.LoadHTML("<company-header>ACME Corp</company-header><p>Hello world</p>")

 Sub CompanyHeaderHandler(doc As VNSPDFDocument, token As VNSPDFHTMLToken, isClosing As Boolean)
   If Not isClosing Then
     doc.SetFont("Helvetica", "B", 20)
     doc.SetTextColor(0, 0, 128)
   Else
     doc.Ln(8)
     doc.SetFont("Helvetica", "", 10)
     doc.SetTextColor(0, 0, 0)
   End If
 End Sub

The problem aren’t the tags but the html itself. Have a look at some random newsletters. These usually have complex CSS and nested tables.

the purpose of this converter is to convert html YOU build
not print any html you may receive, it’s indeed too much complicated
the existing html to pdf converters are millions of lines of code
I certainly don"t intend to replace these


1 Like

Xojo FPDF v1.2 - Digital Signatures, E-Invoicing, Barcodes, HTML/Markdown Import, PDF Preview & More

Follow-up to the v1.1.1 January 2026 announcement

Hi everyone,

Major release! Version 1.2 brings digital signatures validated by Adobe Acrobat, a complete EU e-invoicing module, 10 barcode types with vector rendering, HTML and Markdown to PDF conversion, an in-app PDF preview window, and much more. Here’s everything that changed since v1.1.


Digital Signatures - Adobe Acrobat Validated (Encryption Premium Module)

The big one. You can now digitally sign PDFs with PAdES-B-B signatures that Adobe Acrobat Reader validates as authentic:

Dim pdf As New VNSPDFDocument
pdf.SetFont("Helvetica", "", 12)
pdf.Cell(0, 10, "This document is digitally signed.")

// Sign with your certificate
VNSPDFSignature.SignPDF(pdf, certDER, privateKeyDER, _
    "Jean-Yves", "Contract approval", "Paris, France")
pdf.Save(outputFile)

What’s under the hood:

  • PAdES-B-B (PDF Advanced Electronic Signatures) per ETSI EN 319 142-1
  • XAdES-BES (XML Advanced Electronic Signatures) for signing CII XML in e-invoices
  • Pure Xojo RSA PKCS#1 v1.5 signing - no OpenSSL, no declares, no external dependencies
  • CRT optimization for fast 2048-bit RSA (~12x speedup over naive modular exponentiation)
  • CMS/PKCS#7 SignedData with ESS signing-certificate-v2 per RFC 5652
  • ASN.1 DER encoder/decoder, X.509 certificate parser, W3C C14N XML canonicalization
  • 7 new classes: VNSASN1, VNSX509Certificate, VNSPKCS7Signer, VNSPDFSignature, VNSXMLCanonicalizer, VNSXAdESSigner, VNSRSASigner

All pure Xojo. Works on Desktop, Web, iOS, and Console.


E-Invoice Premium Module - EU-Compliant Factur-X/ZUGFeRD

The EU ViDA directive mandates structured electronic invoicing for B2B transactions starting 2026-2027. This module handles both creating and reading compliant invoices:

Creating E-Invoices

Dim invoice As New VNSPDFEInvoice
invoice.InvoiceNumber = "INV-2026-001"
invoice.InvoiceDate = New DateTime(2026, 2, 14)
invoice.Currency = "EUR"
// ... set seller, buyer, line items, tax breakdowns ...

Dim pdf As New VNSPDFDocument
// ... add visual invoice layout ...

VNSPDFEInvoicePremium.CreateFacturXInvoice(pdf, invoice, _
    VNSPDFEInvoicePremium.eFacturXProfile.EN16931)
pdf.Save("invoice.pdf")

Generates a PDF/A-3b document with embedded CII XML per EN 16931. Self-contained: sRGB ICC output intent, XMP metadata with Factur-X extension schemas. No dependency on the PDF/A premium module.

Reading & Verifying E-Invoices

Open any PDF and check if it’s a valid Factur-X/ZUGFeRD invoice:

Dim result As JSONItem = VNSPDFEInvoicePremium.ReadEInvoice("/path/to/invoice.pdf")

If result.Value("valid") = True Then
  Dim inv As JSONItem = result.Value("invoice")
  // Access invoiceNumber, seller, buyer, lineItems, totals...
End If

// Also detects digital signatures
Dim sigCount As Integer = result.Value("signatureCount")
If sigCount > 0 Then
  Dim sigs As JSONItem = result.Value("signatures")
  // signer name, hash validity, certificate info, self-signed detection...
End If

Features:

  • 5 conformance profiles: MINIMUM, BASIC WL, BASIC, EN 16931, EXTENDED
  • Profile-aware validation with EU Business Term references (BT-1, BT-2, etc.)
  • XML validation warnings: comma-as-decimal detection, date format checks, currency/country code validation
  • Error codes (EINV-000 to EINV-004) for programmatic handling
  • Digital signature detection: SHA-256 hash verification, ByteRange coverage check, X.509 certificate subject/issuer, self-signed detection
  • Type-safe enums: eTaxCategoryCode (UNTDID 5305), eFacturXProfile, eInvoiceJSONKey with extension methods

Free Standalone App

We provide a free compiled VNS E-Invoicer app (macOS, Windows, Linux) so you can test e-invoice creation, reading, and validation on your own PDFs before purchasing the module. Don’t hesitate to try it with your own e-invoice PDFs and report here if you find files that don’t behave correctly!


HTML & Markdown to PDF (Premium Module)

Convert HTML or Markdown files to formatted PDFs:

Dim pdf As New VNSPDFDocument
pdf.LoadHTML(htmlContent)
pdf.Save("output.pdf")

// Or Markdown
pdf.LoadMarkdown(markdownContent)
pdf.Save("output.pdf")

HTML Support

Full tag support: p, h1-h6, b/strong, i/em, u, s/del/strike, br, hr, img, table, ul/ol/li, blockquote, code/pre, span, font, a, sub/sup. Inline CSS for font-size, color, background-color, text-decoration, font-family. Handles Word/Summernote HTML with automatic cleanup (68% size reduction on messy HTML).

Markdown Support

Headings, bold, italic, strikethrough, code blocks, lists, links, images, blockquotes, horizontal rules, tables.

Extensible

Register custom tag handlers for HTML or custom syntax handlers for Markdown:

pdf.RegisterHTMLTagHandler("custom-tag", AddressOf MyCustomHandler)
pdf.RegisterMarkdownHandler("^!!!(.+)", AddressOf MyAlertHandler)

Free Standalone Apps

We provide free compiled binaries of HtmlToPdf and MarkdownToPdf (macOS, Windows, Linux) so you can test conversion on your own files before purchasing the module. Don’t hesitate to try them with your own HTML and Markdown files and report here if you find content that doesn’t render correctly!


PDF Preview Window (Desktop)

Thanks to a contribution from Valdemar de Sousa, the library now includes an in-app PDF preview window:

  • Modal window with rendered PDF pages
  • Thumbnail sidebar navigation
  • Zoom and pan controls
  • Save and print buttons
  • Cross-platform page rendering: macOS PDFKit, Windows PowerShell+Windows.Data.Pdf, Linux Poppler

All 33 examples now support both “Save to Desktop” and “Preview” modes.


GraphicsPath - Full Xojo Compatibility

VNSPDFGraphicsPath is now fully compatible with Xojo’s GraphicsPath API:

Dim path As New VNSPDFGraphicsPath
path.MoveToPoint(50, 50)
path.AddCurveToPoint(100, 20, 150, 80, 200, 50)  // Cubic Bezier
path.AddArc(150, 150, 50, 0, 3.14159, False)      // Circular arc
path.AddRoundRectangle(10, 200, 180, 60, 15, 15)  // Round rectangle
path.CloseSubpath

g.DrawPath(path)     // Stroke
g.FillPath(path)     // Fill
g.ClipToPath(path)   // Clip

Segment types: MoveTo, LineTo, CubicBezierTo, QuadraticBezierTo, CloseSubpath, Rectangle. Plus Bounds() for bounding box and Contains(x, y) for hit testing. Example 29 demonstrates all features across 6 pages.


Barcode Module (E-Invoice Premium Module)

Generate scanner-ready barcodes directly in your PDFs. The premium module uses vector rendering (native PDF rectangles) for perfect print quality at any resolution - no raster images, no JPEG artifacts:

// Premium: vector barcodes on all platforms including Console
VNSPDFBarcode.DrawBarcode(pdf, VNSPDFModule.eBarcodeType.QRCode, 10, 50, 35, 35, "https://example.com")
VNSPDFBarcode.DrawBarcode(pdf, VNSPDFModule.eBarcodeType.EAN13, 10, 100, 60, 25, "4006381333931")
VNSPDFBarcode.DrawBarcode(pdf, VNSPDFModule.eBarcodeType.Code128, 10, 140, 80, 25, "PRODUCT-001")

10 barcode types supported:

  • 1D: Code 128, EAN-13, EAN-8, UPC-A, Code 39, ITF, Codabar
  • 2D: QR Code (ISO 18004), DataMatrix (ECC 200), PDF417

Free library also includes DrawQRCode() and DrawCode128() using Xojo’s built-in Barcode class (Desktop/Web/iOS only, raster rendering).

The premium renderers are pure Xojo math - Reed-Solomon error correction, GF(256) arithmetic, ISO-compliant encoding tables. No external libraries. Works everywhere including Console.

Example 33 is a 4-page showcase: free barcodes, premium 1D barcodes with Xojo Core comparison, premium 2D barcodes, and barcodes embedded in table cells.


Manual Table Builder (Table Premium Module)

Build tables without a database. Define columns, add rows as string arrays, and get the same professional output as the RowSet-based tables:

Dim table As New VNSPDFManualTable(6.0)
table.AddColumn("Region", 35.0, VNSPDFModule.eColumnAlignment.Left)
table.AddColumn("Product", 50.0, VNSPDFModule.eColumnAlignment.Left)
table.AddColumn("Qty", 25.0, VNSPDFModule.eColumnAlignment.Right)
table.AddColumn("Total", 35.0, VNSPDFModule.eColumnAlignment.Right)

table.AddRow(Array("East", "Software License", "3", "1,499.97"))
table.AddRow(Array("East", "Training Session", "3", "750.00"))
table.AddSubtotalRow(Array("", "Subtotal East", "6", "2,249.97"))

// Footer auto-sums skip subtotal rows — no double-counting
Dim footer() As VNSPDFManualTableFooterCell
footer.Add(New VNSPDFManualTableFooterCell("GRAND TOTAL", 2))
footer.Add(New VNSPDFManualTableFooterCell(VNSPDFModule.eFooterCalcType.Sum, 2, 1, ""))
footer.Add(New VNSPDFManualTableFooterCell(VNSPDFModule.eFooterCalcType.Sum, 3, 1, ""))
table.SetFooterCells(footer)
table.Render(pdf)

Features:

  • Multi-row merged headers with colspan
  • Inline subtotal rows with distinct styling (gray background, bold text)
  • Auto-calculated footers (SUM, AVG, MIN, MAX, COUNT) that skip subtotals
  • Per-cell style overrides — mix fonts, styles, sizes, and colors on individual cells
  • Per-column font/color overrides, pictures and barcodes in cells
  • Locale-aware number formatting for footer calculations
  • Automatic page breaks with header repetition

7 examples (10-16) demonstrate everything from basic tables to per-cell styling.


More Improvements

Full Text Justification - Cell, MultiCell, and WriteAligned now support justify alignment (“J”) using the PDF Twword spacing operator. New eTextAlignment enum for type-safe alignment.

Font Improvements - Font subsetter fix for short loca format fonts (Verdana, Trebuchet MS). AddUTF8Font() now auto-searches system fonts when called without a path. Font streams compressed with FlateDecode (~50% size reduction).

PDF Parser Fixes - Fixed hex/literal string parsing in VNSPDFDictionary/VNSPDFParser. Fixed VNSZlibModule CString truncation at null bytes. Fixed Int32 return type for zlib error codes.


Premium Modules - 5 Available

All modules available at verynicesw.fr/xojo-fpdf-premium-modules

Module Price Description
Encryption EUR 50 AES-256/128, RC4-128, digital signatures (PAdES-B-B, XAdES-BES)
Table EUR 50 SimpleTable, ImprovedTable, FancyTable, Manual Table Builder with subtotals and per-cell styling
Zlib EUR 50 Pure Xojo compression for iOS (27-60% reduction)
HTML/Markdown Import EUR 50 LoadHTML() and LoadMarkdown() with full formatting
E-Invoice EUR 50 Factur-X/ZUGFeRD create + read + validate + signature detection + barcode generation

Bundle: Buy 2, Get 1 Free = EUR 100

Every module includes full source code (unencrypted, readable, modifiable), lifetime license, all platforms, and 12 months free updates. Payment via PayPal.


By the Numbers

  • 33 working examples across 4 platforms
  • 5 premium modules available now, 2 more coming (PDF/A, Forms)
  • 10 barcode types with vector rendering for perfect print quality
  • 7 new cryptography classes for digital signatures
  • 8 new e-invoice classes for EU compliance
  • 9 new barcode classes for scanner-ready barcodes
  • Cross-platform: Desktop, Web, iOS, Console (Xojo 2025r3.1 API2)
  • Tested on macOS, Windows 11, Linux ARM64

Questions, feedback, or bug reports? Post in this thread. Community testing has been invaluable - every bug report makes the library better for everyone.

1 Like

I tried the app HtmlToPDF.

  1. The app is in French locale.
  2. The app doesn’t do anything.

OUPS ! seems my beta testers team did not fullfil their job ! :wink:
I fixed htmltopdf and markdowntopdf
vns e-invoicer is fixed too.

1 Like

The pdf for my new app is way more simple than for the email app. I mostly need text, images, urls and url previews like this:

Would that work in your library?

Yes you can draw anything you want on a page, pictures or text are available in the free library
take a look at example 9 for that

I just uploaded the 1.2.1 version to fix a mini mess between free and premium classes.