Skip to content

Commit

Permalink
Fix Form XOBject and update example
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaasuni committed Aug 18, 2024
1 parent a9db5a8 commit a1df9b7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.0.69
8.0.70
28 changes: 13 additions & 15 deletions examples/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -1436,33 +1436,31 @@

// ----------

// XOBject template (@TODO: fix the implementation)
// XOBject template

$pageC02 = $pdf->page->add();

$tid = $pdf->newXObjectTemplate(80, 80, []);

$xcnz = $pdf->graph->getStartTransform();
$xcnz = $pdf->graph->getStarPolygon(50, 50, 40, 10, 3, 0, 'CNZ');
$timg = $pdf->image->add('../vendor/tecnickcom/tc-lib-pdf-image/test/images/200x100_GRAY.png');
$xcnz .= $pdf->image->getSetImage($timg, 10, 10, 80, 80, $pageC02['height']);
$xcnz .= $pdf->graph->getStopTransform();

$timg = $pdf->image->add('../vendor/tecnickcom/tc-lib-pdf-image/test/images/200x100_RGB.png');
$pdf->addXObjectImageID($tid, $timg);

$xcnz .= $pdf->image->getSetImage($timg, 10, 10, 80, 80, 80);
$pdf->addXObjectContent($tid, $xcnz);

$pdf->exitXObjectTemplate();

$tmpl = $pdf->getXObjectTemplate(
$tid,
0,
0,
80,
80,
'T',
'L',
);
$tmpl = $pdf->graph->getAlpha(0.33);
$tmpl .= $pdf->getXObjectTemplate($tid, 10, 10, 30, 30, 'T', 'L');
$pdf->page->addContent($tmpl);

$tmpl = $pdf->graph->getAlpha(0.66);
$tmpl .= $pdf->getXObjectTemplate($tid, 20, 20, 40, 40, 'T', 'L');
$pdf->page->addContent($tmpl);

$tmpl = $pdf->graph->getAlpha(1);
$tmpl .= $pdf->getXObjectTemplate($tid, 40, 40, 60, 60, 'T', 'L');
$pdf->page->addContent($tmpl);

// ----------
Expand Down
2 changes: 1 addition & 1 deletion src/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ abstract class Base
/**
* TCPDF version.
*/
protected string $version = '8.0.69';
protected string $version = '8.0.70';

/**
* Time is seconds since EPOCH when the document was created.
Expand Down
3 changes: 2 additions & 1 deletion src/Tcpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,6 @@ public function getXObjectTemplate(
'h' => $height,
];

$out = $this->graph->getStartTransform();
$ctm = [
0 => ($width / $xobj['w']),
1 => 0,
Expand All @@ -725,6 +724,8 @@ public function getXObjectTemplate(
4 => $this->toPoints($tplx),
5 => $this->toYPoints($tply + $height),
];

$out = $this->graph->getStartTransform();
$out .= $this->graph->getTransformation($ctm);
$out .= '/' . $xobj['id'] . ' Do' . "\n";
$out .= $this->graph->getStopTransform();
Expand Down

0 comments on commit a1df9b7

Please sign in to comment.