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.
Related
I am trying to automate some stuff and need to then replace some text in a PDF document generated from InDesign. It's on a linux server so I am looking for a PHP script to replace the text - either in the Indesign document or even better the PDF file - if that is even possible?
Why do you rather replace your text in PDF instead of the Indesign file? Isn't is necessary to have your sourcefiles up-to-date?
You probably want to look at IDML which is de XML-based format of Indesign (indd) files. You can probably convert your indd files serverside to idml files.
There are several PHP libraries to read and write within idml files (not tested by me, not a PHP guy).
https://github.com/jorisros/IDMLlib
https://github.com/deathlyfrantic/php-idml
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.
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.
I'm working on a project in PHP that needs to render dynamically-created SVG images to PNG (or GIF if not PNG) format. I know I can do this by invoking a SVG renderer like rsvg, or with an extension like ImageMagick, which isn't that common*.
Is there a "drop-in" style library that can render SVG using things like GD and DomDocument?
* Available in common webhosts and in packages like XAMPP.
To clarify, I already have the SVG itself generated, I just need it to be rendered server-size.
It shouldn't be too hard to do yourself. SVG is a fairly simple specification, so there shouldn't be too much guess work building a converter... The only difficult parts that I can see would be gradients, markers and filters. The rest should be relatively straight forward when looking at the gd functions available.
Obviously, the best would be to find a stand alone library, but if you can't you could always roll one yourself...
If you have Java on the server, you can use Batik's SVG Rasterizer, which comes as a standalone executable JAR. Call it using PHP exec.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Convert HTML + CSS to PDF with PHP?
I want to convert a web page to a high-resolution PDF suitable for printing. How can I do this?
If you want to do it in code, have a look at HTML2PDF or FPDF, they are php libraries designed to create PDF documents with code.
If you combine HTML2PDF with PHP's output buffering functions
ie
<?php
ob_start();
?>
// put all your html in here
<?php
$data = ob_get_contents();
require('html2pdf.php');
$pdf = new HTML2FPDF();
$pdf->AddPage();
$pdf->WriteHTML($data);
$pdf->Output();
?>
Obviously that is a very rough example but I have used that before within php to generate pdfs. It does have some issues with stylesheets, it seems to ignore most of them. But more control can be gained by using FPDF by itself and manually building the documents.
Try: "wkhtmltopdf" it just work great (and its -open source-). It uses webkit engine (used by safari, chrome browsers) and it is very easy to use :
wkhtmltopdf stackoverflow.com/questions/1878512/ output.pdf
Try it! for Linux and Windows as well. Easy to install. If you use ubuntu, type:
aptitude install wkhtmltopdf
if you want to convert web page using browser, you can use sofware in windows like cutepdf, dopdf etc.
but if you want to convert a web page into pdf by php code (on the fly), there are several ways to convert:
Using library provided, you can try html2pdf (php).
In java / .net a library like pd4ml can be used (even it is not free).
You can use open office converter. It can open multiple doc type, and convert into pdf. Open office provide API (I have tried in java, not php). The flow is same like you open the document, then convert into pdf, but you just do it in your coding. Must have open office server daemon to listen the converter via your code. See here http://oodaemon.sourceforge.net/
If you want quick solution in PHP, maybe you can use html2pdf.
The advantage you use open office converter is the output will be same as you see in browser (I already test it use oodaemon). If using library I am not sure 100% it will be same if you open in browser, because the layout is depend on CSS. pd4ml generate layout in pdf base on html and css (has it owns CSS parser I think)