You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i've got a stationery with header and footer. in between those blocks should appear the content of every site. The stationery blocks should appear on every site so i put them in an object and added it to all pages via addObject. Now my problem is that i can't get the ezSetMargins to work. My thought was that i add the stationery object to all sites and then set the correct margin for the area in between the header and the footer so that the content would automatically break onto a new page before running into the footer and starts after the header on the new page.
what would be the correct aproach to achieve this?
thanks in advance
The text was updated successfully, but these errors were encountered:
Here is a quick example on how to add header and footer while positioning the rest of its content using $pdf->ezSetMargins
<?php
include '../src/Cezpdf.php';
$pdf = new Cezpdf('a4', 'portrait', 'none', null);
$all = $pdf->openObject();
$pdf->saveState();
$pdf->setStrokeColor(0, 0, 0, 1);
// header line and text
$pdf->line(20, 822, 580, 822);
$pdf->addText(20, 800, 14, 'Repeating header line');
$pdf->line(20, 790, 580, 790);
// footer line and text
$pdf->line(20, 40, 578, 40);
$pdf->addText(20, 30, 8, 'Hello footer');
$pdf->addText(580, 30, 8, 'footer right aligned', 0, 'right');
$pdf->restoreState();
$pdf->closeObject();
$pdf->addObject($all,'all');
$pdf->ezSetMargins(100, 100, 50, 50);
$text = str_repeat(
"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.\n\n"
, 20);
$pdf->ezText($text, 0, ['justification' => 'full']);
if (isset($_GET['d']) && $_GET['d']) {
echo "<pre>";
echo $pdf->ezOutput(true);
echo "</pre>";
} else {
$pdf->ezStream(['Content-Disposition' => 'readme.pdf']);
}
Please note: Using the ez* methods (like ezText and ezTable) may have side effects when using it inside $pdf->addObject
Hello,
i've got a stationery with header and footer. in between those blocks should appear the content of every site. The stationery blocks should appear on every site so i put them in an object and added it to all pages via addObject. Now my problem is that i can't get the ezSetMargins to work. My thought was that i add the stationery object to all sites and then set the correct margin for the area in between the header and the footer so that the content would automatically break onto a new page before running into the footer and starts after the header on the new page.
what would be the correct aproach to achieve this?
thanks in advance
The text was updated successfully, but these errors were encountered: