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/;
28 use version
; our $VERSION = qv
('3.07.00.049');
39 my $type = ref($invocant) || $invocant;
42 _InitVars
() if ($opts{InitVars
} == 0);
43 _InitVars
($opts{InitVars
}) if ($opts{InitVars
} > 0);
44 delete($opts{InitVars
});
45 prDocDir
($opts{'DocDir'}) if $opts{'DocDir'};
46 delete($opts{'DocDir'});
48 my $fh = File
::Temp
->new( UNLINK
=> 0, SUFFIX
=> '.pdf' );
49 $opts{Name
} = $self->{filename
} = "$fh"; # filename
50 close $fh; # we need just filename
62 # slurp temporary filename and print it out for plack to pick up
64 open(my $fh, '<', $self->{filename
}) || die "$self->{filename}: $!";
67 unlink $self->{filename
};
78 my $reference = shift;
79 prBookmark
($reference);
84 my $directive = shift;
85 prCompress
($directive);
97 return prDocForm
(%params);
102 my ($pdfFile, $pageNo, $oldInternalName) = @_;
103 return prExtract
($pdfFile, $pageNo, $oldInternalName);
108 my ($fieldName, $value) = @_;
109 prField
($fieldName, $value);
114 my $fontName = shift;
116 my $ttf = C4
::Context
->config('ttf');
119 my $ttf_path = first
{ $_->{type
} eq $fontName } @
{ $ttf->{font
} };
120 if ( -e
$ttf_path->{content
} ) {
121 return prTTFont
($ttf_path->{content
});
123 warn "ERROR in koha-conf.xml -- missing <font type=\"$fontName\">/path/to/font.ttf</font>";
126 return prFont
($fontName);
132 return prFontSize
($size);
138 return prForm
(%params);
143 return prGetLogBuffer
();
149 prGraphState
($string);
155 return prImage
(%params);
160 my ($string, $duplicateCode) = @_;
161 prInit
($string, $duplicateCode);
166 my ($imageData, $width, $height, $imageFormat, $altImageData, $altImageWidth, $altImageHeight, $altImageFormat) = @_;
167 return prAltJpeg
($imageData, $width, $height, $imageFormat, $altImageData, $altImageWidth, $altImageHeight, $altImageFormat);
172 my ($imageData, $width, $height, $imageFormat) = @_;
173 return prJpeg
($imageData, $width, $height, $imageFormat);
178 my $string_or_fileName = shift;
179 prJs
($string_or_fileName);
196 my $directory = shift;
197 prLogDir
($directory);
202 my ($lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY) = @_;
203 prMbox
($lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY);
214 my ($file, $pageNumber) = @_;
215 return prSinglePage
($file, $pageNumber);
220 my ($string, $font, $fontSize) = @_;
222 # replace font code with path to TTF font file if need be
223 my $ttf = C4
::Context
->config('ttf');
225 my $ttf_path = first
{ $_->{type
} eq $font } @
{ $ttf->{font
} };
226 if ( -e
$ttf_path->{content
} ) {
227 $font = $ttf_path->{content
};
229 warn "ERROR in koha-conf.xml -- missing <font type=\"$font\">/path/to/font.ttf</font>";
233 return prStrWidth
($string, $font, $fontSize);
238 my ($x, $y, $string, $align, $rotation) = @_;
239 return prText
($x, $y, $string, $align, $rotation);
245 return prTTFont
($path);
251 PDF
::Reuse
::Barcode
::Code128
(%opts);
257 PDF
::Reuse
::Barcode
::Code39
(%opts);
263 PDF
::Reuse
::Barcode
::COOP2of5
(%opts);
269 PDF
::Reuse
::Barcode
::EAN13
(%opts);
275 PDF
::Reuse
::Barcode
::EAN8
(%opts);
281 PDF
::Reuse
::Barcode
::IATA2of5
(%opts);
287 PDF
::Reuse
::Barcode
::Industrial2of5
(%opts);
293 PDF
::Reuse
::Barcode
::ITF
(%opts);
299 PDF
::Reuse
::Barcode
::Matrix2of5
(%opts);
305 PDF
::Reuse
::Barcode
::NW7
(%opts);
311 PDF
::Reuse
::Barcode
::UPCA
(%opts);
317 PDF
::Reuse
::Barcode
::UPCE
(%opts);
326 C4::Creators::PDF - A class wrapper for PDF::Reuse and PDF::Reuse::Barcode to allow usage as a pseudo-object. For usage see
327 PDF::Reuse documentation and C4::Creators::PDF code.
333 Chris Nighswonger <cnighswonger AT foundations DOT edu>