File Coverage

blib/lib/PDF/API2/Resource/ExtGState.pm
Criterion Covered Total %
statement 26 109 23.8
branch 0 2 0.0
condition n/a
subroutine 8 35 22.8
pod 29 30 96.6
total 63 176 35.8


line stmt bran cond sub pod time code
1             package PDF::API2::Resource::ExtGState;
2              
3 39     39   283 use base 'PDF::API2::Resource';
  39         104  
  39         3751  
4              
5 39     39   255 use strict;
  39         91  
  39         1001  
6 39     39   195 no warnings qw[ deprecated recursion uninitialized ];
  39         93  
  39         2040  
7              
8             our $VERSION = '2.045'; # VERSION
9              
10 39     39   224 use PDF::API2::Basic::PDF::Utils;
  39         100  
  39         2634  
11 39     39   223 use PDF::API2::Util;
  39         82  
  39         55875  
12              
13             =head1 NAME
14              
15             PDF::API2::Resource::ExtGState - Graphics state dictionary support
16              
17             =head1 METHODS
18              
19             =over
20              
21             =item $egs = PDF::API2::Resource::ExtGState->new @parameters
22              
23             Returns a new extgstate object (called from $pdf->egstate).
24              
25             =cut
26              
27             sub new {
28 3     3 1 10 my ($class,$pdf,$key)=@_;
29 3         22 my $self = $class->SUPER::new($pdf,$key);
30 3         10 $self->{Type}=PDFName('ExtGState');
31 3         9 return($self);
32             }
33              
34             =item $egs->strokeadjust $boolean
35              
36             =cut
37              
38             sub strokeadjust {
39 0     0 1 0 my ($self,$var)=@_;
40 0         0 $self->{SA}=PDFBool($var);
41 0         0 return($self);
42             }
43              
44             =item $egs->strokeoverprint $boolean
45              
46             =cut
47              
48             sub strokeoverprint {
49 0     0 1 0 my ($self,$var)=@_;
50 0         0 $self->{OP}=PDFBool($var);
51 0         0 return($self);
52             }
53              
54             =item $egs->filloverprint $boolean
55              
56             =cut
57              
58             sub filloverprint {
59 0     0 1 0 my ($self,$var)=@_;
60 0         0 $self->{op}=PDFBool($var);
61 0         0 return($self);
62             }
63              
64             =item $egs->overprintmode $num
65              
66             =cut
67              
68             sub overprintmode {
69 0     0 1 0 my ($self,$var)=@_;
70 0         0 $self->{OPM}=PDFNum($var);
71 0         0 return($self);
72             }
73              
74             =item $egs->blackgeneration $obj
75              
76             =cut
77              
78             sub blackgeneration {
79 0     0 1 0 my ($self,$obj)=@_;
80 0         0 $self->{BG}=$obj;
81 0         0 return($self);
82             }
83              
84             =item $egs->blackgeneration2 $obj
85              
86             =cut
87              
88             sub blackgeneration2 {
89 0     0 1 0 my ($self,$obj)=@_;
90 0         0 $self->{BG2}=$obj;
91 0         0 return($self);
92             }
93              
94             =item $egs->undercolorremoval $obj
95              
96             =cut
97              
98             sub undercolorremoval {
99 0     0 1 0 my ($self,$obj)=@_;
100 0         0 $self->{UCR}=$obj;
101 0         0 return($self);
102             }
103              
104             =item $egs->undercolorremoval2 $obj
105              
106             =cut
107              
108             sub undercolorremoval2 {
109 0     0 1 0 my ($self,$obj)=@_;
110 0         0 $self->{UCR2}=$obj;
111 0         0 return($self);
112             }
113              
114             =item $egs->transfer $obj
115              
116             =cut
117              
118             sub transfer {
119 0     0 1 0 my ($self,$obj)=@_;
120 0         0 $self->{TR}=$obj;
121 0         0 return($self);
122             }
123              
124             =item $egs->transfer2 $obj
125              
126             =cut
127              
128             sub transfer2 {
129 0     0 1 0 my ($self,$obj)=@_;
130 0         0 $self->{TR2}=$obj;
131 0         0 return($self);
132             }
133              
134             =item $egs->halftone $obj
135              
136             =cut
137              
138             sub halftone {
139 0     0 1 0 my ($self,$obj)=@_;
140 0         0 $self->{HT}=$obj;
141 0         0 return($self);
142             }
143              
144             =item $egs->halftonephase $obj
145              
146             =cut
147              
148             # Per RT #113514, this was last present in version 1.2 of the PDF
149             # spec, so it can probably be removed.
150             sub halftonephase {
151 0     0 1 0 my ($self,$obj)=@_;
152 0         0 $self->{HTP}=$obj;
153 0         0 return($self);
154             }
155              
156             =item $egs->smoothness $num
157              
158             =cut
159              
160             sub smoothness {
161 0     0 1 0 my ($self,$var)=@_;
162 0         0 $self->{SM}=PDFNum($var);
163 0         0 return($self);
164             }
165              
166             =item $egs->font $font, $size
167              
168             =cut
169              
170             sub font {
171 0     0 1 0 my ($self,$font,$size)=@_;
172 0         0 $self->{Font}=PDFArray(PDFName($font->{' apiname'}),PDFNum($size));
173 0         0 return($self);
174             }
175              
176             =item $egs->linewidth $size
177              
178             =cut
179              
180             sub linewidth {
181 0     0 1 0 my ($self,$var)=@_;
182 0         0 $self->{LW}=PDFNum($var);
183 0         0 return($self);
184             }
185              
186             =item $egs->linecap $cap
187              
188             =cut
189              
190             sub linecap {
191 0     0 1 0 my ($self,$var)=@_;
192 0         0 $self->{LC}=PDFNum($var);
193 0         0 return($self);
194             }
195              
196             =item $egs->linejoin $join
197              
198             =cut
199              
200             sub linejoin {
201 0     0 1 0 my ($self,$var)=@_;
202 0         0 $self->{LJ}=PDFNum($var);
203 0         0 return($self);
204             }
205              
206             =item $egs->miterlimit $limit
207              
208             =cut
209              
210             sub miterlimit {
211 0     0 1 0 my ($self,$var)=@_;
212 0         0 $self->{ML}=PDFNum($var);
213 0         0 return($self);
214             }
215              
216             # Deprecated: miterlimit was originally named incorrectly
217 0     0 0 0 sub meterlimit { return miterlimit(@_) }
218              
219             =item $egs->dash @dash
220              
221             =cut
222              
223             sub dash {
224 1     1 1 7 my ($self,@dash)=@_;
225 1         3 $self->{D}=PDFArray(PDFArray( map { PDFNum($_); } @dash), PDFNum(0));
  2         5  
226 1         3 return($self);
227             }
228              
229             =item $egs->flatness $flat
230              
231             =cut
232              
233             sub flatness {
234 0     0 1 0 my ($self,$var)=@_;
235 0         0 $self->{FL}=PDFNum($var);
236 0         0 return($self);
237             }
238              
239             =item $egs->renderingintent $intentName
240              
241             =cut
242              
243             sub renderingintent {
244 1     1 1 11 my ($self,$var)=@_;
245 1         8 $self->{RI}=PDFName($var);
246 1         5 return($self);
247             }
248              
249             =item $egs->strokealpha $alpha
250              
251             The current stroking alpha constant, specifying the
252             constant shape or constant opacity value to be used
253             for stroking operations in the transparent imaging model.
254              
255             =cut
256              
257             sub strokealpha {
258 0     0 1   my ($self,$var)=@_;
259 0           $self->{CA}=PDFNum($var);
260 0           return($self);
261             }
262              
263             =item $egs->fillalpha $alpha
264              
265             Same as strokealpha, but for nonstroking operations.
266              
267             =cut
268              
269             sub fillalpha {
270 0     0 1   my ($self,$var)=@_;
271 0           $self->{ca}=PDFNum($var);
272 0           return($self);
273             }
274              
275             =item $egs->blendmode $blendname
276              
277             =item $egs->blendmode $blendfunctionobj
278              
279             The current blend mode to be used in the transparent
280             imaging model.
281              
282             =cut
283              
284             sub blendmode {
285 0     0 1   my ($self,$var)=@_;
286 0 0         if(ref($var)) {
287 0           $self->{BM}=$var;
288             } else {
289 0           $self->{BM}=PDFName($var);
290             }
291 0           return($self);
292             }
293              
294             =item $egs->alphaisshape $boolean
295              
296             The alpha source flag (alpha is shape), specifying
297             whether the current soft mask and alpha constant
298             are to be interpreted as shape values (true) or
299             opacity values (false).
300              
301             =cut
302              
303             sub alphaisshape {
304 0     0 1   my ($self,$var)=@_;
305 0           $self->{AIS}=PDFBool($var);
306 0           return($self);
307             }
308              
309             =item $egs->textknockout $boolean
310              
311             The text knockout flag, which determines the behavior
312             of overlapping glyphs within a text object in the
313             transparent imaging model.
314              
315             =cut
316              
317             sub textknockout {
318 0     0 1   my ($self,$var)=@_;
319 0           $self->{TK}=PDFBool($var);
320 0           return($self);
321             }
322              
323             =item $egs->transparency $t
324              
325             The graphics transparency, with 0 being fully opaque and 1 being fully transparent.
326             This is a convenience method setting proper values for strokealpha and fillalpha.
327              
328             =cut
329              
330             sub transparency {
331 0     0 1   my ($self,$var)=@_;
332 0           $self->strokealpha(1-$var);
333 0           $self->fillalpha(1-$var);
334 0           return($self);
335             }
336              
337             =item $egs->opacity $op
338              
339             The graphics opacity , with 1 being fully opaque and 0 being fully transparent.
340             This is a convenience method setting proper values for strokealpha and fillalpha.
341              
342             =cut
343              
344             sub opacity {
345 0     0 1   my ($self,$var)=@_;
346 0           $self->strokealpha($var);
347 0           $self->fillalpha($var);
348 0           return($self);
349             }
350              
351             =back
352              
353             =cut
354              
355             1;