![]() |
![]()
| ![]() |
![]()
NAMEPDF::WebKit - Use WebKit to Generate PDFs from HTML (via wkhtmltopdf)SYNOPSISuse PDF::WebKit; # PDF::WebKit->new takes the HTML and any options for wkhtmltopdf # run `wkhtmltopdf --extended-help` for a full list of options my $kit = PDF::WebKit->new(\$html, page_size => 'Letter'); push @{ $kit->stylesheets }, "/path/to/css/file"; # Get an inline PDF my $pdf = $kit->to_pdf; # save the PDF to a file my $file = $kit->to_file('/path/to/save/pdf'); # PDF::WebKit can optionally accept a URL or a File # Stylesheets cannot be added when source is provided as a URL or File. my $kit = PDF::WebKit->new('http://google.com'); my $kit = PDF::WebKit->new('/path/to/html'); # Add any kind of option through meta tags my $kit = PDF::WebKit->new(\'<html><head><meta name="pdfkit-page_size" content="Letter"...'); DESCRIPTIONPDF::WebKit uses wkhtmltopdf <http://code.google.com/p/wkhtmltopdf/> to convert HTML documents into PDFs. It is a port of the elegant PDFKit <https://github.com/jdpace/PDFKit> Ruby library.wkhtmltopdf generates beautiful PDFs by leveraging the rendering power of Qt's WebKit browser engine (used by both Apple Safari and Google Chrome browsers). ConfigurationConfiguration of PDF::WebKit is configured globally by calling the "PDF::WebKit->configure" class method:PDF::WebKit->configure(sub { # default `which wkhtmltopdf` $_->wkhtmltopdf('/path/to/wkhtmltopdf'); # default 'pdf-webkit-' $_->meta_tag_prefix('my-prefix-'); $_->default_options->{'--orientation'} = 'Portrait'; }); See the new method for the standard default options. Constructor
Methods
SEE ALSOPDFKit <https://github.com/jdpace/PDFKit>, wkhtmltopdf <http://code.google.com/p/wkhtmltopdf/>, WKHTMLTOPDF <http://search.cpan.org/~tbr/WKHTMLTOPDF-0.02/lib/WKHTMLTOPDF.pm> (a lower-level wrapper for wkhtmltopdf).AUTHORPhilip Garrett <philip.garrett@icainformatics.com>CONTRIBUTORSChristian Walde <walde.christian@gmail.com>CONTRIBUTINGIf you'd like to contribute, just fork my repository on Github, commit your changes and send me a pull request.http://github.com/kingpong/perl-PDF-WebKit ACKNOWLEDGMENTSThis code is nearly a line-by-line port of Jared Pace's PDFKit. https://github.com/jdpace/PDFKitCOPYRIGHT & LICENSECopyright (c) 2011 by Informatics Corporation of America.This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
|