File Coverage

blib/lib/PDF/API3/Compat/API2/Basic/PDF/Utils.pm
Criterion Covered Total %
statement 36 57 63.1
branch n/a
condition n/a
subroutine 12 27 44.4
pod 15 15 100.0
total 63 99 63.6


line stmt bran cond sub pod time code
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
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             #=======================================================================
27             package PDF::API3::Compat::API2::Basic::PDF::Utils;
28            
29             =head1 NAME
30            
31             PDF::API3::Compat::API2::Basic::PDF::Utils - Utility functions for PDF library
32            
33             =head1 DESCRIPTION
34            
35             A set of utility functions to save the fingers of the PDF library users!
36            
37             =head1 FUNCTIONS
38            
39             =cut
40            
41 1     1   6 use strict;
  1         2  
  1         46  
42            
43 1     1   751 use PDF::API3::Compat::API2::Basic::PDF::Array;
  1         4  
  1         26  
44 1     1   546 use PDF::API3::Compat::API2::Basic::PDF::Bool;
  1         3  
  1         23  
45 1     1   5 use PDF::API3::Compat::API2::Basic::PDF::Dict;
  1         1  
  1         18  
46 1     1   6 use PDF::API3::Compat::API2::Basic::PDF::Name;
  1         1  
  1         16  
47 1     1   592 use PDF::API3::Compat::API2::Basic::PDF::Null;
  1         2  
  1         24  
48 1     1   652 use PDF::API3::Compat::API2::Basic::PDF::Number;
  1         2  
  1         91  
49 1     1   5 use PDF::API3::Compat::API2::Basic::PDF::String;
  1         2  
  1         18  
50 1     1   620 use PDF::API3::Compat::API2::Basic::PDF::Literal;
  1         3  
  1         33  
51            
52 1     1   7 use Exporter;
  1         1  
  1         50  
53 1     1   5 use vars qw(@EXPORT @ISA);
  1         2  
  1         64  
54             @ISA = qw(Exporter);
55             @EXPORT = qw(PDFBool PDFArray PDFDict PDFLiteral PDFName PDFNull PDFNum PDFStr PDFStrHex PDFUtf
56             asPDFBool asPDFName asPDFNum asPDFStr);
57 1     1   5 no warnings qw[ deprecated recursion uninitialized ];
  1         1  
  1         533  
58            
59            
60             =head2 PDFBool
61            
62             Creates a Bool via PDF::API3::Compat::API2::Basic::PDF::Bool->new
63            
64             =cut
65            
66             sub PDFBool
67 0     0 1   { PDF::API3::Compat::API2::Basic::PDF::Bool->new(@_); }
68            
69            
70             =head2 PDFArray
71            
72             Creates an array via PDF::API3::Compat::API2::Basic::PDF::Array->new
73            
74             =cut
75            
76             sub PDFArray
77 0     0 1   { PDF::API3::Compat::API2::Basic::PDF::Array->new(@_); }
78            
79            
80             =head2 PDFDict
81            
82             Creates a dict via PDF::API3::Compat::API2::Basic::PDF::Dict->new
83            
84             =cut
85            
86             sub PDFDict
87 0     0 1   { PDF::API3::Compat::API2::Basic::PDF::Dict->new(@_); }
88            
89            
90             =head2 PDFName
91            
92             Creates a name via PDF::API3::Compat::API2::Basic::PDF::Name->new
93            
94             =cut
95            
96             sub PDFName
97 0     0 1   { PDF::API3::Compat::API2::Basic::PDF::Name->new(@_); }
98            
99            
100             =head2 PDFNull
101            
102             Creates a null via PDF::API3::Compat::API2::Basic::PDF::Null->new
103            
104             =cut
105            
106             sub PDFNull
107 0     0 1   { PDF::API3::Compat::API2::Basic::PDF::Null->new(@_); }
108            
109            
110             =head2 PDFNum
111            
112             Creates a number via PDF::API3::Compat::API2::Basic::PDF::Number->new
113            
114             =cut
115            
116             sub PDFNum
117 0     0 1   { PDF::API3::Compat::API2::Basic::PDF::Number->new(@_); }
118            
119            
120             =head2 PDFStr
121            
122             Creates a string via PDF::API3::Compat::API2::Basic::PDF::String->new
123            
124             =cut
125            
126             sub PDFStr
127 0     0 1   { PDF::API3::Compat::API2::Basic::PDF::String->new(@_); }
128            
129             =head2 PDFStrHex
130            
131             Creates a hex-string via PDF::API3::Compat::API2::Basic::PDF::String->new
132            
133             =cut
134            
135             sub PDFStrHex
136 0     0 1   { my $x=PDF::API3::Compat::API2::Basic::PDF::String->new(@_); $x->{' ishex'}=1; return($x); }
  0            
  0            
137            
138             =head2 PDFUtf
139            
140             Creates a utf8-string via PDF::API3::Compat::API2::Basic::PDF::String->new
141            
142             =cut
143            
144             sub PDFUtf
145 0     0 1   { my $x=PDF::API3::Compat::API2::Basic::PDF::String->new(@_); $x->{' isutf'}=1; return($x); }
  0            
  0            
146            
147             =head2 PDFLiteral
148            
149             Creates a pdf-literal via PDF::API3::Compat::API2::Basic::PDF::Literal->new
150            
151             =cut
152            
153             sub PDFLiteral
154 0     0 1   { PDF::API3::Compat::API2::Basic::PDF::Literal->new(@_); }
155            
156             =head2 asPDFBool
157            
158             Returns a literal value in PDF output form
159            
160             =cut
161            
162             sub asPDFBool
163 0     0 1   { PDF::API3::Compat::API2::Basic::PDF::Bool->new(@_)->as_pdf; }
164            
165            
166             =head2 asPDFStr
167            
168             Returns a string in PDF output form (including () or <>)
169            
170             =cut
171            
172             sub asPDFStr
173 0     0 1   { PDF::API3::Compat::API2::Basic::PDF::String->new(@_)->as_pdf; }
174            
175            
176             =head2 asPDFName
177            
178             Returns a Name in PDF Output form (including /)
179            
180             =cut
181            
182             sub asPDFName
183 0     0 1   { PDF::API3::Compat::API2::Basic::PDF::Name->new(@_)->as_pdf (@_); }
184            
185            
186             =head2 asPDFNum
187            
188             Returns a number in PDF output form
189            
190             =cut
191            
192             sub asPDFNum
193 0     0 1   { $_[0]; } # no translation needed
194            
195            
196             =head2 unpacku($str)
197            
198             Returns a list of unicode values for the given UTF8 string
199            
200             =cut
201            
202             sub unpacku
203             {
204 0     0 1   my ($str) = @_;
205 0           my (@res);
206            
207 0           return (unpack("U*", $str));
208             }
209            
210            
211             1;
212