@@ -20,6 +20,7 @@ Use the compiler to generate a reusable XObject result. Consumers that prefer ar
2020``` php
2121use LibreSign\XObjectTemplate\Dto\CompileRequest;
2222use LibreSign\XObjectTemplate\Integration\XObjectPayloadAdapter;
23+ use LibreSign\XObjectTemplate\Pdf\SinglePagePdfExporter;
2324use LibreSign\XObjectTemplate\XObjectTemplateCompiler;
2425
2526$compiler = new XObjectTemplateCompiler();
@@ -32,15 +33,27 @@ $result = $compiler->compile(new CompileRequest(
3233));
3334
3435$payload = (new XObjectPayloadAdapter())->toXObjectPayload($result);
36+ $pdf = (new SinglePagePdfExporter())->export($result);
37+
38+ file_put_contents(__DIR__ . '/build/preview.pdf', $pdf);
3539```
3640
41+ ### Standalone PDF export
42+
43+ ` SinglePagePdfExporter ` wraps a compiled XObject result into a one-page PDF whose ` MediaBox ` matches the compiled ` bbox ` size exactly.
44+
45+ - The page size is derived from ` $result->bbox `
46+ - Non-zero bounding boxes are translated back to the page origin automatically
47+ - Local PNG and JPEG image sources are embedded into the standalone PDF during export
48+
3749### Output contract
3850
3951- ` $result->contentStream ` : PDF operators ready for a Form XObject stream
4052- ` $result->resources ` : font/image resource dictionary keyed for PDF serialization
4153- ` $result->bbox ` : bounding box as ` [x1, y1, x2, y2] `
4254- ` $result->metadata ` : render diagnostics such as ` line_count ` , ` image_count ` , ` node_count ` , and ` render_ms `
4355- ` $payload ` : transport-agnostic array with ` stream ` , ` resources ` , and ` bbox `
56+ - ` $pdf ` : standalone PDF bytes ready to save, stream, or attach to preview workflows
4457
4558## Supported HTML/CSS subset
4659
0 commit comments