#1 2026-09-12 07:48:02

mdoyle
Member
Registered: 2020-11-29
Posts: 32

mORMot PDF crossplatform

I’ve been a big fan of mORMot for a long time, and I’ve used the PDF engine extensively over the years. It’s a powerful library, and I really appreciate how much it can do.

Recently, with the move to Lazarus on macOS and Linux, I became especially interested in a cross-platform solution for PDF generation and reporting. That led me to build and refine a project that abstracts the platform-specific parts and works across those environments.

This is a very complex library, so I relied heavily on Claude to help with the porting and integration work. It has been extremely useful in navigating the complexity and getting the cross-platform pieces to fit together cleanly.

The project currently includes 6 example files that demonstrate the main use cases and APIs:

direct PDF generation,
TCanvas-style usage,
report generation,
markdown/export flow,
CJK support,
RTL/Arabic text handling.

You can find the project on https://github.com/martin-doyle/mORMot2 … ssPlatform.

I’d love to hear whether this kind of cross-platform mORMot PDF/reporting project is of interest to others in the community. If there is interest, I’d be happy to share more details and examples.

Martin

Offline

#2 2026-09-13 09:47:05

edwinsn
Member
Registered: 2010-07-02
Posts: 1,230

Re: mORMot PDF crossplatform

@Martin, thanks for sharing, it must be very helpful.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#3 2026-09-14 08:08:17

flydev
Member
From: France
Registered: 2020-11-27
Posts: 205
Website

Re: mORMot PDF crossplatform

thanks! good timing, I've just been asked to add report generation and pdf export on our backend, and I never touched the pdf side of mormot until now. will give it a try this week.

Offline

#4 2026-09-15 13:00:37

JD
Member
Registered: 2015-08-20
Posts: 132

Re: mORMot PDF crossplatform

@mdoyle Thank you so much for sharing your work.

Offline

#5 2026-09-21 19:11:33

mdoyle
Member
Registered: 2020-11-29
Posts: 32

Re: mORMot PDF crossplatform

Besides the cross-platform support, creating accessible PDFs was a design goal. Since the European Accessibility Act came into force on 28 June 2025, accessibility is mandatory for many PDFs published online (and it has been required for public-sector bodies for even longer).

I've made a few adjustments so that most of the examples now pass an accessibility test, carried out with the German testing tool PAC. All demos except the Chinese and RTL ones now run through the tests without any errors.

Offline

#6 2026-09-22 03:57:42

EduardAppelhans
Member
Registered: 2020-04-14
Posts: 15

Re: mORMot PDF crossplatform

I‘m wondering if it might be reasonable to combine this solution with Sh17/Sven Harazim/ Landrix Zugpferd for Delphi solution.

The idea is to use it on top of an existing invoice generating mormot2 SOA Service with fast report to enhance it submitting cross platform PDF Zugpferd capabilities. Would this approach generally be advisable?

Last edited by EduardAppelhans (2026-09-22 04:51:39)

Offline

#7 2026-09-22 19:15:34

mdoyle
Member
Registered: 2020-11-29
Posts: 32

Re: mORMot PDF crossplatform

Thanks for the question, it touches on something I've been thinking about as well.

Short answer: invoice generation itself is out of scope for this project, but PDF/A-3 with file attachments is something I will look into.

A few thoughts on your setup:

- If FastReport renders your invoices, the PDF comes from FastReport's own exporter. Since this PDF engine can't modify existing PDFs, you would need to render the layout with TGDIPages instead, or check whether FastReport itself supports PDF/A-3 attachments.

- This library could provide the generic container: PDF/A-3 with embedded files like Landrix XML invoice library, combined with the existing PDF/UA tagging.

I'll put PDF/A-3 with attachments on the roadmap as a future item and validate it. By the way, a real-world invoice layout would make an excellent test case.

Offline

#8 2026-09-22 20:16:55

EduardAppelhans
Member
Registered: 2020-04-14
Posts: 15

Re: mORMot PDF crossplatform

Thanks for your answer!

Offline

#9 2026-09-23 22:19:33

sh17
Member
From: Dresden/Germany
Registered: 2011-08-09
Posts: 63
Website

