Skip to content

Commit 920c922

Browse files
authored
Merge pull request #7 from benconda/render-form
chore: allow form values rendering
2 parents 4e87046 + b104de2 commit 920c922

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/Page/PageBitmap.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ public function __construct(
2424
private readonly Page $page,
2525
?int $width = null,
2626
?int $height = null,
27-
private ?int $x = 0,
28-
private ?int $y = 0
27+
public readonly ?int $x = 0,
28+
public readonly ?int $y = 0,
29+
public readonly bool $withFormValues = false,
2930
) {
3031
$this->ffi = PhpPdfium::lib()->FFI();
3132
$pageWidth = $this->page->getWidth();
@@ -60,6 +61,11 @@ public function getHandler(): CData
6061
// Render in bitmap
6162
$this->ffi->FPDF_RenderPageBitmap($this->bitmap, $this->page->getHandler(), $this->x, $this->y, $this->width, $this->height, 0, 0x800);
6263

64+
if ($this->withFormValues) {
65+
$formHandle = $this->page->getDocument()->getFormHandler();
66+
$this->ffi->FPDF_FFLDraw($formHandle, $this->bitmap, $this->page->getHandler(), $this->x, $this->y, $this->width, $this->height, 0, 0);
67+
}
68+
6369
return $this->bitmap;
6470
}
6571

tests/unit/DocumentTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public function testGetPageSizeByIndex(): void
4242
{
4343
$notice = $this->loadDocument('notice');
4444
$size = $notice->getPageSizeByIndex(0);
45-
self::assertSame(595, (int)$size->width);
46-
self::assertSame(841, (int)$size->height);
45+
self::assertSame(595, (int) $size->width);
46+
self::assertSame(841, (int) $size->height);
4747

4848
$badIndex = $notice->getPageSizeByIndex(-5);
4949
self::assertNull($badIndex);
@@ -58,8 +58,8 @@ public function testPageSizeIterator()
5858
$notice = $this->loadDocument('notice');
5959
foreach ($notice->pageSizeIterator() as $size) {
6060
$layout[] = [
61-
'width' => (int)$size->width,
62-
'height' => (int)$size->height,
61+
'width' => (int) $size->width,
62+
'height' => (int) $size->height,
6363
];
6464
}
6565
self::assertCount(36, $layout);

0 commit comments

Comments
 (0)