Hi everybody
I'm using CKeditor to edit and generate some reports for my php project. But I need to export the edited texts from CkEditor to Open office and Microsoft word format. So what I need is a class or component which has a function like these :converttoodf($htmlcode) converttodoc($htmlcodes) which return odf and doc format.
However, The doc and Odf file should be without problem , and the pictures and tables should be shown nicely.
In addition, No matter if yr solution be commercial, I may buy it cause I really need it urgently
Tnx in advance and hope can get the right answer asap , here
XLS:
http://docraptor.com/ (automatic conversion from HTML)
or
http://phpexcel.codeplex.com/ (manual building of file, just like phpword from another answer)
DOC
You can get away with just saving the HTML with inline css styles applied and saving it as a .doc. Not sure about how to display images there though.
ODT
http://incubator.apache.org/zetacomponents/documentation/trunk/Document/tutorial.html
more info: http://www.slideshare.net/tobyS/presentation-5028656
You might want to take a look at phpword... i know it supports html documents but im not sure if you can jsut load some source and save it out - you may have to build the document programatically.
If you need ODT anyway, then I'd recommend using OpenOffice via commandline. There is http://www.artofsolving.com/opensource/pyodconverter which can convert between pretty much all Office formats.
HTML import shouldn't be a problem. Don't be foiled by the PDF example. Input and output formats can vary. http://www.oooninja.com/2008/02/batch-command-line-file-conversion-with.html
Related
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'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.
Is there available any class in php that extract all text from pdf file so i can store it in mysql database. My pdf has many elements like images, tables,plain text,form elements,charts etc.
So far i saw many classes for last two days, that extract texts, but no one facilitate with complete text extraction, Not extracting complete text from pdf.
I want to extract all text from given pdf file, even if the text is in table etc.
Any one know about this ? :)
Thanks a lot. Have a nice day :)
Find the below url,
Reading the clean text from PDF with PHP
If you are running this on a linux server, you could try using apdf2text calling it via exec then grabing the contents of the output file.
Note that a few pdf to text scripts are around and you'll get different mileage from all.
I've tested many command line program, but none has 100% result.
So I've started my own library in PHP :
https://github.com/smalot/pdfparser
Currently it's text oriented, but image support will be planned.
If you encountered issues, thanks for sending me your PDF and if possible, the way you made it .
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.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Convert HTML + CSS to PDF with PHP?
I have a form with 5 fields, two of which are textboxes extended with tinyMCE, the rest are simple inputs of type text.
I need to generate a PDF from this input. I understand that I can use Zend_Pdf to generate the PDF and include the plain text data. But how, for example, can I include a bulleted list from the tinyMCE fields?
Would the best way be to create an HTML file, and then use for example DOMPDF or HTML2PDF? Ideally, I'd prefer to just use the zend framework to create the document, position and insert the fields, and save.
Thanks in advance.
More info in Convert HTML + CSS to PDF with PHP?.
In my experience, Prince XML was the Rolls Royce of such technologies so far away and above any of the other ones it's not even funny. It's expensive though. But I had all sorts of problems with all the others.
Some time ago I tried to use HTML to PDF conversion programs to convert... HTML to PDF, but in the end I gave up with that approach and just created the PDFs directly in code. I use fpdf (http://www.fpdf.org/) as a base and added supporting code for lists and grids etc.
I am using Prince XML mentioned by cletus. Results are very good, even with css styled html with floats etc. It's expensive, but it just works and saves a lots of time.
FPDF is very old library for PHP4. It propably won't even work nowadays. I'd recommend DOMPDF or TCPDF. They both are for PHP5+ and can eat HTML or CSS to some degree.
You could convert it all to HTML and then use openoffice or some other tool (pandoc is quite nifty too) to convert from HTML to PDF.
Alternatively, you could take a look at LiveDocx, which has php-bindings too. It's a hosted service, but you can use it without charge.
I personal recommend command line application instead of any php libraries.
Reasons :
PHP libraries need more time and memory (cache) for conversion process
They need well formatted html pages only, otherwise through errors or warning
Not support for external style sheet.
Command Line Tool:
If run your script on Linux server then I suggest command line tool.
Reasons :
They are extremely fast as compared to PHP libraries.
Support css.
Accept non well formatted html.
Which command line tool to use?
wkhtmltopdf
htmltopdf
html2pdf
for more information refer Converting HTML to PDF (not PDF to HTML) using PHP