Private alternatives to LiveDocx - php

I've been looking for a solution to generate PDF from some data I have on a database. Currently I put it on an HTML and then print to PDF, but they asked me to save directly to PDF. These are documents that vary a lot in design, so before it was easy to change a margin or a font size, but now they asking for a direct PDF output it's more difficult, so I saw that LiveDocx is a great solution for me... but these documents are very private (illneses, income...) and my bosses don't want to send any document to a server. So I'm looking for some other solutions. The perfect workaround is doing what LiveDocx proposes (You have a template in a Docx format that you can modify whenever you want, and then you can send some data to the template to fill the gaps and of course save to PDF) but in my own server. Do you know something like this?
My platform is based on PHP+Zend Framework, so it should be compatible with that.
Thank you!!

Well instead of using LiveDocx, i found a really cool Library. mPDF an MIT Licensed library that transfers HTML Code to a pdf document. Its simple and great. Let me know if this helped you and if you need more help.
AND ontop of all that, you can write your data directly to the pdf document. You can input an html file into the pdf writer IF you want. If not then yes you can use their write function to write data directly to pdf.

Related

php - generate pdf with html table and save it on file server

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.

Pdf book reader in php?

Actually I have to upload pdf files and need to read on my website as book reader like a presentation. Please show me the possible ways to achieve my goals.
Thank you
I've been using flexpaper, I use pdf2swf to convert the pdf to swf as I used the flash version but there is a javascript version too.
One possible solution would be to use scribd. You simply upload your document to their website and embed their reader on your website. This is the easiest way, and you get things like searchability. Their reader also works like Adobe's Acrobat Reader.
The downside is that you are uploading your documents onto a public website, so everyone will be able to view it. Perhaps they might have settings where you can lock your documents so that only certain people can see them.
The next solution is to roll your own. You can use turn.js. In this case, you will need to find a way to convert your PDF files to HTML files or perhaps image files. With images, your text won't be selectable, and they won't be discoverable by search engines. Again, converting PDF to HTML can also be difficult as you might lose formatting in the process.
But it is entirely up to your use case. Personally, I would go with scribd, as their platform works very well, and you won't have to worry about implementing your own system.

Dynamic PDF generation

this is what i'm trying to do. I have a Student Result Application in
which i'll like to print out a pdf format of a specially designed
Result's Sheet..
http://www.4shared.com/photo/yg8vCjYe/results_layout.html
My question is that is it possible to send all the html, css and php
variables from the final result sheet to the pdf engine, or just
design a new page result_printout.php page and implement the
pdf engine on that page.
I'll be happy your honest opinions
thanks for you help
honestly, i haven't done this before,
but i think this should help:
http://www.rustyparts.com/pdf.php
Since you allready have the HTML I would suggest to use wkhtmltopdf. There also some wrappers for PHP. It's allways a bit tricky to get it all work in the right way, especially with pagebreaks.
But I find it usually more easy to use then all the other PHP PDF creation classes/libraries.
I have only worked with MPDF and you can pretty much send all the html, css and php variables to the pdf enginge and tell the engine to either force a download or send it to the browser where the user can either save the file or print or just view it. You can also email the generated pdf.
You can read the documentation here: http://mpdf1.com/manual/

PHP to Mesh 2 PDF'S Together or not?

I have an already pre-designed PDF, and I would like to fill the PDF with some database information. So I'm curious if I should save the PDF into JPG's and render them out with the data on top of the image and re-create a PDF.
Or is there a way to use the PDF already, and print data into the PDF that is already made?
I am trying to figure out the best solution to generating this type of PDF.
All thoughts would be greatly appreciated!
You can read about PHP's PDF library here: http://php.net/manual/book.pdf.php
PHP also recommends these alternatives:
http://www.fpdf.org/
http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf
http://php.net/manual/book.haru.php
PDF files support the use of interactive form fields, so the best method for adding information to a PDF from a database, is add form fields to your database and find a library that let's you fill out PDF forms programatically.
Rendering a PDF to an image just to write information on it and then converting it back to a PDF would mean that no text was selectable in the new PDF unless you OCR'd it, which isn't the most optimal way to do it.
After a bit more digging, I was able to use Zend PDF within the framework to update the PDF quite easily. It was my first time using the Zend Framework, and found it quite useful. I suggest anyone trying to manipulate PDF's use Zend.
Just my .02 though. I appreciate your pointers though that were given.

How do I replace outbound link URLs in a PDF document, using PHP

I have a PDF document with some external links.
I'd like to parse the document, replace the destination of the links then close (and serve) the PDF document, all using PHP
I know I can do this with PDFLib but I don't want to incur this cost.
I could re-write the document with FPDF or DomPDF, but some of these PDFs are quite complex so this would be a major time investment.
Surely there must be a way to do this directly to PDF docs, using native PHP?
TIA
I don't think there is a text/hyperlink changer class for PHP. The closest products, like pdftk, only does higher-level stuff like merging, splitting and applying watermarks.
Changing a pdf is much more difficult than generating it, so you need to use a pdf editor like Nitro PDF (untested), or why not Acrobat/Illustrator/InDesign.
If you must use PHP, regenerating the PDF:s with one of the free classes seems to be your best choice. I like FPDF very much, it gets my recommendation. If you decide to use it, check out FPDI as well, it can use existing PDF files as a template, maybe it will help you. Good luck!

Categories