I am creating a small application which manipulates PDF file as follows
A customer creates a CSV to a given specification that contains the
name,address, country, ink type, station to use. This CSV could also
include customized tokens which replace tokens that are written
within their PDF Document.
A customer creates a PDF document it could be a standard document
that's exactly the same that gets sent to everyone in their CSV file,
or it could contain special tokens which are replace with specific
contacts details within the CSV.
I've briefly looked at http://us.php.net/pdf and FPDF, but I was wondering what specific technique I'd use to achieve this.
I was thinking I'd insert an address tokens string where I want the address to go, and then use some function to update those tokens in the PDF document.
Can anyone point me in the right direction? I have php experience, but not with editing / generating pdf documents from php.
You can use MPDF lib to generate PDF. In it you just need to pass your HTML content.
From half the PHP devs I talk to they recommend this:
http://www.setasign.de/products/pdf-php-solutions/setapdf-linkreplacer/
For your problem - I believe you need to buy it but there is an eval copy for your devving needs.
HTHs - Thanks,
//P
I am using Tcpdf library to generate pdf.
please check url for example. http://www.tcpdf.org/examples.php
If you kept all the contact information on a single page you could use poppler-utils https://packages.debian.org/sid/poppler-utils to pdfmerge the page of contact info with the bulk of the PDF. Use tcpdf library to create the one page with contact info.
Related
I have one issue about PDF file.
I generate dynamic PDF template (Like Certificate). The file content some fields like Firstname, Lastname, Course type, etc.
I want to write dynamic content into PDF as firstname, lastname etc.
I have tried MPDF, FPDF etc tools, but they are not working. I also used PDF to HTML conversation but after converting HTML regenerates not possible from html into proper format.
Please let me know if anyone have other idea to direct replace content into Existing pdf using PHP.
I have sample pdf files.
I want to replace content into given attachment. This is a demo file I have many files with different templates.
Okay, get away from your thoughts one could easiely change anything in a pdf from PHP.
The one way to do such thing like generating a certificate for anyone is to generate a "blank" pdf and then put in the names with names with a php libarary (like Zend_Pdf or anything else).
To make it short: There is no (easy, free) way to manipulate data in a PDF.
To make it complicated: Yes, there is a way. One have to open the file, read it's content, understand where to search for the variables, manipulate the data and regenerate the pdf with a pdf generator. And yes, i know, it is very complicated, so stay at the short and easy way: Generate a blanko and put in the variables as needed ;)
I am working with a tool which lets user upload a .csv file.
That csv file contains an address column. I have to use the address from each row in another HTML template. That HTML template is like this
. After creating that template I then need to convert it into a PDF, store the PDF on a file server and give the user a link to the PDF.
I've finished the first two steps - csv upload and created complete template with address, but I'm stuck on how I can convert a template into a PDF.
I have looked into a few php-pdf libraries like fpdf mpdf. I'm facing a problem in creating pdf with html template.
A link to a library wich convert HTML to PDF and works pretty well.
First the link to the library
HTML2PDF
Then some code* to create your PDF using your own generated HTML, where $content is your HTML string.
$html2pdf = new HTML2PDF('P','A4','fr');
$html2pdf->WriteHTML($content);
$html2pdf->Output('exemple.pdf');
*Code taken from the "example page" of the site.
I have used tcpdf in many cases, https://tcpdf.org/
Works well with tables, I have made receipts and accounting related stuff with it. Handle UTF-8 without problems, why it's my way to go.
Only downside is that code is bit long and complicated and it doesn't keep tables as tables in pdf and turns them to divs, so paddings and other styles might be bit trickier to do.
One way is to use webkit based HTML to PDF converter.
Pros are that it is easy to customize and style and to see in the browser how it will look and then you can be sure that it will look as same in PDF as well. You could use CSS and JavaScript as well to style and modify.
Cons are that it is hard to install it on the production server sometimes. But there are web services and APIs that get you covered.
For example one service is https://pdfapi.io. It is free to use. Only when your amounts get bigger, then it will charge like a cup of coffee.
Hope that helps.
I am making an app that creates an invoice.
It is created in HTML and PHP using different data from a database.
I need to create a function that converts the page into a PDF and send it to a client.
I can not store it on server as it would mean to create a few hundred everyday. I need something like "http://FreeHTMLtoPDF.com/?convert=".$strBillURL; but it's not working any more.
Many thanks if you can help me!
I prefer to generate PDF files using some library that converts HTML/CSS to PDF. One of the libraries that provides this and is very easy to use is mPDF:
https://github.com/mpdf/mpdf
I have no information regarding what type of PDFs you generate, but in my projects I tend to generate them on the fly from the data in the database and do not store them at all.
There are also other options available for converting HTML to PDF, like wkhtmltopdf, but they might require additional knowledge in set up: https://github.com/wkhtmltopdf/wkhtmltopdf
I need to create a PDF that will contain employee CVs for an employer to download. The information that needs to go into the CV e.g first_name, last_name etc needs to be extracted from the database and then I need to build the format of the CV with HTML and then make it possible to be downloaded as a PDF.
I know how to get the user info and build the HTML be not sure how to convert it to a PDF afterwards is there a good WordPress plugin to do this?
I know it's a little out of time for answering, I had the same problem some time ago and I didn't find any plugin for doing it. So what I did was integrate fpdf.
It is really easy. Just download the last version from here, save it on one folder on your directory and include it on your function.php.
Then, you will be able to build an html string and generate the pdf file with it. Take a look at the tutorials on the fpdf page, they will be really useful for knowing what tags you will be able to use.
good luck!
I am currently building a digital signature system for my company and I need to be able to add the signature once signed to a PDF document.
I have been using FPDF & FDPI to overlay the signature onto the document (this works great if the document is static.)
The problem I have is that the document starts out as a word doc and is converted to PDF. The document has 20 pages and tons of fields passed to it by our case management software so to change to PDF will take me ages also it will change in size based on the information passed from the fields.
I was wondering if anyone has come across a way to search & replace text in a PDF or is there a way to parse the document add a signature and re-create a new PDF.
Any help on this would be great as I have spent a week now trying to find a solution.
Oh sorry for lengthy post just trying to get as much info in as possible.
Thanks
Brad
Actually I'm not aware of any class/library in PHP that is able to replace text in a PDF document with other content. If it is possible to convert the "fields" into real PDF form fields, you may check this out (not free!).
Thanks for your reply
I have managed to sort. I am going to parse the document using parserpdf and then find and replace a placeholder in the document with the signature and then re-build the PDF using FPDF.
Bit long winded but tested and works well.