Dompdf is a PHP library that functions as a document rendering engine, transforming HTML and CSS markup into portable document files. It operates by parsing web-based layout attributes and visual properties to generate static documents suitable for reports, invoices, or archival purposes.
The library distinguishes itself by integrating a resource-fetching pipeline that retrieves external stylesheets and images to maintain visual fidelity. It also supports the execution of server-side scripts during the document creation process, allowing for the injection of dynamic data and custom logic into the final output.
The rendering process involves converting web markup into a structured tree of geometric boxes, which are then translated into low-level vector instructions and text streams. This workflow includes calculating element dimensions, margins, and padding, as well as mapping font metrics to ensure accurate text wrapping and document flow.