HTML to PDF converter in php with support for svg? - php

Do you know any php (4/5) library that would convert HTML string to PDF with support for svg?

wkhtmltopdf is not a PHP library, but in most cases, you'll be able to execute it with exec(). An example on how to do this is listed on the project page's wiki. Make sure that you CHMOD it to be executable (+x) via command line or your FTP client.
Embedded SVG has some caveats.

Related

Convert html or pdf document in postscript over web (PHP, JS)

I need print a document directly over PHP. It works by php_printer. Now I need convert HTML ou PDF document to PostScript.
It's possible over web? By Js ou PHP?
Thanks!
With PHP you can use wkhtmltopdf, you will have to install it on server though. It's a command line tool, but there are some PHP libraries, like phpwkhtmltopdf to simplify the usage.

How can i convert a svg image to png image with Imagemagick when the svg file has embedded images?

With PHP i'm creating an image with embedded content (base64 encoded files). If i see it using Firefox, or downloading it and then opening it with Inkscape (www.inkscape.org), the image is fine!.
But when i try to convert it using imagemagick (using convert command or with Imagick support for PHP) the embedded image doesn't come in with the final result.
I don't know if there is a special command or configuration i'm missing. I'm not using any special setup. Just ...
convert image.svg image.png
Thank you very much for your answer.
ImageMagick's built-in SVG rendering is really pretty horrible. Don't use it if you can avoid it. I'd recommend using librsvg instead, either using the command-line rsvg tool, or possibly with the PHP rsvg extension.
(Librsvg's rendering isn't always perfect either, but it should be able to handle embedded images just fine. If you want even better rendering, you could always try using Inkscape from the command line.)
Is the embedded image in PNG or in Jpeg format? What converter is used in PHP? I tried on Windows with latest ImageMagick, which doesn't come with RSVG. I found a RSVG-Converter build for Windows, and, while it does a good job, it skips the Jpeg version of the image of a test file.
On the other hand, the built-in converter handles correctly both images, but does an awful job on the home image shown in the SVG tutorial.

Open Office for doc, docx and rtf to html conversion

How can i read formatted text as HTML from doc, docs and rtf files?
My script is on LAMP, can access openoffice installed on server for this type of conversion?
EDIT
Its not necessary that i want to access openoffice through a php extension or Apache module, if it is possible to use it using cli trhoug php, it would be fine too.
You can try Puno: http://www.wstech2.net/index.php?do=0a,01,05
This project is a PHP5 module written in C++ that brings the OpenOffice.org UNO Programming API to the PHP userspace.
It uses UNO Reflection API by OpenOffice for it. It's easy to start with. Check out sample example given there.

Conversion of an Adobe PDF to the JPEG

Is there any ready PHP-based soultiuon for creation of an JPEG images from the Adobe's PDF files? Just like this: http://www.convertpdftoimage.com/
The ImageMagick program allows conversion between graphic formats, and it includes support for reading PDF files. Therefore it should be able to convert PDF to JPG. (indeed, googling for ImageMagick pdf to jpg gives plenty of results, with good usage examples)
Furthermore, there is a PHP extension for ImageMagick, so if you have that extension included in your PHP, then it should be pretty simple (you can check which extensions are included in a given PHP installation by using the phpinfo() function).
If you don't have that extension (and you can't install it), you can still use ImageMagick, using it's command-line interface via the PHP shell_exec() function, etc.
I don't know about PHP. But we use this application: Callas pdfToolbox. It's standalone on your UNIX server.
Apache provides a Java solutions: PDFBox
Not sure PHP is capable of rendering PDF's. Getting the text out of then however should be easy.

Excel to PDF in PHP

I need to convert an Excel(.xls) spreadsheet to a PDF document with an image in PHP. If there is a library available please put the link.
Note - I have created excel(.xls) to PDF with "PHPExcel" library but my output is without image and border.
If PHPExcel can't do it, then you're stumped for a straight PHP solution, and might have to look at options like COM.
You don't mention what your problem is with the borders, and these have been a problem for some time in PHPExcel... the 1.7.6 version of PHPExcel resolved some of these issues, and there is a patch listed in the Issues section of the PHPExcel site that fixes some other problems with borders.
You can convert XLS files to PDF on Linux by installing OpenOffice
with a PDF writer as the default printer driver.
Then, you can call OpenOffice (from PHP) using the "-p" command-line
parameter, which will cause it to load a designated file and print it.
For example, if your file was "accounts.xls" you would call the
following command:
soffice -p accounts.xls
OpenOffice would load the "accounts.xls" file and "print" it to the
PDF writer, which would be configured to save the PDF document to the
desired filename.
GhostScript is a suitable PDF writer.
The OpenOffice setup guide describes how to install and configure
printer drivers using the "spadmin" utility, and discusses the use of
ghostscript as a PDF writer:
"Open Office Setup Guide - Appendix"
http://www.openoffice.org/docs/setup_guide/appendix.html
You can call OpenOffice from PHP by using the backtick execution
operator, or the "exec" function. You may also need to use PHP to move
and/or rename the resulting PDF files:
PHP: Program Execution Functions
http://www.php.net/manual/en/ref.exec.php
PHP: Filesystem: Rename
http://www.php.net/manual/en/function.rename.php
OpenOffice is pretty good at processing XLS files, but it may not
perfectly render every such file - so if you need the ultimate in
compatibility you will have to use Microsoft Excel on a Windows
Platform or emulator. "IT AsiaOne" looked at several alternatives to
Microsoft Office (including OpenOffice) and wrote that "while none of
the alternative suites promise ... full compatibility with Microsoft
Office-created documents, in general, they do a decent job of
translating Microsoft ".doc", ".ppt" and ".xls" file formats":
IT AsiaOne - Specials - Yours For The Picking
http://it.asia1.com.sg/specials/mmedia20020724_001.html
Additional links:
OpenOffice.org Home Page
http://www.openoffice.org/
Ghostscript Home Page
http://www.cs.wisc.edu/~ghost/
PHP Home Page
http://www.php.net/
Google search strategy:
openoffice scripting pdf linux
://www.google.com/search?q=openoffice%20scripting%20pdf%20linux
openoffice print "command line"
://www.google.com/search?q=openoffice%20scripting%20pdf%20linux
followed by a search for "command line parameters" from the
openoffice.org home page.
Ref

Categories