html2ps/pdf FAQ

Back to table of contents

How would I report a bug?

Use the support forum of tufat.com.

Please, provide the following:

The will greatly reduce the time required for solving your issue. Thank you for understanding.

Installation.

Can I call this script from the command line?
Probably yes; check if your PHP support command line interface. Also, consider reading this article on php.net: Using PHP from the command line

No output at all. Broken output.

All I'm getting is a blank page; no error messages in PHP error log. Whats happened?
The script is probably running out of memory or execution time. Try increasing the values of max_execution_time and/or memory_limit PHP configuration variables. Recommended values are 120 seconds and 32 megabytes. Nevertheless, if you're using VERY big images, you'll probably need to increase these values even more.
I've increased the limits, but still sometimes get a blank page immediately after the script starts! Some sites are parsed, though...
Some users encountered this problem using the GD library bundled with PHP. While it matched the GD version requirement, it sometimes caused PHP to silently die on some images. The problem is solved by recompiling the PHP using the external (recent enough) GD library. Note that NOT ALL PHP configurations are subject to this problem.
Generated Poscript files print very slowly or even do not print at all

If you're sending PS directly to the printer, you should keep in mind that image-containing PS files require a lot of memory and computational resources to render due to the way it is generated, so the printer may just run out of memory trying to print it.

You may consider using the Ghostscript ps2ps script as a printing filter, this should speed up the printing process, as most computations will be done by computer instead of printer.

Also note that current version of HTML2PS generated Postscript Level 3! We're planning to implement Level 2 output soon; meanwhile, you need to use ps2ps filter to print it on the non-PS-Level-3 compliant printer.

I'm getting "PDF doesn't start with "%PDF-" message from Acrobat Reader. Nevertheless, when I save file to my hard drive, it opens perfectly. I'm using Firefox.
There were user reports on issues related to Firefox/Acrobat Reader plugin incompatibility. In particular, this problem appeared with Firefox 1.0.7 and Reader 6.0.2 PL. You may consider upgrading your software to latest versions in this case.

Broken layout.

Sites are cut-off on the right side when I'm using 640 pixels page width. What can I do?
Nothing. Treat this as a feature. Just increase the page width. Most sites are NOT designed for such small resolutions and will cause a horizontal scrollbar to appear in browser in such cases.
I've disabled the "Keep screen pixel/point ratio" option and the page layout is completely broken! What can I do?
Nothing. Treat this as a feature. If you want to get the layout close to the image rendered by the browser, never disable this option. The only time you'll need it is when you need to render text having the exact size specified in points.

Customizing output.

How can I make an explicit page break?
You may use one of the following HTML2PS script-specific commands:
<!--NewPage-->
<pagebreak/>
<?page-break>
Or CSS page-break-after property:
<div style="page-break-after: always">
... some content ...
</div>
How should I add headers or footers to generated Postscript / PDF files?
Use 'position: fixed'. Example
I've added headers and footers to my HTML pages, but how I can prevent them from showing up in the browser?
Use CSS @media rules; as you may specify which set of media rules the script should use during conversion, you may optionally show or hide particular page elements like navigation bars or headers in generated files. Example
Is there a possibility to create pdf documents with more than 72dpi using html2ps?
You may make a page with high-resolution images and set their on-page height and width using height and width attributes. HTML2PS does not resample images, just outputs them to PDF and provides the scaling factor.

Fonts. National symbols.

How can I use fonts other than standard (Times, Helvetica and Courier)?
Follow these instructions
Cyrillic symbols are not displayed in PS output
Install sharatype-fonts package to your Ghostscript; the script is configured to use these fonts out-of-the-box.
Greek symbols with tonos are not displayed in PS output; all other greek symbols rendered normally.
Chinese (Japanese, Arabic, etc...) symbols do not show on the page. What I need to do?
First of all, you'll need fonts containing these symbols; in most cases default fonts bundled with Ghostscript or PDFLIB will contain only Western/Central European symbols. After you find fonts containing characters you need, you should install them instead of the standard fonts, using the answer for this question «How can I use fonts other than standard (Times, Helvetica and Courier)?»

Miscellanous

Is it possible when outputting the pdf file to use a custom file name? As of right now, the filename is long ugly string and doesn't look very clean. Can I pass the script a varible such as &saveas=thispdffile.pdf and use that for the file name when saving in the browser?
Yes. You would need to replace $g_baseurl with $_REQUEST['saveas'] in the following piece of code near the end of html2ps.php:
switch ($g_config['output']) {
case 0:
   $pipeline->destination = new DestinationBrowser($g_baseurl);
   break;
case 1:
   $pipeline->destination = new DestinationDownload($g_baseurl);
   break;
case 2:
   $pipeline->destination = new DestinationFile($g_baseurl);
   break;
}; 
Also please note that by default output file name can contain only latin letters, digits, '-' and '_' signs, any other symbols will be replaced by underscores; you may change this behavior by hacking the filename_escape function in destination._interface.class.php.