source: XIOS/tools/FCM/examples/sbin/fcm-html2pdf @ 1385

Last change on this file since 1385 was 81, checked in by ymipsl, 12 years ago

ajout FCM 1.5

File size: 2.0 KB
Line 
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
8use strict;
9use warnings;
10
11use FindBin;
12use lib "$FindBin::Bin/../lib";
13use File::Basename qw{dirname};
14use File::Spec;
15use FCM::Admin::Util qw{run_html2pdf};
16use Getopt::Long qw{GetOptions};
17use Pod::Usage qw{pod2usage};
18
19main();
20
21sub 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
47fcm-html2pdf
48
49=head1 SYNOPSIS
50
51    fcm-html2pdf [--config=HTML2PS-CSS] HTML-PATH OUT-NAME
52
53=head1 DESCRIPTION
54
55Converts a self contained set of HTML documents into a PDF.
56
57=head1 ARGUMENTS
58
59=over 4
60
61=item HTML-PATH
62
63The path to the input HTML file.
64
65=item OUT-NAME
66
67The root name (basename without the extension) of the output file. The output is
68normally written to a file called I<OUT-NAME>.pdf in the directory containing
69L<HTML-PATH|/"HTML-PATH">
70
71=back
72
73=head1 OPTIONS
74
75=over 4
76
77=item --help, -h, --usage
78
79Prints help and exits.
80
81=item --config=HTML2PS -c HTML2PS
82
83Specifies a configuration file for the I<html2ps> command. If not specified, the
84configuration file is assumed to be a file called I<style.html2ps.css> in the
85directory containing L<HTML-PATH|/"HTML-PATH">.
86
87=back
88
89=head1 COPYRIGHT
90
91E<169> Crown copyright Met Office. All rights reserved.
92
93=cut
Note: See TracBrowser for help on using the repository browser.