blib/lib/Acme/PDF/rescale.pm untested

filter: Statementstmt 0.0% 0 / 27 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 41 CC 1 SCAR 6.9
CC
1
Cov
0%
base_name
2.0
make_tex_file
2.0
compile_tex_file
2.0
CRAP 2.0
1 package Acme::PDF::rescale;
2 use strict;
3 use vars qw(@ISA @EXPORT_OK $VERSION %EXPORT_TAGS);
4  
5 =head1 NAME
6  
7 Acme::PDF::rescale - A stupid module just to get trained with CPAN.
8  
9 =head1 SYNOPSIS
10  
11 use Acme::PDF::rescale qw(:all);
12  
13 =head1 DESCRIPTION
14  
15 =head2 Overview
16  
17 I just wrote this module to learn how to upload something on CPAN.
18  
19 Anyway, you may find the L<pdfrescale> script useful. It is installed
20 with the module. It has its own documentation. It allows to rescale a
21 pdf file, using a dirty trick : it creates a LaTeX file and calls
22 pdflatex (uses the pdfpages package).
23  
24 =head2 Methods
25  
26 Useless subs were written, so that there is actually a
27 module and not just a script. If you B<really> want to use this,
28 you'd better read the script itself.
29  
30 =over
31  
32 base_name(pdffilename)
33  
34 make_tex_file(basename, pdffilename, scale, offset)
35  
36 compile_tex_file(basename)
37  
38 clean_tex_files(basename)
39  
40 =back
41  
42 =cut
43  
44 require Exporter;
45 @ISA = qw(Exporter);
46 @EXPORT_OK = qw(base_name make_tex_file compile_tex_file clean_tex_files);
47 %EXPORT_TAGS = ('all' => \@EXPORT_OK);
48 $VERSION = '0.2';
49  
50 sub base_name
51 {
52 my $name = shift;
53 $name =~ s/\.pdf$//;
54 $name .= "-scaled";
55 return $name;
56 }
57  
58 sub make_tex_file
59 {
60 my ($base_name, $file, $scale, $offset) = @_;
61 open OUT, ">$base_name.tex" or die "$base_name.tex : $!";
62 print OUT <<EOF
63 \\documentclass{article}
64 \\usepackage{pdfpages}
65 \\begin{document}
66 \\includepdf[pages=-,scale=$scale,offset=$offset]{$file}
67 \\end{document}
68 EOF
69 ;
70 close OUT;
71 }
72  
73 sub compile_tex_file
74 {
75 my $base_name = shift;
76 qx(pdflatex $base_name.tex);
77 }
78  
79 sub clean_tex_files
80 {
81 my $base_name = shift;
82 unlink "$base_name.tex";
83 unlink "$base_name.log";
84 unlink "$base_name.aux";
85 }