@@ -55,6 +55,41 @@ file_put_contents(__DIR__ . '/build/preview.pdf', $pdf);
5555- ` $payload ` : transport-agnostic array with ` stream ` , ` resources ` , and ` bbox `
5656- ` $pdf ` : standalone PDF bytes ready to save, stream, or attach to preview workflows
5757
58+ ### Scaling a compiled XObject
59+
60+ ` CompileRequest::width ` and ` CompileRequest::height ` define the base design size of the template.
61+ If a downstream consumer needs to place the compiled stamp at a different size while preserving the
62+ original aspect ratio, it should keep the compiled XObject unchanged and apply a uniform scale during
63+ PDF placement instead of recompiling the HTML with new dimensions.
64+
65+ - Read the base size from ` $result->bbox `
66+ - Compute a single scale factor from the target width or target height
67+ - Apply the same scale to both axes in the placement matrix
68+
69+ ``` php
70+ [$minX, $minY, $maxX, $maxY] = $result->bbox;
71+
72+ $baseWidth = $maxX - $minX;
73+ $baseHeight = $maxY - $minY;
74+
75+ $targetWidth = 175.0;
76+ $scale = $targetWidth / $baseWidth;
77+ $targetHeight = $baseHeight * $scale;
78+
79+ // Consumer-side PDF placement concept:
80+ $placement = sprintf(
81+ 'q %F 0 0 %F %F %F cm /Fm0 Do Q',
82+ $scale,
83+ $scale,
84+ $x,
85+ $y,
86+ );
87+ ```
88+
89+ Using a uniform placement scale keeps text, images, spacing, and line breaks visually aligned.
90+ Recompiling only to emulate a proportional resize is usually the wrong integration point for this
91+ package.
92+
5893## Supported HTML/CSS subset
5994
6095### HTML
0 commit comments