# html2ps/pdf FAQ

Back to table of contents

- Installation
- No output at all. Broken output.
- Broken layout.
- Customizing output.
  - How can I make an explicit page break?
  - How should I add headers or footers to generated Postscript / PDF files?
  - I've added headers and footers to my HTML pages, but how I can prevent them from showing up in the browser?
  - Is there a possibility to create pdf documents with more than 72dpi using html2ps?
- Fonts. National symbols.
- Interactive forms.
- Frames.
- Miscellanous.

## How would I report a bug?

Use the support forum of tufat.com.

Please, provide the following:

- `phpinfo()` output;
- script version (and information about applied patches, if any);
- script parameters you're using for conversion;
- full HTML code of the page you're trying to convert.

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.
  Another cause may be a JavaScript or META redirect on page you're trying to convert. As HTML2PS script is not designed as interactive user agent, it will not follow such redirects for you. You may try to open the url in question in your browser and check if the URL will change when page finishes loading. In this case, just supply the final URL to the script.
  Also, please note that domain.com and www.domain.com may point to different sites. In the worst case, domain.com (without 'www' part) may just ignore HTTP requests. On the other side, popular browsers try to guess correct URL; for example, when you enter 'something' to the address bar, they may try to get something.com or www.something.com. This may lead to problem similar to one described in previous paragraph; the solution is the same: open URL in browser and check it will change.

The script just hangs when converting page containing images! WIth "render images" options disabled it works!
  There were reports on this problem on Windows recently. A quick investigation showed that for some reason PHP 4.4.0 sometimes hangs indefinitely inside the 'fsockopen' call. Consider upgrading your PHP version in this case.
I'm using PHP 4.4.2 on Windows and almost always conversion results in blank page or error 404
  Unfortunately, there's a strange problem with official Windows PHP 4.4.2 binaries from PHP.net: the PHP process dies on calls to file_get_contents using http:// protocol. I would recommend either downgrading to earlier 4.4.x versions or installing PHP 5.
I've increased 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.
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.
Some images are rendered inside black rectangles!
  PNG images with alpha channel are NOT supported. Swicth to single-color transparency, if you need it.

## 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?
  You may use one of these two options:
  - Use blocks with 'position: fixed'. Pleas note that you probably want to set 'top' and 'bottom' properties to negative values to avoid overlapping with main content; it is an expected behavior according to HTML/CSS standards. (see also a simple sample)
  - Use "Header" and "Footer" options in web interface or PreTreeFilterHeaderFooter filter in API
I've added headers and footers to my HTML pages, but how I can prevent them from showing up in the browser?
  Use @media css rules setting 'display: none' or 'display: block' for header/footer blocks on different media.
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.
  - install the unicode postscript .pfb fonts (for example, from http://canopus.iacp.dvo.ru/~panov/cm-unicode/)
  - remove the following default 'encoding-override' section from .html2ps.config, as it make greek text to use by default 'Symbol' font lacking 'tonos' symbols:

        <encoding-override name="iso-8859-7">
          <normal normal="Symbol" italic="Symbol" oblique="Symbol"/>
          <bold normal="Symbol" italic="Symbol" oblique="Symbol"/>
        </encoding-override>

  - update "fonts" (NOT "fonts-pdf") section to point to installed fonts, for example:

        <fonts>
          <family name="times">
            <normal normal="CMUSansSerif" italic="CMUSansSerif-Oblique" oblique="CMUSansSerif-Oblique"/>

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)?»

## Interactive forms

When I try to submit the form, Acrobat responds with a "Cannot handle content type: …" message.
Every time I submit the form, I get a strange-looking result page in by browser.
  PDF interactive forms are not like HTML forms; you MUST modify the server-side script so it return FDF file instead of normal HTML in this case. See PDF Reference, v 1.6, page 1026, par. 134 for futher information. Also, you may check for a brief outline of PDF forms.

## Frames

I have a page with frames containing a lot of text, but generated PDF contains only 1 page. Where's my content?
  As produced PDFs are static, you have no ways to scroll frame content. Thus, only initially visible frame content will be available. It is a feature.
Some links inside the frames are not active even when I enable "Render Hyperlinks" option.
  As was stated previously, script may render only a part of frame content. So, if rendered part contains a local hyperlink pointing to non-rendered part, this hyperlink will be disabled, as it points to nowhere.

## 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. If you're using the web interface (html2ps.php file from distribution) 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`.

  If you're using API, refer to DestinationBrowser/DestinationDownload/DestinationFile class documentation.