Comments (4)
Check here: https://github.com/mplodowski/dynamicpdf-plugin?tab=readme-ov-file#page-numbers
You have access to PAGE_NUM constant, so check if it is not even and add page empty page to pdf. Check dompdf documentation how to add new page.
If you figure it out, please add your solution here.
from dynamicpdf-plugin.
Well I'm really lost here. It would be really nice, if PAGE_COUNT constant could be used in template where I could do something like:
`{% if PAGE_COUNT is odd %}
I could use PAGE_COUNT variable also in other cases, like put it in table on front page, but I just have no idea how to get access to that.
from dynamicpdf-plugin.
Enable demo: https://github.com/mplodowski/dynamicpdf-plugin?tab=readme-ov-file#demo-examples
There is Header and Footer example there. Go to Header and Footer layout and there is a code for using page numbers.
You can use following methods to accomplish what you need:
$pdf->new_page(); // add new page
$pdf->get_page_count(); // get all page count
from dynamicpdf-plugin.
Ok, got it working like this
`<script type="text/php">
if (isset($pdf)) {
$size = 9;
$color = [0,0,0];
$font = "{{ 'plugins/renatio/dynamicpdf/assets/fonts/Montserrat-Regular.ttf'|app }}";
$textHeight = $fontMetrics->getFontHeight($font, $size);
$width = $fontMetrics->getTextWidth('Page 1 of 2', $font, $size);
$foot = $pdf->open_object();
$w = $pdf->get_width();
$h = $pdf->get_height();
$y = $h - $textHeight - 35;
$pdf->close_object();
$pdf->add_object($foot, 'all');
$text = "Strana {PAGE_NUM} z {PAGE_COUNT}";
if ($PAGE_COUNT % 2 != 0) { // Check if page number is odd
$pdf->new_page(); // Add a new blank page
}
// Center the text
$pdf->page_text(40, $y, $text, $font, $size, $color);
}
</script>`
from dynamicpdf-plugin.
Related Issues (20)
- custom font not working anymore HOT 9
- The images are no longer printed HOT 1
- Can it be used in a component?
- No query results for model [Renatio\DynamicPDF\Models\Template] HOT 3
- I modified it to Support Arabic language
- Demo command
- Encoding issue when using |raw twig filter. HOT 2
- Deprecated in PHP 8.0 HOT 3
- Webp support. HOT 1
- Not working with OctoberCMS 3.0 HOT 1
- Error with translate plugin HOT 2
- Permissions denied HOT 3
- Duplicate template and layout
- Preview button on the list
- Plugin is creating a 'public' folder HOT 1
- Disable the setIsPhpEnabled() on the preview
- Error when font face is used HOT 1
- Cannot resolve public path HOT 1
- Login Fail for the Demo Version HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dynamicpdf-plugin.