I have created PDF file by using php script and FPDF lib. It works fine, i have created two files named index.php and create_result.php in the file create_result.php i have written the php script for pdf file. what i want is that if i changed any program in this file there is no change in pdf file. my confusion is how to change the pdf file ,
ex:(result.pdf).
In the result.pdf file i have made a registraion form , if i want to change any thing in this result.pdf in the sense what should i do for a change?
Two things:
Does the Server have the permission to overwrite the PDF
Do you write Data from you login-Script into the PDF? If so, you have serious problems with multithreading, becaus one user can change the PDF for another user. You have to write a temporal PDF-File per user, with a unique filename.
Related
I have 70gb PDF files, and I want to search inside them with PHP and some Ajax.
The code must search on all PDF files and extract the data out into table,
For example: 1547AD
When I hit enter the code will search in all PDF files and extract all PDF files that contain "1547AD" inside them.
My problem is: of course putting these data inside MySQL will be better for the server and stronger but imagine extracting all tables in 70GB of PDF files! and these pdf files updated daily, also there is alot of traffic on this page.
My question is: Is it the right way to build this in PHP or I should use another language and/or another method for this kind of heavy data?
I studied wkhtmltopdf, tcpdf mechanism to generate pdf files. wkhtmltopdf where you directly pass a .html file and it gives you the pdf where in tcpdf you need to code entire pdf.
my case is I'm having a pdf form template Which I've converted into html so user can fill that form and after i fill that template with user entered values then I'll give an option to user to download the html (user filled) file as PDF document, so template will have user entered data next to that labels.
so first
PDF template >> convert to .HTML page >> process with php echoing >> convert it back with user input to a PDF file.
I'm confused here which approach I should use.
Install wkhtmltopdf on server and use it to pass .html page
problem: Everytime I need to save .html page on server and pass again it to wkhtmltopdf.
using TCPDF I need to write lots of code to create pdf exactly same as template PDF docs I'm having
and then using php echoing those user enterted values.
Which approach should i use If I'm expecting 1000+ users will be saving page as pdf at same time, approach which will be more easier and scalable in future.
First of all - I think you should go with the HTML form to PDF approach, so that's either wkhtmltopdf or a tool that already does this for you like PDFmyFORM.
In case you're expecting to go to 1000 saves concurrently then you definitely want to roll your own solution instead of going with an external service though.
There are patches in the wkhtmltopdf issue list that suggest caching (see this one) and you may also want to think about whether all these forms have to be generated as PDF again. You could use APC cache to somehow cache PDFs based on the same values being filled in. That could save you a bunch of time.
Other solutions you may want to look into are for example PhantomJS, which is a headless webkit browser too, but then based on JS - so that may reduce your server load alltogether...
I want my PHP script to write a file to my directory. What this would do is write a file called hello.php, hello.txt, or hello.html and put it in a specific directory.
The reason is so that when a user fills out their name and age on a form, it would generate a .html file that would be a basic outline, including theirname and age from the form data.
Take a look at file_put_contents(). http://php.net/manual/en/function.file-put-contents.php
file_put_contents('hello.txt', 'Your name is user1544586.');
However, is there a reason you want to generate static HTML files? It is generally better to store data in a database, and then generate pages on the fly with PHP.
We want to generate & validate PDF files with configuration mention into CSV or XML or TXT files via from database records, How can we do it?
I come to know about PDFTK library, but not sure, whether it is suitable for generating auto populated PDF files.
Also i wonder, how can we validate PDF files, means to check, if any fields has been left blank or something?
Is there any way to create a FDF file within PHP without using the dead FDF functions? I am aware that you can use pdftk to create a PDF from an existing FDF file, but I need to create the FDF file first with one field value set.
Or, is there a way to set one field in a PDF using PHP (skipping the FDF file creation) before allowing a user to download it?
For the heck of it, I tried creating an FDF file in PHP using fopen - did not work. I also know there is a generate_fdf operation within pdftk, but this does not allow me to set a specific value, at least not that I can see.
Does anybody know what an answer could be? I am pretty stuck. Unfortunately, I have no control over telling the client to scrap the full PDF (and instead use a webform).
With PDFTK you need two pieces to complete the puzzle. First you need FDF with the data, and secondly an original PDF with appropriately named form fields. PDFTK merges the data into the PDF.
To answer the FDF question first check out this excellent article, http://koivi.com/fill-pdf-form-fields/ that also includes a method to help generate the FDF.
Once you have the FDF with your data you can use PDFTK's fill_form function
You can keep the document editable by using passthru() instead of readfile($temp_file) and outputting to stdout instead of a file name by using the "output - " parameter. Also important is refraining from forcing a document disposition. If you try to force a file download rather than opening it in the browser you'll end up with an uneditable and unsaveable mess.
example:
header("Content-type:application/pdf");
passthru("pdftk ".$original." fill_form ".$fdf." output -");
die();
This will open it in the browser using the Reader plugin. You'll then be able to edit and print the filled form fields, but I still haven't figured out a way to save a copy with the changes. I'm currently chasing Adobe sales for other options.
As noted elsewhere, do not use PDFTK's option "flatten".
The original PDF must not include any passwords.
If I understand you correctly, you just don't want to use the FDF library in particular?
Have you tried TCPDF? See http://www.tcpdf.org/
If you want to use an existing PDF file as a template and only add some values, use the extending FPDI which extends TCPDF: http://www.setasign.de/products/pdf-php-solutions/fpdi/