File Coverage

blib/lib/PDF/API2/Basic/PDF/Utils.pm
Criterion Covered Total %
statement 43 44 97.7
branch n/a
condition n/a
subroutine 19 20 95.0
pod 8 9 88.8
total 70 73 95.8


line stmt bran cond sub pod time code
1             # Code in the PDF::API2::Basic::PDF namespace was originally copied from the
2             # Text::PDF distribution.
3             #
4             # Copyright Martin Hosken
5             #
6             # Martin Hosken's code may be used under the terms of the MIT license.
7             # Subsequent versions of the code have the same license as PDF::API2.
8              
9             package PDF::API2::Basic::PDF::Utils;
10              
11 41     41   1306 use strict;
  41         94  
  41         2029  
12              
13             our $VERSION = '2.045'; # VERSION
14              
15             =head1 NAME
16              
17             PDF::API2::Basic::PDF::Utils - Convenience functions for creating low-level PDF
18             objects
19              
20             =head1 DESCRIPTION
21              
22             A set of utility functions to save the fingers of the PDF library users!
23              
24             =head1 FUNCTIONS
25              
26             =cut
27              
28 41     41   17191 use PDF::API2::Basic::PDF::Array;
  41         111  
  41         1159  
29 41     41   16277 use PDF::API2::Basic::PDF::Bool;
  41         99  
  41         1215  
30 41     41   18178 use PDF::API2::Basic::PDF::Dict;
  41         137  
  41         1535  
31 41     41   262 use PDF::API2::Basic::PDF::Name;
  41         93  
  41         777  
32 41     41   17385 use PDF::API2::Basic::PDF::Null;
  41         110  
  41         1107  
33 41     41   16274 use PDF::API2::Basic::PDF::Number;
  41         104  
  41         1113  
34 41     41   239 use PDF::API2::Basic::PDF::String;
  41         79  
  41         760  
35 41     41   16594 use PDF::API2::Basic::PDF::Literal;
  41         102  
  41         1068  
36              
37 41     41   258 use Exporter;
  41         92  
  41         1589  
38 41     41   247 use vars qw(@EXPORT @ISA);
  41         82  
  41         13749  
39             @ISA = qw(Exporter);
40             @EXPORT = qw(PDFBool PDFArray PDFDict PDFName PDFNull
41             PDFNum PDFStr PDFStrHex PDFUtf);
42              
43             =head2 PDFBool
44              
45             Creates a Bool via PDF::API2::Basic::PDF::Bool->new
46              
47             =cut
48              
49             sub PDFBool {
50 3     3 1 23 return PDF::API2::Basic::PDF::Bool->new(@_);
51             }
52              
53             =head2 PDFArray
54              
55             Creates an array via PDF::API2::Basic::PDF::Array->new
56              
57             =cut
58              
59             sub PDFArray {
60 773     773 1 2456 return PDF::API2::Basic::PDF::Array->new(@_);
61             }
62              
63             =head2 PDFDict
64              
65             Creates a dict via PDF::API2::Basic::PDF::Dict->new
66              
67             =cut
68              
69             sub PDFDict {
70 1095     1095 1 4225 return PDF::API2::Basic::PDF::Dict->new(@_);
71             }
72              
73             =head2 PDFName
74              
75             Creates a name via PDF::API2::Basic::PDF::Name->new
76              
77             =cut
78              
79             sub PDFName {
80 16816     16816 1 35206 return PDF::API2::Basic::PDF::Name->new(@_);
81             }
82              
83             =head2 PDFNull
84              
85             Creates a null via PDF::API2::Basic::PDF::Null->new
86              
87             =cut
88              
89             sub PDFNull {
90 12     12 1 48 return PDF::API2::Basic::PDF::Null->new(@_);
91             }
92              
93             =head2 PDFNum
94              
95             Creates a number via PDF::API2::Basic::PDF::Number->new
96              
97             =cut
98              
99             sub PDFNum {
100 13323     13323 1 28183 return PDF::API2::Basic::PDF::Number->new(@_);
101             }
102              
103             =head2 PDFStr
104              
105             Creates a string via PDF::API2::Basic::PDF::String->new
106              
107             =cut
108              
109             sub PDFStr {
110 185     185 1 923 return PDF::API2::Basic::PDF::String->new(@_);
111             }
112              
113             # Deprecated
114 0     0 0 0 sub PDFUtf { return PDFStr(@_) }
115              
116             =head2 PDFStrHex
117              
118             Creates a hex-string via PDF::API2::Basic::PDF::String->new
119              
120             =cut
121              
122             sub PDFStrHex {
123 1     1 1 3 my $string = PDF::API2::Basic::PDF::String->new(@_);
124 1         3 $string->{' ishex'} = 1;
125 1         3 return $string;
126             }
127              
128             1;