Why not adopt me?
NAME
HTML::FormatPS - Format HTML as PostScript
VERSION
version 2.16
SYNOPSIS
use HTML::TreeBuilder;
$tree = HTML::TreeBuilder->new->parse_file("test.html");
use HTML::FormatPS;
$formatter = HTML::FormatPS->new(
FontFamily => 'Helvetica',
PaperSize => 'Letter',
);
print $formatter->format($tree);
Or, for short:
use HTML::FormatPS;
print HTML::FormatPS->format_file(
"test.html",
'FontFamily' => 'Helvetica',
'PaperSize' => 'Letter',
);
DESCRIPTION
The HTML::FormatPS is a formatter that outputs PostScript code. Formatting of HTML tables and forms is not implemented.
HTML::FormatPS is built on top of HTML::Formatter and so further detail may be found in the documentation for HTML::Formatter.
You might specify the following parameters when constructing the formatter object (or when calling format_file or format_string):
- PaperSize
-
What kind of paper should we format for. The value can be one of these: A3, A4, A5, B4, B5, Letter, Legal, Executive, Tabloid, Statement, Folio, 10x14, Quarto.
The default is "A4".
- PaperWidth
-
The width of the paper, in points. Setting PaperSize also defines this value.
- PaperHeight
-
The height of the paper, in points. Setting PaperSize also defines this value.
- LeftMargin
-
The left margin, in points.
- RightMargin
-
The right margin, in points.
- HorizontalMargin
-
Both left and right margin at the same time. The default value is 4 cm.
- TopMargin
-
The top margin, in points.
- BottomMargin
-
The bottom margin, in points.
- VerticalMargin
-
Both top and bottom margin at the same time. The default value is 2 cm,
- PageNo
-
This parameter determines if we should put page numbers on the pages. The default value is true; so you have to set this value to 0 in order to suppress page numbers. (The "No" in "PageNo" means number/numero!)
- FontFamily
-
This parameter specifies which family of fonts to use for the formatting. Legal values are "Courier", "Helvetica" and "Times". The default is "Times".
- FontScale
-
This is a scaling factor for all the font sizes. The default value is 1.
For example, if you want everything to be almost three times as large, you could set this to 2.7. If you wanted things just a bit smaller than normal, you could set it to .92.
- Leading
-
This option (pronounced "ledding", not "leeding") controls how much is space between lines. This is a factor of the font size used for that line. Default is 0.1 -- so between two 12-point lines, there will be 1.2 points of space.
- StartPage
-
Assuming you have PageNo on, StartPage controls what the page number of the first page will be. By default, it is 1. So if you set this to 87, the first page would say "87" on it, the next "88", and so on.
- NoProlog
-
If this option is set to a true value, HTML::FormatPS will make a point of not emitting the PostScript prolog before the document. By default, this is off, meaning that HTML::FormatPS will emit the prolog. This option is of interest only to advanced users.
- NoTrailer
-
If this option is set to a true value, HTML::FormatPS will make a point of not emitting the PostScript trailer at the end of the document. By default, this is off, meaning that HTML::FormatPS will emit the bit of PostScript that ends the document. This option is of interest only to advanced users.
METHODS
new
my $formatter = FormatterClass->new(
option1 => value1, option2 => value2, ...
);
This creates a new formatter object with the given options.
SEE ALSO
ISSUES
Output is in ISO Latin1 format. The underlying HTML parsers tend to now work in Unicode (perl native) code points. There is an impedance mismatch between these, which may give issues with complex characters within HTML.
TO DO
Support for some more character styles, notably including: strike-through, underlining, superscript, and subscript.
Support for Unicode.
Support for Win-1252 encoding, since that's what most people mean when they use characters in the range 0x80-0x9F in HTML.
And, if it's ever even reasonably possible, support for tables.
I would welcome email from people who can help me out or advise me on the above.
AUTHORS
Nigel Metheringham <nigelm@cpan.org>
Sean M Burke <sburke@cpan.org>
Gisle Aas <gisle@ActiveState.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by Nigel Metheringham, 2002-2005 Sean M Burke, 1999-2002 Gisle Aas.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.