Re: mORMot PDF crossplatform

Oh, exciting. I'll keep an eye on it.

Offline

#10 2026-09-24 19:36:18

mdoyle
Member
Registered: 2020-11-29
Posts: 32

Re: mORMot PDF crossplatform

The engine now writes PDF/A-3U and PDF/UA-1 in one file.

The new example zugferd_demo builds a ZUGFeRD / Factur-X invoice (profile EN 16931): a tagged, accessible PDF with the invoice XML embedded. The invoice data is public KoSIT test data. The result passes veraPDF, the Mustang validator and PAC 2024 on Windows, Linux and macOS.

Feedback welcome, especially if you try it with your own validator or accounting software.

Offline

#11 2026-09-24 23:00:00

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,602
Website

Re: mORMot PDF crossplatform

Perhaps it could be worth considering integrating it back to the mormot trunk sooner or later.

We could define a new "src/pdf" folder for the units, not any more in "src/ui".
The mormot.pdf.xxxx.pas unit names just show this pattern.
wink

Offline

#12 2026-09-25 03:54:50

sh17
Member
From: Dresden/Germany
Registered: 2011-08-09
Posts: 63
Website

Re: mORMot PDF crossplatform

mdoyle wrote:

The engine now writes PDF/A-3U and PDF/UA-1 in one file.

The new example zugferd_demo builds a ZUGFeRD / Factur-X invoice (profile EN 16931): a tagged, accessible PDF with the invoice XML embedded. The invoice data is public KoSIT test data. The result passes veraPDF, the Mustang validator and PAC 2024 on Windows, Linux and macOS.

Feedback welcome, especially if you try it with your own validator or accounting software.

A dream is coming true. I'm going to take a look at it right away today.

Offline

#13 2026-09-25 11:04:11

mdoyle
Member
Registered: 2020-11-29
Posts: 32

Re: mORMot PDF crossplatform

ab wrote:

Perhaps it could be worth considering integrating it back to the mormot trunk sooner or later.

We could define a new "src/pdf" folder for the units, not any more in "src/ui".
The mormot.pdf.xxxx.pas unit names just show this pattern.
wink

This is exactly what I was hoping for. It finally gives me a chance to give something back to the project.

I wasn't sure whether PDF still had enough relevance in 2026, or whether my changes were good enough to be accepted upstream.

I've been so focused on tackling cross-platform challenges like fonts, different libraries, and tagged PDF support that I kind of lost sight of other areas, such as Delphi.

And yes, integrating it with mORMot2 is definitely the way forward.

Offline

#14 Yesterday 22:06:59

mdoyle
Member
Registered: 2020-11-29
Posts: 32

Re: mORMot PDF crossplatform

A busy day on the PDF cross-platform port. The main news: the TCanvas bridge and TGDIPages now build on Delphi 7 too. All the console demos and the --export mode of the two GUI demos run there and produce the same PDFs as FPC, still passing PAC and veraPDF.

Heads-up, there are breaking changes:
- preview and printing moved out of TGDIPages into their own unit (mormot.ui.reportpreview)
- TGDIPages takes RawUtf8 now, and GetReportFonts/GetExportFonts return RawUtf8
- the demo PDFs have new file names

Most code should compile as before, but please check the ROADMAP ("To Announce") before you update.

Offline

#15 Today 10:48:10

mdoyle
Member
Registered: 2020-11-29
Posts: 32

Re: mORMot PDF crossplatform

mORMot2 PDF cross-platform: now on Delphi 2010 too

After Delphi 7, today it was Delphi 2010's turn, our first Unicode Delphi. Good news: the engine didn't need a single fix. All tests pass on Delphi 2010, Delphi 7 and FPC, all eight demos give the same PDFs as with Delphi 7, and PAC and veraPDF are happy.

It wasn't completely painless: my UTF-8 string constants got encoded twice, and that shook out a small bug in the XMP header. Fixed.

I can't test a current Delphi or Delphi for Linux myself because I don't have those compilers. If you do, I'd love to hear how it goes.

Details in the Github repo.

Offline

Board footer

Powered by FluxBB