Merge branch 'patroncards-wip' of git://git.foundations.edu/koha into community
[koha.git] / C4 / Creators / PDF.pm
1 package C4::Creators::PDF;
2
3 # Copyright 2009 Foundations Bible College.
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
11 #
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA  02111-1307 USA
19
20 use strict;
21 use warnings;
22 use PDF::Reuse;
23 use PDF::Reuse::Barcode;
24
25 BEGIN {
26     use version; our $VERSION = qv('1.0.0_1');
27 }
28
29 sub _InitVars {
30     my $self = shift;
31     my $param = shift;
32     prInitVars($param);
33 }
34
35 sub new {
36     my $invocant = shift;
37     my $type = ref($invocant) || $invocant;
38     my %opts = @_;
39     my $self = {};
40     _InitVars() if ($opts{InitVars} == 0);
41     _InitVars($opts{InitVars}) if ($opts{InitVars} > 0);
42     delete($opts{InitVars});
43     prDocDir($opts{'DocDir'}) if $opts{'DocDir'};
44     delete($opts{'DocDir'});
45     prFile(%opts);
46     bless ($self, $type);
47     return $self;
48 }
49
50 sub End {
51     my $self = shift;
52     prEnd();
53 }
54
55 sub Add {
56     my $self = shift;
57     my $string = shift;
58     prAdd($string);
59 }
60
61 sub Bookmark {
62     my $self = shift;
63     my $reference = shift;
64     prBookmark($reference);
65 }
66
67 sub Compress {
68     my $self = shift;
69     my $directive = shift;
70     prCompress($directive);
71 }
72
73 sub Doc {
74     my $self = shift;
75     my %params = @_;
76     prDoc(%params);
77 }
78
79 sub DocForm {
80     my $self = shift;
81     my %params = @_;
82     return prDocForm(%params);
83 }
84
85 sub Extract {
86     my $self = shift;
87     my ($pdfFile, $pageNo, $oldInternalName) = @_;
88     return prExtract($pdfFile, $pageNo, $oldInternalName);
89 }
90
91 sub Field {
92     my $self = shift;
93     my ($fieldName, $value) = @_;
94     prField($fieldName, $value);
95 }
96
97 sub Font {
98     my $self = shift;
99     my $fontName = shift;
100     return prFont($fontName);
101 }
102
103 sub FontSize {
104     my $self = shift;
105     my $size = shift;
106     return prFontSize($size);
107 }
108
109 sub Form {
110     my $self = shift;
111     my %params = @_;
112     return prForm(%params);
113 }
114
115 sub GetLogBuffer {
116     my $self = shift;
117     return prGetLogBuffer();
118 }
119
120 sub GraphState {
121     my $self = shift;
122     my $string = shift;
123     prGraphState($string);
124 }
125
126 sub Image {
127     my $self = shift;
128     my %params = @_;
129     return prImage(%params);
130 }
131
132 sub Init {
133     my $self = shift;
134     my ($string, $duplicateCode) = @_;
135     prInit($string, $duplicateCode);
136 }
137
138 sub AltJpeg {
139     my $self = shift;
140     my ($imageData, $width, $height, $imageFormat, $altImageData, $altImageWidth, $altImageHeight, $altImageFormat) = @_;
141     return prAltJpeg($imageData, $width, $height, $imageFormat, $altImageData, $altImageWidth, $altImageHeight, $altImageFormat);
142 }
143
144 sub Jpeg {
145     my $self = shift;
146     my ($imageData, $width, $height, $imageFormat) = @_;
147     return prJpeg($imageData, $width, $height, $imageFormat);
148 }
149
150 sub Js {
151     my $self = shift;
152     my $string_or_fileName = shift;
153     prJs($string_or_fileName);
154 }
155
156 sub Link {
157     my $self = shift;
158     my %params = @_;
159     prLink(%params);
160 }
161
162 sub Log {
163     my $self = shift;
164     my $string = shift;
165     prLog($string);
166 }
167
168 sub LogDir {
169     my $self = shift;
170     my $directory = shift;
171     prLogDir($directory);
172 }
173
174 sub Mbox {
175     my $self = shift;
176     my ($lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY) = @_;
177     prMbox($lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY);
178 }
179
180 sub Page {
181     my $self = shift;
182     my $noLog = shift;
183     prPage($noLog);
184 }
185
186 sub SinglePage {
187     my $self = shift;
188     my ($file, $pageNumber) = @_;
189     return prSinglePage($file, $pageNumber);
190 }
191
192 sub StrWidth {
193     my $self = shift;
194     my ($string, $font, $fontSize) = @_;
195     return prStrWidth($string, $font, $fontSize);
196 }
197
198 sub Text {
199     my $self = shift;
200     my ($x, $y, $string, $align, $rotation) = @_;
201     return prText($x, $y, $string, $align, $rotation);
202 }
203
204 sub TTFont {
205     my $self = shift;
206     my $path = shift;
207     return prTTFont($path);
208 }
209
210 sub Code128 {
211     my $self = shift;
212     my %opts = @_;
213     PDF::Reuse::Barcode::Code128(%opts);
214 }
215
216 sub Code39 {
217     my $self = shift;
218     my %opts = @_;
219     PDF::Reuse::Barcode::Code39(%opts);
220 }
221
222 sub COOP2of5 {
223     my $self = shift;
224     my %opts = @_;
225     PDF::Reuse::Barcode::COOP2of5(%opts);
226 }
227
228 sub EAN13 {
229     my $self = shift;
230     my %opts = @_;
231     PDF::Reuse::Barcode::EAN13(%opts);
232 }
233
234 sub EAN8 {
235     my $self = shift;
236     my %opts = @_;
237     PDF::Reuse::Barcode::EAN8(%opts);
238 }
239
240 sub IATA2of5 {
241     my $self = shift;
242     my %opts = @_;
243     PDF::Reuse::Barcode::IATA2of5(%opts);
244 }
245
246 sub Industrial2of5 {
247     my $self = shift;
248     my %opts = @_;
249     PDF::Reuse::Barcode::Industrial2of5(%opts);
250 }
251
252 sub ITF {
253     my $self = shift;
254     my %opts = @_;
255     PDF::Reuse::Barcode::ITF(%opts);
256 }
257
258 sub Matrix2of5 {
259     my $self = shift;
260     my %opts = @_;
261     PDF::Reuse::Barcode::Matrix2of5(%opts);
262 }
263
264 sub NW7 {
265     my $self = shift;
266     my %opts = @_;
267     PDF::Reuse::Barcode::NW7(%opts);
268 }
269
270 sub UPCA {
271     my $self = shift;
272     my %opts = @_;
273     PDF::Reuse::Barcode::UPCA(%opts);
274 }
275
276 sub UPCE {
277     my $self = shift;
278     my %opts = @_;
279     PDF::Reuse::Barcode::UPCE(%opts);
280 }
281
282 1;
283 __END__
284
285
286 =head1 NAME
287
288 C4::Creators::PDF -   A class wrapper for PDF::Reuse and PDF::Reuse::Barcode to allow usage as a psuedo-object. For usage see
289                     PDF::Reuse documentation and C4::Creators::PDF code.
290
291 =cut
292
293 =head1 AUTHOR
294
295 Chris Nighswonger <cnighswonger AT foundations DOT edu>
296
297 =cut