Recent

Author Topic: XRechnung-for-Delphi now runs on FreePascal  (Read 386 times)

sh17

  • Newbie
  • Posts: 5
XRechnung-for-Delphi now runs on FreePascal
« on: June 18, 2026, 12:29:05 pm »
Hey folks,

quick heads-up: I've started porting https://github.com/LandrixSoftware/XRechnung-for-Delphi (GPL lib for German/EU e-invoices — XRechnung 3.0, ZUGFeRD/Factur-X, Peppol BIS 3.0) to FreePascal. First stage is done and it actually works.

The FPC code sits next to the Delphi code via {$IFDEF FPC}, so it's one source tree. The Delphi Xml.XMLDoc write path is mapped onto fcl-xml through a tiny shim — plain FPC ≥ 3.2.2, no Lazarus needed.

And it's verified, not just "compiles": the Delphi version produces golden XML files, the FPC build regenerates them, and a canonical DOM compare says:


PASS: 102/102 golden files identical
Two FPC gotchas that ate my afternoon, in case they save yours:

umlauts in string literals → you need {$codepage utf8} in the unit (-FcUTF8 and a BOM didn't cut it for UnicodeString literals on 3.2.2).
TStringStream.DataString reinterpreted my UTF-8 as UTF-16 → garbage. TMemoryStream + UTF8ToString fixed it (same trap with Base64).
Right now it's the write path only (enough to emit every format), Windows/x86_64 tested. If there's interest, I'd be happy to tackle the read/parse path next (currently MSXML-based, hence Windows-only) and maybe take a swing at porting https://github.com/LandrixSoftware/ZUGFeRD-for-Delphi too.

Let me know if that'd be useful to anyone — and shout if you've got a preferred approach for the reader (fcl-xml XPath vs. manual DOM walk).

Sven

zeljko

  • Hero Member
  • *****
  • Posts: 1987
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: XRechnung-for-Delphi now runs on FreePascal
« Reply #1 on: June 18, 2026, 12:56:40 pm »
Cool, as I can see validation cannot be done without saxon (java) ? I've done it for HR UBL 2.1 few months ago, but at the end I've created java service to do validation since calling jvm and saxon per process is pretty slow.

sh17

  • Newbie
  • Posts: 5
Re: XRechnung-for-Delphi now runs on FreePascal
« Reply #2 on: June 18, 2026, 02:07:31 pm »
Yes, that’s true. For proper validations, I rely on valitool.org; that way, I’m certain everything is correct.

Thaddy

  • Hero Member
  • *****
  • Posts: 19472
  • Glad to be alive.
Re: XRechnung-for-Delphi now runs on FreePascal
« Reply #3 on: June 18, 2026, 02:54:54 pm »
Reminds me about a time about 10 years ago where I rewrote our internal tools from Delphi to FPC...
(That was/is a BIG shop) and then we rewrote most of it in C# and the performance dropped...

Cause: licensing issue with Embarcadero for big shops....

Yes, Margreet, that was a big loss to you, I Know. I am almost out of T-shirts, do you have some? %) O:-)
« Last Edit: June 18, 2026, 03:00:42 pm by Thaddy »
Any "programmer" that knows only one programming language is not a programmer

sh17

  • Newbie
  • Posts: 5
Re: XRechnung-for-Delphi now runs on FreePascal
« Reply #4 on: June 18, 2026, 03:20:09 pm »
I'm currently switching from Delphi to FPC. AI makes it possible—finally.

 

TinyPortal © 2005-2018