# html2ps/pdf script parameters

Back to table of contents

Note that parameter names are case-sensitive. This script accepts parameters passed using both the GET and POST methods. Script parameters (in alphabetical order) are:

Parameter | Description
--- | ---
batch[] | Specify a list of URL for "batch-processing" mode here. Note that ##PAGES## directive will not work in this case.
compress | Set this option to generate compressed Postscript files. You'll probably only need this option only if you're working with Postscript (NOT PDF) files via Adobe Acrobat Distiller, as it does not support compressed Postscript. In any other case, use compressed Postscript, as it will save on bandwidth. PDF files may be compressed, but you will need to unpack them manually before viewing.
cssmedia | HTML page can contain stylesheets for different target media types; for example, the printable version of a page may have navigation panes and banners hidden, while the version for handhelds may be specially formatted to work on small displays and so on. By setting the value of this parameter, you determine which set of CSS rules will be used during PS/PDF rendering.
debugbox | Set this option if you want to see boundaries of all boxes generated by the script. It is unlikely you'll need this option, as it is mostly for debugging purposes. Please note if you're using this option that the script renders the content boundary which is different from the "normal" box border!
encoding | Encoding can usually be automatically detected using HTTP response header or META tags inside the HTML. Sometimes, encoding information is missing; you can specify encoding name as a value of this parameter.
footerhtml | HTML string containing text to insert to every page footer. You may use 'style' attribute to control header/footer appearance; for example:
    <div style="background: red;">SOME TEXT</div>
Note this string must be (almost) valid XHTML (almost means that HTML/HEAD/BODY tags may be omitted). In particular: you should replace &,< and > with &amp;,&lt and &gt; correspondingly. All tags should be closed (including self-closing tags like BR or IMG). Tag and attribute names should be in lower case. See also: XHTML 1.0: Differences with HTML 4. For more sophisticated control over the header/footer data, please refer to CSS 3 margin boxes
headerhtml | HTML string containing text to insert to every page header. You may use 'style' attribute to control header/footer appearance; for example:
    <div style="background: red;">SOME TEXT</div>
Note this string must be (almost) valid XHTML (almost means that HTML/HEAD/BODY tags may be omitted). In particular: you should replace &,< and > with &amp;,&lt and &gt; correspondingly. All tags should be closed (including self-closing tags like BR or IMG). Tag and attribute names should be in lower case. See also: XHTML 1.0: Differences with HTML 4. For more sophisticated control over the header/footer data, please refer to CSS 3 margin boxes
html2xhtml | If you're absolutely sure you have valid strict XHTML page, you can set this option to disable HTML-to-XHTML conversion and speed up script execution a little. In any other case, do not set this option, as the script will not work with non-well-formed XML. Use this option at your own risk; if you encounts any errors first enable the HTML-to-XHTML conversion.
landscape | Set this parameter to rotate the media to landscape orientation. Please note that the 'virtual resolution' will remain the same; all page content will be scaled to fit the new page width.
leftmargin, rightmargin, topmargin, bottommargin | Page margins (millimeters). Note that you may calculate top and bottom margin height automatically to fit header/footer content (provided it is defined using CSS 3 margin boxes) by specifying zero values for topmargin AND bottommargin at the same time.
media | Name of predefined media to use. Note that media name is case-sensitive!
method | This option determines the type of script output: fastps -- Postscript; pdflib -- PDF generated using PDFLIB; fpdf -- PDF generated using FPdf
output | The value of this parameter determines how the generated file will be handled: 0 -- PDF file will be opened immediately (possibly in the same browser window). Note it will not work for Postscript files in most cases, they will be downloaded as usual; 1 -- user will be prompted to download generated file; 2 -- generated file will be stored on the server;
pageborder | Set this parameter if you want the page border to be printed.
pdfversion | This option determines the compatibility level of PDF to be generated; the higher level you use, more features can this PDF contain. On the other hand, high-level PDFs may not be readable by older viewer versions: 1.2 (Acrobat Reader 3) 1.3 (Acrobat Reader 4) 1.4 (Acrobat Reader 5) 1.5 (Acrobat Reader 6)
pixels | 'Virtual screen' horizontal resolution used during the page rendering process. As you know, a lot of HTML pages contain dimensions set in pixels -- images, in most cases, but sometimes fonts. Postscript/PDF files do not have "pixels", all dimensions are measured in "points" so we need to provide information about the pixel/point ratio. In our case, this ratio can be calculated as follows:
    R = (page full width in points - page horizontal margins in points) / virtual resolution
Thus, you can specify resolution in 800 pixels and make pages designed for 800x600 resolution to fit your printed page exactly. `index.php` provides three default values for this parameter: 640, 800 and 1024; if you need more exotic value, say 945, you may specify this in the script query string manually and still get correct results. Please note that pages may be cut off on the right side if they're designed for the higher resolution than you've specified (for example, if they have hardcoded table widths or wide images). It is a feature. In such cases please consider increasing 'pixels' value.
process_mode | Set this parameter to 'batch' to process several URLs at once and merge results in one PDF file; if this parameter have any other value, script runs in normal "single-url" mode.
pslevel | If this parameter have value of '3', the script will generate Postscript Level 3; otherwise – Postscript Level 2. Default value is '3'. This parameter does not affect PDF generation.
ps2pdf | Flag indicating whether script should convert generated Postscript file to PDF using Ghostscript utility. Note that generally script does not prevent you to enable this filter for 'fpdf' and 'pdflib' methods, but this will result in conversion error.
renderfields | Flag indicating whether script should render special fields like ##PAGE##. Fields will be rendered if this parameter is present (even if it has empty value)
renderforms | Flag indicating whether script should render interactive form controls. Forms will be rendered if this parameter is present (even if it has empty value)
renderimages | Flag indicating whether script should fetch and render image files. Images will be rendered if this parameter is present (even if it has empty value)
renderlinks | Flag indicating whether script should render internal and external hyperlinks. Links will be rendered if this parameter is present (even if it has empty value)
scalepoints | When a page contains both device-dependent (in pixels) and device-independent (in points) dimensions, we're in trouble. For example, imagine a page containing absolute-positioned text inside the image; in this case, as display and paper have different sizes, point/pixel ratio will be different in the browser window and file rendered by the script, possilibly breaking the page layout. To prevent this, the `scalepoint` option is used. If this parameter is set, the HTML page "points" are scaled to keep the mentioned ratio, so if you print the resulting file and measure fonts, they will be smaller than you expect, but the page layout will be exactly the same as you see in browser window (well, close to it). If you want fonts to have their real size, disable this option. Note that this additional scaling applies to points only; such units as in, cm, mm and pc are not affected by this option.
toc | Flag indicating whether script should automatically generate table of contents
toc-location | Defines the place where to place generated table of contents: `before` — on the first (separate) page `after` — on the last (separate) page (default) `placeholder` — replace placeholder DIV
URL | URL you're going to convert (page should be available via either `http` or `https`). Note that the `http://` prefix is prepended to this value automatically in case no http or https protocol part is found, thus you may set the value of this parameter, for example, to `www.google.com`, not `http://www.google.com`. Note that if you're trying to use URL containing GET request (e.g. http://www.google.com/search?q=test), you must apply urlencode function to this url.
watermarkhtml | HTML string containing text to display across every page.

Top↑