NAME
Catalyst::View::ChromePDF - convert HTML (or TT) content to PDF using Chrome
VERSION
version v0.1.2
SYNOPSIS
In your application, create a view, e.g. lib/MyApp/View/ChromePDF.pm:
package MyApp::View::ChromePDF;
use Moose;
extends 'Catalyst::View::ChromePDF';
__PACKAGE__->meta->make_immutable();
In the application, e.g. lib/MyApp.pm specify the "CONFIGURATION":
__PACKAGE__->config(
# Configure Template-Toolkit
'View::TT' => {
INCLUDE_PATH => [ __PACKAGE__->path_to('root'), ],
ENCODING => 'utf-8',
TIMER => 0,
TEMPLATE_EXTENSION => '.tt',
ABSOLUTE => 1,
render_die => 1
},
# Configure View::ChromePDF
'View::ChromePDF' => {
stash_key => 'pdf',
page_size => 'a4',
},
);
In a controller method, specify "PARAMETERS":
$c->stash->{pdf} = {
template => 'base.tt',
page_size => 'a5', # override default
};
$c->forward('View::ChromePDF');
DESCRIPTION
This is a Catalyst view for rendering web pages of PDFs using Chrome or a Chrome-compatible browser with WWW::Mechanize::Chrome.
It is intended as a successor to Catalyst::View::Wkhtmltopdf.
CONFIGURATION
tmpdir
This is the temporary directory.
It defaults to the File::Spec tmpdir.
See "SECURITY CONSIDERATIONS" below.
tt_view
This is the template view. It defaults to "TT" for Catalyst::View::TT.
stash_key
It defaults to "pdf".
Note: for Catalyst::View::Wkhtmltopdf compatibility, use "wk".
chrome_args
This contains additional arguments to pass to the constructor of WWW::Mechanize::Chrome.
This will be ignored if a separate "mech" argument is passed in the stash.
format
This is the paper format. It defaults to undef.
page_size
This is an alias for "format", for compatibility with Catalyst::View::Wkhtmltopdf.
orientation
The is the orientation, it defaults to "portrait".
Acceptable values are "portrait" or "landscape".
disposition
This is the download disposition. It defaults to "inline".
Acceptable values are "inline" or "attachment".
filename
This is the attachment filename. It defaults to output.pdf.
METHODS
process
render
PARAMETERS
template
This this is not specified, then it will default to using $c-stash->{template}>.
html
This is the raw HTML to render, if no "template" is specified.
Otherwise, it will render the Catalyst::Response body.
mech
This is a WWW::Mechanize::Chrome instance.
If omitted, a new instance will be created and then closed, using the "chrome_args".
send_filehandle
format
This is the format or paper size.
page_size
This is the same as format, but is added for compatibility with Catalyst::View::Wkhtmltopodf.
paper_width
paper_height
Specify the paper width and height as an alternative to specifying the "format".
These are in inches, as that is what WWW::Mechanize::Chrome uses.
orientation
COMPATIBILITY
Differences from Catalyst::View::Wkhtmltopdf
There is no
commandattribute.Instead, you need to specify the
launch_exepath in "chrome_args", e.g.<View::ChromePDF> <chrome_args> launch_exe /opt/chrome/bin/chrome </chrome_args> </View::ChromePDF>Additional command-line switches should be specified using
launch_arg.orientationmust be lowercase, e.g. "portrait" instead of "Portrait"."stash_key" has a different default.
Margins, DPI, and image quality options are not supported.
Some of these options may be added in the future.
SECURITY CONSIDERATIONS
HTML
It is assumed that the content of the rendered HTML that as saved as a PDF is controlled and trusted by the developer.
The default configuration of "mech" does not block file: URLs. That is a feature, not a bug or oversight.
Temporary Files
Temporary HTML and PDF files are saved in "tmpdir". They may be left in the directory on failure.
When returning a filehandle instead of the PDF content, the PDF files are not removed when "send_filehandle" is true.
A separate process will need to purge files, to prevent them from filling the disk, as well as to remove sensitive information.
SOURCE
The development version is on github at https://github.com/robrwo/perl-Catalyst-View-ChromePDF and may be cloned from https://github.com/robrwo/perl-Catalyst-View-ChromePDF.git
SUPPORT
Only the latest version of this module will be supported.
This module requires Perl v5.24 or later. Future releases may only support Perl versions released in the last ten (10) years.
Reporting Bugs and Submitting Feature Requests
Please report any bugs or feature requests on the bugtracker website https://github.com/robrwo/perl-Catalyst-View-ChromePDF/issues
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
Reporting Security Vulnerabilities
Security issues should not be reported on the bugtracker website. Please see SECURITY.md for instructions how to report security vulnerabilities
AUTHOR
Robert Rothenberg <perl@rhizomnic.com>
The initial development of this module was sponsored in part by Science Photo Library https://www.sciencephoto.com.
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Robert Rothenberg <perl@rhizomnic.com>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.