I am using mPDF to generate PDF files from form submissions.
The script is going through all questions and creating a HTML fieldset for each containing the question and the answers.
Since the survey is quite long, the generated PDF spans over several pages which works fine. Now, the client wants "nice & pretty" PDF files, where a fieldset does not contain a page break.
From this question, I know I can determine the remaining space of a page during the generation process.
Now the question is, how can I determine the height of the fieldset coming up next in order to decide whether or not I have to add a page break first?
Is there a function, which just renders a specific part of HTML as a PDF and returns the final height?
Related
I am trying to create an editable HTML textarea component using TCPDF API library. I want to display a scrollable text box on the screen.
Can this be done?
Current TCPDF examples include these: https://tcpdf.org/examples/
I know PDFs can have editable components, but I am not sure how to create them with TCPDF, if it is at all possible.
TD;DR: how can I generate a page with a scrollable textarea using PHP + TCPDF?
Linked Answer using another library (mPDF):
Note that while How to create editable Pdf form in php may work, it does not make use of TCPDF library. My existing codebase relies heavily on TCPDF, I would like to explore the possibility of using TCPDF before I consider adding another library ...
i.e. I rather have an answer of "Not possible" than to use another library at this time.
It looks like the issue is two-fold.
First, you can use a typical form example, like here: https://tcpdf.org/examples/example_054/
However, you cannot see editable fields in a browser, at least you cannot in Mozilla Firefox 56.0.2 as the time of this writing. (https://support.mozilla.org/en-US/questions/1006115)
What you need to do is open the generated PDF in a different viewer that supports editable form fields, such as Adobe PDF reader/other.
Then you can fill out the textarea and if text size exceeds the area of the form element, it will have scroll bars added to the textarea.
I have to generate a PDF document that could take more than one page. Each page has a html table (that has a variable length), and a QR code at the bottom of the page.
The QR code will be at the bottom of every page of the document, but, if that is too difficult to achieve, I can have it only in first page.
I have the problem that the text of the html table is printing over the QR code. I tried using $pdf->setPageRegions without any positive result, because the coordinates used to define the position of QRCode and for setRegions are in different units.
How can I achieve this?
Below is an image of a HTML page that I need a little advice with.
The large square is an AJAX DIV that gets reloaded when a user changes pages. (works fine).
The smaller black rectangle is a DIV that is including in many of the pages and it has a few different states. I want to keep the current state regardless of which page the user is on and I'm struggling to work out how to include this.
I've been using PHP include but it reloads the code again each time - eg: current state lost.
I was considering using an iframe but I'm not sure if I can iframe to a DIV and then I have the added issue of the red square which pops out from the smaller black rectangle when certain selections are made. Not sure if I could include all this in an iframe when there is other information behind the red square on the page - eg: the iframe needs to overlap other information...
any advice? I can explain more/better if needed.
thx
One of the following might fit your needs:
localStorage: http://www.joelennon.ie/2011/02/11/basics-of-html5-local-storage/
PHP Sessions: http://www.php.net/manual/en/session.examples.basic.php
PHP Cookies: http://php.net/manual/en/features.cookies.php
These techniques allows you to simply save data. Say you've named your different states. Save that string in some way, and read it to decide in which state to show that black box.
I am using TCPDF to create PDFs with PHP. Everything works very nice, except when text would be placed where the footer resides. In my example, the text is shown only half, the rest is behind the footer. Is there an option which defines to put it on the next page?
Besides that, my PDFs differ from print to print, some have 1 page, some 2 or more. Is it possible to say that a specific text should only be placed on the page when it fits completely? if not, it should go to the next page.
I already have this in my code, but it doesnt help, the text is still cut.
$pdf->SetAutoPageBreak(true, 25);
I am creating the PDF by creating a huge HTML string and print that to the PDF using writeHTML. This is how it looks, the bold text on top should go to the next page, its hidden behind the footer.
Thanks!
I am trying to create an interface to allow easy editing of PDFs like VuePDF in an application I am building. This is not core to the application and will only be used by the admin.
I was wondering if there was a per-built stack for editing PDFs in the browser window?
Basically the admin user needs to black-out private data, like names and addresses.
If there is not currently a solution I was thinking of some like:
Using ImageMagik to create JPEG version of each page
Using the canvas element to add black marks to the image
Recording the location of top-left and bottom right of each black mark
Sending back the coordinates and adding black rectangles to the original PDF
Is that correct?
If you draw over the PDF, the data will still be there in the PDF and easy to extract. I wrote a blog article explaining the issue at http://www.jpedal.org/PDFblog/?p=553
You need to replace the text in the PDF command stream as well.