[16/40] Improvements to label management interface code.
[koha.git] / C4 / Labels / PDF.pm
1 package C4::Labels::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     prFile(%opts);
44     bless ($self, $type);
45     return $self;
46 }
47
48 sub End {
49     my $self = shift;
50     prEnd();
51 }
52
53 sub Add {
54     my $self = shift;
55     my $string = shift;
56     prAdd($string);
57 }
58
59 sub Bookmark {
60     my $self = shift;
61     my $reference = shift;
62     prBookmark($reference);
63 }
64
65 sub Compress {
66     my $self = shift;
67     my $directive = shift;
68     prCompress($directive);
69 }
70
71 sub Doc {
72     my $self = shift;
73     my %params = @_;
74     prDoc(%params);
75 }
76
77 sub DocDir {
78     my $self = shift;
79     my $directoryName = shift;
80     prDocDir($directoryName);
81 }
82
83 sub DocForm {
84     my $self = shift;
85     my %params = @_;
86     return prDocForm(%params);
87 }
88
89 sub Extract {
90     my $self = shift;
91     my ($pdfFile, $pageNo, $oldInternalName) = @_;
92     return prExtract($pdfFile, $pageNo, $oldInternalName);
93 }
94
95 sub Field {
96     my $self = shift;
97     my ($fieldName, $value) = @_;
98     prField($fieldName, $value);
99 }
100
101 sub Font {
102     my $self = shift;
103     my $fontName = shift;
104     return prFont($fontName);
105 }
106
107 sub FontSize {
108     my $self = shift;
109     my $size = shift;
110     return prFontSize($size);
111 }
112
113 sub Form {
114     my $self = shift;
115     my %params = @_;
116     return prForm(%params);
117 }
118
119 sub GetLogBuffer {
120     my $self = shift;
121     return prGetLogBuffer();
122 }
123
124 sub GraphState {
125     my $self = shift;
126     my $string = shift;
127     prGraphState($string);
128 }
129
130 sub Image {
131     my $self = shift;
132     my %params = @_;
133     return prImage(%params);
134 }
135
136 sub Init {
137     my $self = shift;
138     my ($string, $duplicateCode) = @_;
139     prInit($string, $duplicateCode);
140 }
141
142 sub Jpeg {
143     my $self = shift;
144     my ($imageFile, $width, $height) = @_;
145     return prJpeg($imageFile, $width, $height);
146 }
147
148 sub Js {
149     my $self = shift;
150     my $string_or_fileName = shift;
151     prJs($string_or_fileName);
152 }
153
154 sub Link {
155     my $self = shift;
156     my %params = @_;
157     prLink(%params);
158 }
159
160 sub Log {
161     my $self = shift;
162     my $string = shift;
163     prLog($string);
164 }
165
166 sub LogDir {
167     my $self = shift;
168     my $directory = shift;
169     prLogDir($directory);
170 }
171
172 sub Mbox {
173     my $self = shift;
174     my ($lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY) = @_;
175     prMbox($lowerLeftX, $lowerLeftY, $upperRightX, $upperRightY);
176 }
177
178 sub Page {
179     my $self = shift;
180     my $noLog = shift;
181     prPage($noLog);
182 }
183
184 sub SinglePage {
185     my $self = shift;
186     my ($file, $pageNumber) = @_;
187     return prSinglePage($file, $pageNumber);
188 }
189
190 sub StrWidth {
191     my $self = shift;
192     my ($string, $font, $fontSize) = @_;
193     return prStrWidth($string, $font, $fontSize);
194 }
195
196 sub Text {
197     my $self = shift;
198     my ($x, $y, $string, $align, $rotation) = @_;
199     return prText($x, $y, $string, $align, $rotation);
200 }
201
202 sub TTFont {
203     my $self = shift;
204     my $path = shift;
205     return prTTFont($path);
206 }
207
208 sub Code128 {
209     my $self = shift;
210     my %opts = @_;
211     PDF::Reuse::Barcode::Code128(%opts);
212 }
213
214 sub Code39 {
215     my $self = shift;
216     my %opts = @_;
217     PDF::Reuse::Barcode::Code39(%opts);
218 }
219
220 sub COOP2of5 {
221     my $self = shift;
222     my %opts = @_;
223     PDF::Reuse::Barcode::COOP2of5(%opts);
224 }
225
226 sub EAN13 {
227     my $self = shift;
228     my %opts = @_;
229     PDF::Reuse::Barcode::EAN13(%opts);
230 }
231
232 sub EAN8 {
233     my $self = shift;
234     my %opts = @_;
235     PDF::Reuse::Barcode::EAN8(%opts);
236 }
237
238 sub IATA2of5 {
239     my $self = shift;
240     my %opts = @_;
241     PDF::Reuse::Barcode::IATA2of5(%opts);
242 }
243
244 sub Industrial2of5 {
245     my $self = shift;
246     my %opts = @_;
247     PDF::Reuse::Barcode::Industrial2of5(%opts);
248 }
249
250 sub ITF {
251     my $self = shift;
252     my %opts = @_;
253     PDF::Reuse::Barcode::ITF(%opts);
254 }
255
256 sub Matrix2of5 {
257     my $self = shift;
258     my %opts = @_;
259     PDF::Reuse::Barcode::Matrix2of5(%opts);
260 }
261
262 sub NW7 {
263     my $self = shift;
264     my %opts = @_;
265     PDF::Reuse::Barcode::NW7(%opts);
266 }
267
268 sub UPCA {
269     my $self = shift;
270     my %opts = @_;
271     PDF::Reuse::Barcode::UPCA(%opts);
272 }
273
274 sub UPCE {
275     my $self = shift;
276     my %opts = @_;
277     PDF::Reuse::Barcode::UPCE(%opts);
278 }
279
280 1;
281 __END__
282
283
284 =head1 NAME
285
286 C4::Labels::PDF -   A class wrapper for PDF::Reuse and PDF::Reuse::Barcode to allow usage as a psuedo-object. For usage see
287                     PDF::Reuse documentation and C4::Labels::PDF code.
288
289 =cut
290
291 =head1 AUTHOR
292
293 Chris Nighswonger <cnighswonger AT foundations DOT edu>
294
295 =cut