Pdf4D follows the GDK Delphi rules. This file lists where it deviates. Where it conflicts with the standard rule set, this file wins.
System.Generics.Collectionsinstead of Spring4D. Overrides: "use Spring.Collections". Reason: the library has no dependencies besides the RTL.- Objects with explicit ownership instead of interfaces in the inner layer (
Cos,Parser,Filter,Crypto,Encryption,Model,Content,Font,FontBox,Text), withtry..finallywhere needed. Overrides: "use interface references for automatic memory management". Reason: the object graph has cycles (page and/Parent), which reference counting would leak. The public API layer (Api) does use interfaces. - Method names in the inner layer follow PDFBox (
GetDictionaryObject,ParseCosDictionary). Overrides: naming for behaviour. Reason: the Delphi code can be laid next to the Java code, so upstream fixes can be carried over. varparameters only where a ported algorithm has to update a position or state and that cannot be done through a field. Overrides: "novarparameters".- Long ported methods may keep the PDFBox order as long as they stay readable. Splitting into private methods is preferred. Overrides: method decomposition.
- Inline variables and
conststay mandatory, as in the GDK rules. - Shared, lazily made objects go through
TPdfSharedInstanceandTPdfSharedCache. Aclass destructormay free such an object. Noinitializationorfinalizationsections. Overrides: the GDK rule on singletons. Reason: thread-safe lazy publication and leak detection (an object that is filled once and freed at shutdown is no leak). - A global
procedure RegisterinPdf4D.Vcl.Registration. Overrides: no global procedures. Reason: the IDE calls it by name when it loads the design-time packagedclPdf4D.Vcl; it is the only global procedure of the library. - The native rasterizer (
src\Render\Native) follows tiny-skia. Names follow the Rust code (TTsprefix, Rust names in PascalCase, helpers ofPdf4D.Render.Native.Scalarwith the Rust semantics), so the Delphi code can be laid next to the Rust code. Overrides: naming for behaviour. A Rust&muton a struct becomes a record withvarparameters. Overrides: "novarparameters".{$OVERFLOWCHECKS OFF}stands inPdf4D.Render.Native.Wide,Pdf4D.Render.Native.Pipeline.HighpandPdf4D.Render.Native.Pipeline.Lowp, where the wrapping arithmetic is intended; all other units follow the project settings. Overrides: the rule on compiler directives. A RustOption<T>result becomesTryX(...; out Value): Boolean, and a Rust panic that input can reach becomes an early exit that draws nothing, never an exception. Every unit begins with the Pdf4D copyright line, one// Port of: tiny-skia v0.12.0 <path>line per source file and the tiny-skia copyright line. Changes to the Rust logic are marked with a comment next to the line they replace and listed indocs/porting.md.
- Language level: Delphi 12. No Delphi 13-only syntax, such as the ternary
ifexpression. - Only
System.*units in the library: the core,Pdf4D.RenderandPdf4D.Viewer. NoWinapi.*,Vcl.*,FMX.*or inline assembler there. Exception:src\Vclmay useVcl.*andWinapi.*(overrides: onlySystem.*units), because it holds the VCL components; it does not useFMX.*.src\FMXmay useFMX.*(overrides: onlySystem.*units) and uses noVcl.*and noWinapi.*, so that the components can compile for macOS and Linux. Events of components areprocedure of objectwithoutvarparameters. - Every unit that ports PDFBox code names the PDFBox source files and the PDFBox version in its header.
- Zero hints and zero warnings on all platforms.
- Test hooks (
TPDFontFactory.CreatorOverride, the setter ofTCMap.MappingLimit, and in the native rasterizerDeferMode,ForceMaskClip,ClipKindand the counters of clip builds and of the sort) exist only whenPDF4D_TESTSis defined and are not part of the API. The define is set in the test projects only (tests/Pdf4D.Tests.dproj,tests/Skia/Pdf4D.Skia.Tests.dproj,tests/Vcl/Pdf4D.Vcl.Tests.dprojandtests/FMX/Pdf4D.FMX.Tests.dproj), so the packages, the library code and the demo never see the hooks. - Layers of the renderer: the core (everything under
srcexceptGraphics,Codec,RenderandResources\Pdf4D.Resources.Icc.*) uses no unit from those folders, and only units undersrc\Render\Skia,src\Vcl\Skiaandsrc\FMX\SkiauseSystem.SkiaorPdf4D.Render.Skia.src\Vieweruses onlySystem.*andPdf4D.*units of the core andPdf4D.Render, and the core andsrc\Renderuse no unit fromsrc\Viewer.build.ps1checks these rules and fails on a violation. - The renderer draws through
IPdfGraphicsDeviceandIPdfRenderBackendonly; it never calls a backend library directly. - The native rasterizer (
src\Render\Native) uses onlySystem.*andPdf4D.*units (build.ps1checks the uses clauses against that allow-list, so noPosix.*,Macapi.*or other unit), and onlysrc\Render\Nativeand the viewer layer (src\Viewer,src\Vcl,src\FMX) usePdf4D.Render.Native.*. - The single precision code of the native rasterizer follows the Rust code operation by operation: a literal that is not exact in
Singleis a typed constant, every inlinevarandconstof a float has an explicit: Single, and the result of an RTL function that feeds a further operation goes through aSinglevariable or cast. The negated comparison as a boolean value (Result := not (A < B)) is not used, because Release builds give the wrong answer for NaN (Pdf4D.Render.Native.CompilerCanary.Testspins it);if not (A < B)is fine. - A backend and a device are held through interfaces; a method is never called on a bare
TPdfNativeBackend.CreateorTPdfSkiaBackend.Create(a reference counted object that has no interface reference is never freed). - Code that computes with floating point in the renderer and the Skia device runs inside
TPdfFloatGuard(Skia masks all floating point exceptions of the process when it loads, Delphi raises on them) and usesSinglewith{$EXCESSPRECISION OFF}, as the text code does. - The demos under
demosfollow the same rules (zero hints and warnings, built bybuild.ps1) and use the components through their public API only: a demo has no logic of its own for the viewer. - The messages of
ENotSupportedExceptionthat acaseraises for a value that it does not know (Unsupported document change: %d) are programmer errors that no user sees: they stay string literals. A message that can reach a user or a log of the application is a resource string inPdf4D.Viewer.ResourceStrings; a text that only one framework shell can raise (src\Vcl,src\FMX) may be aresourcestringof the unit of that shell. - The test programs (
tests\*\*.dpr) may have helper routines of their own (PlatformName,RunTests,FlushFmxBlocks): they are programs, not library code. - A Skia call that is not in the list of
docs\building.md("Skia API of the backend") gets a line in the Delphi 12 checklist there. Graphics,CodecandRenderfollow exception 2 only for the objects that mirror the PDFBox object graph (the colour spaces and the page drawer); the device interface, the renderer and the bitmap use interfaces.