1 package C4::Creators::PDF;
3 # Copyright 2009 Foundations Bible College.
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
23 use PDF::Reuse::Barcode;
25 use List::Util qw/first/;
38 my $type = ref($invocant) || $invocant;
41 _InitVars() if ($opts{InitVars} == 0);
42 _InitVars($opts{InitVars}) if ($opts{InitVars} > 0);
43 delete($opts{InitVars});
44 prDocDir($opts{'DocDir'}) if $opts{'DocDir'};
45 delete($opts{'DocDir'});
47 my $fh = File::Temp->new( UNLINK => 0, SUFFIX => '.pdf' );
48 $opts{Name} = $self->{filename} = "$fh"; # filename
49 close $fh; # we need just filename
61 # slurp temporary filename and print it out for plack to pick up
63 open(my $fh, '<', $self->{filename}) || die "$self->{filename}: $!";
66 unlink $self->{filename};
77 my $reference = shift;
78 prBookmark($reference);
83 my $directive = shift;
84 prCompress($directive);
96 return prDocForm(%params);
101 my ($pdfFile, $pageNo, $oldInternalName) = @_;
102 return prExtract($pdfFile, $pageNo, $oldInternalName);
107 my ($fieldName, $value) = @_;
108 prField($fieldName, $value);
113 my $fontName = shift;
115 my $ttf = C4::Context->config('ttf');
118 my $ttf_path = first { $_->{type} eq $fontName } @{ $ttf->{font} };
119 if ( -e $ttf_path->{content} ) {
120 return prTTFont($ttf_path->{content});
122 warn "ERROR in koha-conf.xml -- missing <font type=\"$fontName\">/path/to/font.ttf</font>";
125 return prFont($fontName);
131 return prFontSize($size);
137 return prForm(%params);
142 return prGetLogBuffer();
148 prGraphState($string);
154 return prImage(%params);
159 my ($string, $duplicateCode) = @_;
160 prInit($string, $duplicateCode);
165 my ($imageData, $width, $height, $imageFormat, $altImageData, $altImageWidth, $altImageHeight, $altImageFormat) = @_;
166 return prAltJpeg($imageData, $width, $height, $imageFormat, $altImageData, $altImageWidth, $altImageHeight, $altImageFormat);
171 my ($imageData, $width, $height, $imageFormat) = @_;
172 return prJpeg($imageData, $width, $height, $imageFormat);
177 my $string_or_fileName = shift;
178 prJs($string_or_fileName);
195 my $directory = shift;
196 prLogDir($directory);
201 my ($lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY) = @_;
202 prMbox($lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY);
213 my ($file, $pageNumber) = @_;
214 return prSinglePage($file, $pageNumber);
219 my ($string, $font, $fontSize) = @_;
221 # replace font code with correct internal font
222 $font = C4::Creators::PDF->Font($font);
224 return prStrWidth($string, $font, $fontSize);
229 my ($x, $y, $string, $align, $rotation) = @_;
230 return prText($x, $y, $string, $align, $rotation);
236 return prTTFont($path);
242 PDF::Reuse::Barcode::Code128(%opts);
248 PDF::Reuse::Barcode::Code39(%opts);
254 PDF::Reuse::Barcode::COOP2of5(%opts);
260 PDF::Reuse::Barcode::EAN13(%opts);
266 PDF::Reuse::Barcode::EAN8(%opts);
272 PDF::Reuse::Barcode::IATA2of5(%opts);
278 PDF::Reuse::Barcode::Industrial2of5(%opts);
284 PDF::Reuse::Barcode::ITF(%opts);
290 PDF::Reuse::Barcode::Matrix2of5(%opts);
296 PDF::Reuse::Barcode::NW7(%opts);
302 PDF::Reuse::Barcode::UPCA(%opts);
308 PDF::Reuse::Barcode::UPCE(%opts);
317 C4::Creators::PDF - A class wrapper for PDF::Reuse and PDF::Reuse::Barcode to allow usage as a pseudo-object. For usage see
318 PDF::Reuse documentation and C4::Creators::PDF code.
324 Chris Nighswonger <cnighswonger AT foundations DOT edu>