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/;
36 my $type = ref($invocant) || $invocant;
39 _InitVars
() if ($opts{InitVars
} == 0);
40 _InitVars
($opts{InitVars
}) if ($opts{InitVars
} > 0);
41 delete($opts{InitVars
});
42 prDocDir
($opts{'DocDir'}) if $opts{'DocDir'};
43 delete($opts{'DocDir'});
45 my $fh = File
::Temp
->new( UNLINK
=> 0, SUFFIX
=> '.pdf' );
46 $opts{Name
} = $self->{filename
} = "$fh"; # filename
47 close $fh; # we need just filename
59 # slurp temporary filename and print it out for plack to pick up
61 open(my $fh, '<', $self->{filename
}) || die "$self->{filename}: $!";
64 unlink $self->{filename
};
75 my $reference = shift;
76 prBookmark
($reference);
81 my $directive = shift;
82 prCompress
($directive);
94 return prDocForm
(%params);
99 my ($pdfFile, $pageNo, $oldInternalName) = @_;
100 return prExtract
($pdfFile, $pageNo, $oldInternalName);
105 my ($fieldName, $value) = @_;
106 prField
($fieldName, $value);
111 my $fontName = shift;
113 my $ttf = C4
::Context
->config('ttf');
116 my $ttf_path = first
{ $_->{type
} eq $fontName } @
{ $ttf->{font
} };
117 if ( -e
$ttf_path->{content
} ) {
118 return prTTFont
($ttf_path->{content
});
120 warn "ERROR in koha-conf.xml -- missing <font type=\"$fontName\">/path/to/font.ttf</font>";
123 return prFont
($fontName);
129 return prFontSize
($size);
135 return prForm
(%params);
140 return prGetLogBuffer
();
146 prGraphState
($string);
152 return prImage
(%params);
157 my ($string, $duplicateCode) = @_;
158 prInit
($string, $duplicateCode);
163 my ($imageData, $width, $height, $imageFormat, $altImageData, $altImageWidth, $altImageHeight, $altImageFormat) = @_;
164 return prAltJpeg
($imageData, $width, $height, $imageFormat, $altImageData, $altImageWidth, $altImageHeight, $altImageFormat);
169 my ($imageData, $width, $height, $imageFormat) = @_;
170 return prJpeg
($imageData, $width, $height, $imageFormat);
175 my $string_or_fileName = shift;
176 prJs
($string_or_fileName);
193 my $directory = shift;
194 prLogDir
($directory);
199 my ($lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY) = @_;
200 prMbox
($lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY);
211 my ($file, $pageNumber) = @_;
212 return prSinglePage
($file, $pageNumber);
217 my ($string, $font, $fontSize) = @_;
219 # replace font code with correct internal font
220 $font = C4
::Creators
::PDF
->Font($font);
222 return prStrWidth
($string, $font, $fontSize);
227 my ($x, $y, $string, $align, $rotation) = @_;
228 return prText
($x, $y, $string, $align, $rotation);
234 return prTTFont
($path);
240 PDF
::Reuse
::Barcode
::Code128
(%opts);
246 PDF
::Reuse
::Barcode
::Code39
(%opts);
252 PDF
::Reuse
::Barcode
::COOP2of5
(%opts);
258 PDF
::Reuse
::Barcode
::EAN13
(%opts);
264 PDF
::Reuse
::Barcode
::EAN8
(%opts);
270 PDF
::Reuse
::Barcode
::IATA2of5
(%opts);
276 PDF
::Reuse
::Barcode
::Industrial2of5
(%opts);
282 PDF
::Reuse
::Barcode
::ITF
(%opts);
288 PDF
::Reuse
::Barcode
::Matrix2of5
(%opts);
294 PDF
::Reuse
::Barcode
::NW7
(%opts);
300 PDF
::Reuse
::Barcode
::UPCA
(%opts);
306 PDF
::Reuse
::Barcode
::UPCE
(%opts);
315 C4::Creators::PDF - A class wrapper for PDF::Reuse and PDF::Reuse::Barcode to allow usage as a pseudo-object. For usage see
316 PDF::Reuse documentation and C4::Creators::PDF code.
322 Chris Nighswonger <cnighswonger AT foundations DOT edu>