Add blank page if current page is ODD in PHP mPDF - php

I have table in HTML, which will take sometimes one page, sometimes more. After add this to pdf I need check how many pages I have so far and add blank page if I have an odd number of pages.
After that I will add another content.
How can I do that?

$mpdf->page holds the current page number, so you can use it to check what page you are on and add a pagebreak if needed:
if($mpdf->page % 2 == 1) {
$mpdf->addPage();
}

Related

TCPDF how to prevent last empty page in some cases

when i create via PHP a pdf using TCPDF, some times i get a last empty page body (so header and footer printed, but body empty).
It appened when i print different rows of text and the latest row is very close to bottom margin of my pdf...
When i output data into a file.pdf, for example, i get 3 pages...but text is not occupying 3 pages... it occupe only 2 pages (very close to bottom margin)... but TCPDF i don't know why, add 1 more useless page.
My idea is:
create my rows
after last row, add an empty span <span id="hidden_end"></span>
search inside the pdf: if I find "hidden_end" inside the last page, all is ok. I I find "hidden_end" NOT at the last page, the delete last page from PDF
But i don't know how to implement point 3.
Any ideas?

PHP session not updating variable

I'm building an image slider where images are loaded from my database and displayed inside a php page.
There's a session variable, "number", to remember what is the current database row, in this way I can easily move to next or previous image.
Initially the page was working perfectly, but now when I press on "Next" button to increase session number and move to next page, it remains stuck to "2" and doesn't allow me to read other pages, even if there are multiple ones. I can only browse image no. 1 and image no. 2
I believe the code is correct, but I'm afraid there's something missing about how PHP sessions works, can you confirm it?
//
session_start() must be the second thing on your page after <?php. HTML tags must be placed after it or the session will not be started.
You do not need to use Session to maintain the pagination, instead Keep the pagination status inside Next, Prev html buttons. I could see some better pagination logic here at:
Simple PHP Pagination script

FPDF show footer page number for specific pages with different format

In FPDF, if there are 4 pages to print then FPDF will calculate page as 0,1,2,3
For generating page number, It will skip the 0th page (if($this->page>0){ } in AddPage() function) and calculate line number from next page onwards(1,2,3) and in close() function it just add another page number (4)
So total there will be 4 pages and in output it will show line number correctly.
Current scenario: I need to determine the page number format dynamically. So in function AddPage($orientation='') I added another parameter called $show_number. So if show number is 1 then need to show the page number for that page in a specific way, else show in another way.
Problem: Because the FPDF skips the first page and adds the last page number in close() function I could not show the page number correctly.
For example, if I wanted to show the number in a different way on the third page, I'm getting the result in 2nd page instead.

FPDF prints one extra blank page

I am using FPDF to view/print data in PHP.
There is only one page I can see on my browser. But, When I try to print that page. I get one extra blank page from printer. Why FPDF submits one extra page every time? Is there any setting that I need to do?
Thanks.

Form on PHP page with multiple submits changes CSS of page

I've created a PHP web form which when all the data is present has 2 submit buttons (Continue and Print). Continue calculates details based on the entered information and displays it on the page. Print performs the same calculations, but then creates a PDF in a new window.
When I click Print the original page still loads (which is fine) but the styling is altered.
To see what I mean head to this page and for speed enter "1" in all text boxes except Position (which must be text). After you've clicked Continue, click Print to generate a PDF, then look back at the original web page to see altered styling.
Any ideas would be useful.
Thanks,
Adrian
Assuming you mean the tables overrunning the footer, get rid of the height: 100%; on #prodselector_text, solves the issue for me.

Categories