Command line printing with Firefox

To print from the command line with Firefox, you need to install an extension. One such extension is
Command Line Print by torisugari.

This extension allows you to print URLs immediately, without user interaction. This can be useful to convert html pages to PDF for example.

You first have to install the extension from

After you've properly installed the extension, you can start using Firefox as command line printer.


$>firefox -print
$>firefox -print -printmode pdf -printfile foobar.pdf
$>firefox -print -printmode PNG

Documentation from the author:
-print @required. If not set, a normal browser launches.

-printmode mode @optional. mode is either {0, 1, 2, printer, pdf, png}. Case-insensitive. If not set, this application behaves according to pref settings. See also: Tools -> Add-ons -> Extensions -> Command Line Print -> Options. Note that PNG requires Firefox version is equal to or more than 2.0, and PDF requires Firefox version is => 3.0, while PRINTER should work with Firefox 1.5.

-printfile filepath @optional. filepath is an absolute, or a relative path from the current directory, like other CLI applications. Any local path will do, as long as Gecko understands where. This option will be ignored, if mode is PRINTER. If not set, the file will be saved at default location: download directory, where you can set Tools -> Options -> Main -> Downloads.



Print to pdf

Thanks for this tool - it is really useful.

However I can't get printing to a pdf to work on XP. If I put the path to the printfile - firefox says "An unknown error occurred while printing". If I just put a file name I get blank documents.

Any ideas? My command line is:

firefox -print slide.xml -printmode pdf -printfile slide.pdf



The latest version of print

The latest version of print from command line is 0.5.2, did you try that one?

As far as I know, you have to specify the full URL, not just a filename or pathname.