@jianwt @rvk Can you show the full program source and compilation command line please.
When I use the standalone SynPDF unit in my test program, compilation fails with "cannot find unit Graphics".
I haven't got a console app but a complete Lazarus LCL app.
This is just a small empty LCL app with a button (as per example) in Lazarus with mORMot2 installed.
You're missing Graphics is just because you didn't add LCL (which is done automatically with a LCL app).
But... more important... SynPdf isn't really updated anymore (I thought).
If you want the latest you need mORMot2 (which pulls in even more).
I tried the older SynPdf but you need to download some SynFPCMetaFile source (found in the older mORMot 1 version).
And after that, the error keep coming. (I gave up after fixing a few there)
When I use mormot.ui.pdf:
Compiling ...\lcl\nonwin32\messages.pp
messages.pp(22,4) Error: User defined: This unit is not for MS Windows. Windows has unit windows for that.
messages.pp(32,30) Fatal: Circular unit reference between Messages and LMessages
Windows 11, Lazarus 3.4 and its bundled FPC 3.2.2
You also need to extract a zip with some binaries in the static directory.
See the documentation on
https://github.com/synopse/mORMot2It also says:
Note that FPC 3.2.2 has a regression with variant late binding - use FPC 3.2.2 fixes branch instead.
So not sure if Lazarus 3.4 had FPC 3.2.2 fixes version (I use trunk here).
After that adding mormot.ui.pdf and Windows to that empty LCL app with one button will do as test application.
I did have to setup extra paths in "other unit-files" to make Lazarus find the sources.
Somehow the mormot2.lpk and mormot2ui.lpk as required packages doesn't add the search path.
So I needed to add:
Q:\dev32\extras\mORMot2\src\ui;Q:\dev32\extras\mORMot2\src\lib;Q:\dev32\extras\mORMot2\src\core;Q:\dev32\extras\mORMot2\src\crypt
After that the shown code gives error (which works fine in Delphi):
Project project1 raised exception class 'External: ACCESS VIOLATION' with message:
Access violation reading from address $00000002.
In file 'mormot.ui.pdf.pas' at line 5216
procedure TPdfWrite.AddGlyphFromChar(Char: WideChar; Canvas: TPdfCanvas;
Ttf: TPdfFontTrueType; NextLine: PBoolean);
var
changed: boolean;
fnt: TPdfFontTrueType;
Glyph: word;
begin
assert((Ttf <> nil) and (Ttf = Ttf.WinAnsiFont));
changed := fAddGlyphFont = fNone;
Glyph := Ttf.fUsedWide[Ttf.FindOrAddUsedWideChar(Char)].Glyph;
with Canvas.fDoc do
if (fPdfA <> pdfaNone) and
(Glyph = 0) and
(fFontFallBackIndex < 0) then
raise Exception.Create('PDF/A expects font fallback to be enabled, ' +
'and the required font is not available on this system')
BTW This works fine so it's just when Chinese characters are used.
S := 'Testen';
pdf.Canvas.SetFont('Arial', 12, []);
Pdf.Canvas.TextOutW(100, 600, PWideChar(S));