1#=======================================================================
2#    ____  ____  _____              _    ____ ___   ____
3#   |  _ \|  _ \|  ___|  _   _     / \  |  _ \_ _| |___ \
4#   | |_) | | | | |_    (_) (_)   / _ \ | |_) | |    __) |
5#   |  __/| |_| |  _|    _   _   / ___ \|  __/| |   / __/
6#   |_|   |____/|_|     (_) (_) /_/   \_\_|  |___| |_____|
7#
8#   A Perl Module Chain to faciliate the Creation and Modification
9#   of High-Quality "Portable Document Format (PDF)" Files.
10#
11#=======================================================================
12#
13#   THIS IS A REUSED PERL MODULE, FOR PROPER LICENCING TERMS SEE BELOW:
14#
15#
16#   Copyright Martin Hosken <Martin_Hosken@sil.org>
17#
18#   No warranty or expression of effectiveness, least of all regarding
19#   anyone's safety, is implied in this software or documentation.
20#
21#   This specific module is licensed under the Perl Artistic License.
22#
23#
24#   $Id: Utils.pm,v 2.0 2005/11/16 02:16:00 areibens Exp $
25#
26#=======================================================================
27package PDF::API3::Compat::API2::Basic::PDF::Utils;
28
29=head1 NAME
30
31PDF::API3::Compat::API2::Basic::PDF::Utils - Utility functions for PDF library
32
33=head1 DESCRIPTION
34
35A set of utility functions to save the fingers of the PDF library users!
36
37=head1 FUNCTIONS
38
39=cut
40
41use strict;
42
43use PDF::API3::Compat::API2::Basic::PDF::Array;
44use PDF::API3::Compat::API2::Basic::PDF::Bool;
45use PDF::API3::Compat::API2::Basic::PDF::Dict;
46use PDF::API3::Compat::API2::Basic::PDF::Name;
47use PDF::API3::Compat::API2::Basic::PDF::Null;
48use PDF::API3::Compat::API2::Basic::PDF::Number;
49use PDF::API3::Compat::API2::Basic::PDF::String;
50use PDF::API3::Compat::API2::Basic::PDF::Literal;
51
52use Exporter;
53use vars qw(@EXPORT @ISA);
54@ISA = qw(Exporter);
55@EXPORT = qw(PDFBool PDFArray PDFDict PDFLiteral PDFName PDFNull PDFNum PDFStr PDFStrHex PDFUtf
56             asPDFBool asPDFName asPDFNum asPDFStr);
57no warnings qw[ deprecated recursion uninitialized ];
58
59
60=head2 PDFBool
61
62Creates a Bool via PDF::API3::Compat::API2::Basic::PDF::Bool->new
63
64=cut
65
66sub PDFBool
67{ PDF::API3::Compat::API2::Basic::PDF::Bool->new(@_); }
68
69
70=head2 PDFArray
71
72Creates an array via PDF::API3::Compat::API2::Basic::PDF::Array->new
73
74=cut
75
76sub PDFArray
77{ PDF::API3::Compat::API2::Basic::PDF::Array->new(@_); }
78
79
80=head2 PDFDict
81
82Creates a dict via PDF::API3::Compat::API2::Basic::PDF::Dict->new
83
84=cut
85
86sub PDFDict
87{ PDF::API3::Compat::API2::Basic::PDF::Dict->new(@_); }
88
89
90=head2 PDFName
91
92Creates a name via PDF::API3::Compat::API2::Basic::PDF::Name->new
93
94=cut
95
96sub PDFName
97{ PDF::API3::Compat::API2::Basic::PDF::Name->new(@_); }
98
99
100=head2 PDFNull
101
102Creates a null via PDF::API3::Compat::API2::Basic::PDF::Null->new
103
104=cut
105
106sub PDFNull
107{ PDF::API3::Compat::API2::Basic::PDF::Null->new(@_); }
108
109
110=head2 PDFNum
111
112Creates a number via PDF::API3::Compat::API2::Basic::PDF::Number->new
113
114=cut
115
116sub PDFNum
117{ PDF::API3::Compat::API2::Basic::PDF::Number->new(@_); }
118
119
120=head2 PDFStr
121
122Creates a string via PDF::API3::Compat::API2::Basic::PDF::String->new
123
124=cut
125
126sub PDFStr
127{ PDF::API3::Compat::API2::Basic::PDF::String->new(@_); }
128
129=head2 PDFStrHex
130
131Creates a hex-string via PDF::API3::Compat::API2::Basic::PDF::String->new
132
133=cut
134
135sub PDFStrHex
136{ my $x=PDF::API3::Compat::API2::Basic::PDF::String->new(@_); $x->{' ishex'}=1; return($x); }
137
138=head2 PDFUtf
139
140Creates a utf8-string via PDF::API3::Compat::API2::Basic::PDF::String->new
141
142=cut
143
144sub PDFUtf
145{ my $x=PDF::API3::Compat::API2::Basic::PDF::String->new(@_); $x->{' isutf'}=1; return($x); }
146
147=head2 PDFLiteral
148
149Creates a pdf-literal via PDF::API3::Compat::API2::Basic::PDF::Literal->new
150
151=cut
152
153sub PDFLiteral
154{ PDF::API3::Compat::API2::Basic::PDF::Literal->new(@_); }
155
156=head2 asPDFBool
157
158Returns a literal value in PDF output form
159
160=cut
161
162sub asPDFBool
163{ PDF::API3::Compat::API2::Basic::PDF::Bool->new(@_)->as_pdf; }
164
165
166=head2 asPDFStr
167
168Returns a string in PDF output form (including () or <>)
169
170=cut
171
172sub asPDFStr
173{ PDF::API3::Compat::API2::Basic::PDF::String->new(@_)->as_pdf; }
174
175
176=head2 asPDFName
177
178Returns a Name in PDF Output form (including /)
179
180=cut
181
182sub asPDFName
183{ PDF::API3::Compat::API2::Basic::PDF::Name->new(@_)->as_pdf (@_); }
184
185
186=head2 asPDFNum
187
188Returns a number in PDF output form
189
190=cut
191
192sub asPDFNum
193{ $_[0]; }          # no translation needed
194
195
196=head2 unpacku($str)
197
198Returns a list of unicode values for the given UTF8 string
199
200=cut
201
202sub unpacku
203{
204    my ($str) = @_;
205    my (@res);
206
207    return (unpack("U*", $str));
208}
209
210
2111;
212
213