[1980] | 1 | #!/usr/bin/perl |
---|
| 2 | # ------------------------------------------------------------------------------ |
---|
| 3 | # (C) Crown copyright Met Office. All rights reserved. |
---|
| 4 | # For further details please refer to the file COPYRIGHT.txt |
---|
| 5 | # which you should have received as part of this distribution. |
---|
| 6 | # ------------------------------------------------------------------------------ |
---|
| 7 | |
---|
| 8 | use strict; |
---|
| 9 | use warnings; |
---|
| 10 | |
---|
| 11 | use FindBin; |
---|
| 12 | use lib "$FindBin::Bin/../lib"; |
---|
| 13 | use File::Basename qw{dirname}; |
---|
| 14 | use File::Spec; |
---|
| 15 | use FCM::Admin::Util qw{run_html2pdf}; |
---|
| 16 | use Getopt::Long qw{GetOptions}; |
---|
| 17 | use Pod::Usage qw{pod2usage}; |
---|
| 18 | |
---|
| 19 | main(); |
---|
| 20 | |
---|
| 21 | sub main { |
---|
| 22 | my %option = (); |
---|
| 23 | my $result = GetOptions( |
---|
| 24 | \%option, |
---|
| 25 | q{config|c=s}, |
---|
| 26 | q{help|usage|h}, |
---|
| 27 | ); |
---|
| 28 | if (!$result) { |
---|
| 29 | pod2usage(1); |
---|
| 30 | } |
---|
| 31 | if (exists($option{help})) { |
---|
| 32 | pod2usage(q{-verbose} => 1); |
---|
| 33 | } |
---|
| 34 | if (@ARGV != 2) { |
---|
| 35 | my $message = sprintf(qq{Expect 2 arguments, %d given}, scalar(@ARGV)); |
---|
| 36 | pod2usage({q{-exitval} => 1, q{-message} => $message}); |
---|
| 37 | } |
---|
| 38 | my ($html_path, $out_name) = @ARGV; |
---|
| 39 | my $pdf_path = File::Spec->catfile(dirname($html_path), "$out_name.pdf"); |
---|
| 40 | run_html2pdf($html_path, $pdf_path, \%option); |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | __END__ |
---|
| 44 | |
---|
| 45 | =head1 NAME |
---|
| 46 | |
---|
| 47 | fcm-html2pdf |
---|
| 48 | |
---|
| 49 | =head1 SYNOPSIS |
---|
| 50 | |
---|
| 51 | fcm-html2pdf [--config=HTML2PS-CSS] HTML-PATH OUT-NAME |
---|
| 52 | |
---|
| 53 | =head1 DESCRIPTION |
---|
| 54 | |
---|
| 55 | Converts a self contained set of HTML documents into a PDF. |
---|
| 56 | |
---|
| 57 | =head1 ARGUMENTS |
---|
| 58 | |
---|
| 59 | =over 4 |
---|
| 60 | |
---|
| 61 | =item HTML-PATH |
---|
| 62 | |
---|
| 63 | The path to the input HTML file. |
---|
| 64 | |
---|
| 65 | =item OUT-NAME |
---|
| 66 | |
---|
| 67 | The root name (basename without the extension) of the output file. The output is |
---|
| 68 | normally written to a file called I<OUT-NAME>.pdf in the directory containing |
---|
| 69 | L<HTML-PATH|/"HTML-PATH"> |
---|
| 70 | |
---|
| 71 | =back |
---|
| 72 | |
---|
| 73 | =head1 OPTIONS |
---|
| 74 | |
---|
| 75 | =over 4 |
---|
| 76 | |
---|
| 77 | =item --help, -h, --usage |
---|
| 78 | |
---|
| 79 | Prints help and exits. |
---|
| 80 | |
---|
| 81 | =item --config=HTML2PS -c HTML2PS |
---|
| 82 | |
---|
| 83 | Specifies a configuration file for the I<html2ps> command. If not specified, the |
---|
| 84 | configuration file is assumed to be a file called I<style.html2ps.css> in the |
---|
| 85 | directory containing L<HTML-PATH|/"HTML-PATH">. |
---|
| 86 | |
---|
| 87 | =back |
---|
| 88 | |
---|
| 89 | =head1 COPYRIGHT |
---|
| 90 | |
---|
| 91 | E<169> Crown copyright Met Office. All rights reserved. |
---|
| 92 | |
---|
| 93 | =cut |
---|