Building a PDF Creation Library in MQL5
Generating real PDF documents from MetaTrader in pure MQL5 — statements, trade tickets and performance reports — with no DLL and no external library.

The problem this series solves
Every trading tool eventually has to hand a document to a person. A statement for an investor, a trade ticket, a monthly performance report, a record for a prop-firm review.
MetaTrader gives you an HTML statement. HTML is fine until somebody prints it, emails it, or opens it on a phone — then the columns shift and a page break lands in the middle of a table. A PDF does not move. It states where every character sits, and it says it in a way a viewer written twenty years from now will still agree with.
The obvious objection is that PDF must be hard. It has the reputation of a binary format with a specification hundreds of pages long and a whole industry of libraries built to hide it. MQL5 has no PDF function and no way to use an external library without a DLL — and a DLL costs you Market validation and the trust of anyone who would have to install it.
That reputation is mostly wrong. A PDF is a text file with an index at the bottom. You can type one in Notepad.
The approach
The series starts with no library at all. Part 1 types two working PDFs by hand — a 592-byte page and an 885-byte trade ticket — and explains every character in them.
That order is deliberate. A reader who has hand-written a working PDF can debug a generated one. A reader who has not, never will.
From there the series builds up a complete PDF library in pure MQL5: no DLLs, no external dependencies, nothing that will fail Market validation.
Who it is for
MQL5 developers who need to produce a document a client or a prop firm will actually accept, and anyone who has wondered what is really inside a PDF file. You need to be comfortable with MQL5 strings and file handling. No knowledge of the PDF specification is assumed — that is the point of Part 1.
Related tool
If you want the finished result rather than the code behind it, Rhino PDF Trade Report exports a MetaTrader account history to a print-ready PDF in one click.
All parts
Each part builds on the one before it. Start at Part 1.
- Part 1Writing a PDF by HandSeptember 24, 2026
Read the full articles on MQL5.com
Every part is published in full, with complete source code, on MQL5.com.

