SelectPdf/HtmlToPdfClient.pm

filter: Statementstmt 18.8% 83 / 441 Branchbran 18.1% 12 / 66 Conditioncond 20.6% 13 / 63 MC/DCmcdc 12.9% 4 / 31 Subroutinesub 19.4% 23 / 118 Podpod 99.0% 108 / 109 totaltotal 29.3% 243 / 828 CC 56 SCAR 20.6
CC
56
Cov
19%
setViewerPageMode
56.0
setViewerPageLayout
30.0
_splitFields
20.0
CRAP 7.8
« SelectPdf/PdfMergeClient.pm ↑ Summary SelectPdf/DemoExceptions.pm »
1 package SelectPdf::HtmlToPdfClient;
2
3 1 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use SelectPdf::ApiClient;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use SelectPdf::ApiEnums;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use SelectPdf::AsyncJobClient;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use SelectPdf::DemoExceptions;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use SelectPdf::WebElementsClient;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 our @ISA = qw(SelectPdf::ApiClient);
11
12 1 our $VERSION = '1.6.0';
13
14 =head1 NAME
15
16 SelectPdf::HtmlToPdfClient - Html To Pdf Conversion with SelectPdf Online API.
17
18 =head1 SYNOPSIS
19
20 Convert URL to PDF and save result into a file on disk.
21
22 use SelectPdf;
23 print "This is SelectPdf-$SelectPdf::VERSION\n";
24
25 my $url = "https://selectpdf.com/";
26 my $local_file = "Test.pdf";
27 my $apiKey = "Your API key here";
28
29 eval {
30 my $client = SelectPdf::HtmlToPdfClient->new($apiKey);
31
32 $client
33 ->setPageSize("A4")
34 ->setMargins(0)
35 ->setShowPageNumbers('False')
36 ->setPageBreaksEnhancedAlgorithm('True')
37 ;
38
39 $client->convertUrlToFile($url, $local_file);
40 };
41
42 if ($@) {
43 print "An error occurred: $@\n";
44 }
45
46 Convert raw HTML string to PDF and save result into a file on disk.
47
48 use SelectPdf;
49 print "This is SelectPdf-$SelectPdf::VERSION\n";
50
51 my $html = "This is a <b>test HTML</b>.";
52 my $local_file = "Test.pdf";
53 my $apiKey = "Your API key here";
54
55 eval {
56 my $client = SelectPdf::HtmlToPdfClient->new($apiKey);
57
58 $client
59 ->setPageSize("A4")
60 ->setMargins(0)
61 ->setShowPageNumbers('False')
62 ->setPageBreaksEnhancedAlgorithm('True')
63 ;
64
65 $client->convertHtmlStringToFile($html, $local_file);
66 };
67
68 if ($@) {
69 print "An error occurred: $@\n";
70 }
71
72 Keyless demo mode (no API key; output is watermarked and capped at 5 pages).
73
74 use SelectPdf;
75
76 eval {
77 my $client = SelectPdf::HtmlToPdfClient->new(); # undef, "" or "demo" selects the demo endpoint
78
79 $client->convertUrlToFile("https://selectpdf.com/", "Test.pdf");
80
81 print "Demo response: " . $client->isDemoResponse() . ", mode: " . $client->getMode() . "\n";
82 print "Dropped fields: " . join(", ", $client->getDroppedFields()) . "\n" if $client->wasAnyFieldDropped();
83 };
84
85 if (my $err = $@) {
86 if (ref $err && $err->isa("SelectPdf::DemoRateLimitException")) {
87 print "Demo rate limit reached. Retry after " . $err->retryAfter() . "s.\n";
88 }
89 else {
90 print "An error occurred: $err\n";
91 }
92 }
93
94 For more details and full list of parameters see L<Html To Pdf API|https://selectpdf.com/html-to-pdf-api/>.
95
96 =head1 METHODS
97
98 =head2 new( $apiKey )
99
100 Construct the Html To Pdf Client.
101
102 my $client = SelectPdf::HtmlToPdfClient->new($apiKey);
103
104 Pass a paid API key for production use. Pass undef, an empty string, or "demo" (case-insensitive) to use the
105 keyless demo endpoint - output is watermarked and capped at 5 pages, but no signup is required.
106
107 my $demoClient = SelectPdf::HtmlToPdfClient->new(); # keyless demo mode
108
109 Parameters:
110
111 - $apiKey API Key. Undef, empty or "demo" selects the keyless demo endpoint.
112 =cut
113 7 ▶sub new {
Subroutine new: called CC=4 SCAR=13.9
Pod documented
114 7 my $type = shift;
115 7 my $apiKey = shift;
116 7 my $self = $type->SUPER::new;
117
118 # Names of the parameters the demo endpoint clamped / dropped on the most recent conversion.
119 7 $self->{clampedFields} = [];
120 7 $self->{droppedFields} = [];
121
122 7 ▶ my $demo = (not defined($apiKey) or $apiKey eq "" or $apiKey =~ m/^\s*demo\s*$/i);
Condition100%6/6
!defined($apiKey) || $apiKey eq '' || $apiKey =~ /^\s*demo\s*$/i
l!l&&r!l&&!r
322
not defined $apiKey or $apiKey eq ""
l!l&&r!l&&!r
214
MC/DC100%3/3
!defined($apiKey) || $apiKey eq '' || $apiKey =~ /^\s*demo\s*$/i
not defined $apiKey $apiKey eq "" $apiKey =~ /^\s*demo\s*$/i
Truth table100%4/4
not(A) or B || C
A= not defined $apiKeyB= $apiKey eq ""C= $apiKey =~ /^\s*demo\s*$/i
ABCresult
1XX1
01X1
0011
0000
123
124 7 ▶ if ($demo) {
Branch: 1 branch
BranchTrueFalseTotal
if ($demo) { } 5 2 7
125 # API endpoint (keyless demo)
126 5 $self->{apiEndpoint} = "https://selectpdf.com/api2/convert/demo/";
127 5 $self->{isDemoMode} = 1;
128 # Demo is keyless. The "key" parameter is not sent.
129 }
130 else {
131 # API endpoint
132 2 $self->{apiEndpoint} = "https://selectpdf.com/api2/convert/";
133 2 $self->{isDemoMode} = 0;
134 2 $self->{parameters}{"key"} = $apiKey;
135 }
136
137 7 bless $self, $type;
138 7 return $self;
139 }
140
141 # Capture demo-specific response headers (the demo-clamped fields list and the demo-dropped fields list).
142 # Mode and execution mode are read in the base class.
143 0 ▶sub onResponseHeadersReceived {
Subroutine onResponseHeadersReceived: not called CC=1 SCAR=6.9
Pod undocumented
144 0 my($self, $response) = @_;
145
146 0 $self->{clampedFields} = _splitFields($response->header("X-SelectPdf-Demo-Clamped"));
147 0 $self->{droppedFields} = _splitFields($response->header("X-SelectPdf-Demo-Dropped"));
148 }
149
150 0 ▶sub _splitFields {
Subroutine _splitFields: not called CC=4 SCAR=30.0
151 0 my($raw) = @_;
152 0 ▶ return [] if (not defined($raw) or $raw eq "");
Branch: 1 branch
BranchTrueFalseTotal
if not defined $raw or $raw eq "" 0 0 0
Condition0%0/3
not defined $raw or $raw eq ""
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $raw or $raw eq ""
not defined $raw $raw eq ""
Truth table0%0/3
not(A) or B
A= not defined $rawB= $raw eq ""
ABresult
1X1
011
000
153 0 my @parts = split(/,/, $raw, -1);
154 0 s/^\s+|\s+$//g foreach @parts;
155 0 return \@parts;
156 }
157
158 =head2 isDemoMode
159
160 True if the client was constructed for the keyless demo endpoint (the API key was undef, empty, or "demo").
161 Set at construction time and stable for the lifetime of the client. Calling setApiEndpoint does not change it.
162
163 if ($client->isDemoMode()) { ... }
164
165 Returns:
166
167 - 1 for demo mode, 0 otherwise.
168 =cut
169 5 ▶sub isDemoMode {
Subroutine isDemoMode: called CC=2 SCAR=6.9
Pod documented
170 5 my($self) = @_;
171 5 ▶ return $self->{isDemoMode} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'isDemoMode'} ? : 4 1 5
172 }
173
174 =head2 isDemoResponse
175
176 True if the most recent response was tagged X-SelectPdf-Mode: demo (the request actually landed on a demo endpoint).
177
178 if ($client->isDemoResponse()) { ... }
179
180 Returns:
181
182 - 1 if the most recent response came from the demo endpoint, 0 otherwise.
183 =cut
184 1 ▶sub isDemoResponse {
Subroutine isDemoResponse: called CC=3 SCAR=12.5
Pod documented
185 1 my($self) = @_;
186 1 my $mode = $self->getMode();
187 1 ▶ return (defined($mode) and lc($mode) eq "demo") ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $mode && lc $mode eq 'demo' ? : 0 1 1
Condition33%1/3
defined $mode and lc $mode eq "demo"
!ll&&!rl&&r
010
MC/DC0%0/2
defined $mode and lc $mode eq "demo"
defined $mode lc $mode eq "demo"
Truth table33%1/3
A and B
A= defined $modeB= lc $mode eq "demo"
ABresult
0X0
100
111
188 }
189
190 =head2 getClampedFields
191
192 Names of the parameters the demo endpoint clamped on the most recent conversion (e.g. "max_load_time", "engine").
193 "Clamped" means the value was modified (capped, force-set), not discarded. Empty if nothing was clamped or for non-demo responses.
194
195 my @clamped = $client->getClampedFields();
196
197 Returns:
198
199 - List of parameter names (an array reference in scalar context).
200 =cut
201 0 ▶sub getClampedFields {
Subroutine getClampedFields: not called CC=2 SCAR=17.9
Pod documented
202 0 my($self) = @_;
203 0 my @fields = @{ $self->{clampedFields} };
204 0 ▶ return wantarray ? @fields : \@fields;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
205 }
206
207 =head2 wasClamped
208
209 True if the most recent response had any clamped fields.
210
211 Returns:
212
213 - 1 or 0.
214 =cut
215 0 ▶sub wasClamped {
Subroutine wasClamped: not called CC=2 SCAR=17.9
Pod documented
216 0 my($self) = @_;
217 0 ▶ return scalar(@{ $self->{clampedFields} }) > 0 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
scalar @{$self->{'clampedFields'};} > 0 ? : 0 0 0
218 }
219
220 =head2 getDroppedFields
221
222 Names of the parameters the demo endpoint silently dropped on the most recent conversion (e.g. "auth_username", "cookies").
223 The demo endpoint refuses to honor a small set of fields for safety reasons - auth credentials, cookies, raw_parameters,
224 pdf_name, async - and reports any caller-supplied value via the X-SelectPdf-Demo-Dropped response header.
225 Empty if nothing was dropped or for non-demo responses. Clamped = value modified, dropped = value thrown away.
226
227 my @dropped = $client->getDroppedFields();
228
229 Returns:
230
231 - List of parameter names (an array reference in scalar context).
232 =cut
233 1 ▶sub getDroppedFields {
Subroutine getDroppedFields: called CC=2 SCAR=7.0
Pod documented
234 1 my($self) = @_;
235 1 my @fields = @{ $self->{droppedFields} };
236 1 ▶ return wantarray ? @fields : \@fields;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 1 1
237 }
238
239 =head2 wasAnyFieldDropped
240
241 True if the most recent response reported any dropped fields.
242
243 Returns:
244
245 - 1 or 0.
246 =cut
247 0 ▶sub wasAnyFieldDropped {
Subroutine wasAnyFieldDropped: not called CC=2 SCAR=17.9
Pod documented
248 0 my($self) = @_;
249 0 ▶ return scalar(@{ $self->{droppedFields} }) > 0 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
scalar @{$self->{'droppedFields'};} > 0 ? : 0 0 0
250 }
251
252 # Async conversions are not available on the keyless demo endpoint.
253 1 ▶sub _requireNonDemoForAsync {
Subroutine _requireNonDemoForAsync: called CC=2 SCAR=7.2
254 1 my($self) = @_;
255 1 ▶ die SelectPdf::DemoUnsupportedException->newLocal("async") if ($self->{isDemoMode});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"isDemoMode"} 1 0 1
256 }
257
258 =head2 convertUrl( $url )
259
260 Convert the specified url to PDF.
261 SelectPdf online API can convert http:// and https:// publicly available urls.
262
263 $content = $client->convertUrl($url);
264
265 Parameters:
266
267 - $url Address of the web page being converted.
268
269 Returns:
270
271 - Byte array containing the resulted PDF.
272 =cut
273 0 ▶sub convertUrl($) {
Subroutine convertUrl: not called CC=1 SCAR=6.9
Pod documented
274 0 my($self, $url) = @_;
275
276 0 $self->{parameters}{"url"} = $url;
277 0 $self->{parameters}{"async"} = "False";
278 0 $self->{parameters}{"html"} = "";
279 0 $self->{parameters}{"base_url"} = "";
280
281 0 return $self->SUPER::performPost();
282 }
283
284 =head2 convertUrlToFile( $url, $filePath )
285
286 Convert the specified url to PDF and writes the resulted PDF to a local file.
287 SelectPdf online API can convert http:// and https:// publicly available urls.
288
289 $client->convertUrlToFile($url, $filePath);
290
291 Parameters:
292
293 - $url Address of the web page being converted.
294
295 - $filePath Local file including path if necessary.
296 =cut
297 0 ▶sub convertUrlToFile($;$) {
Subroutine convertUrlToFile: not called CC=2 SCAR=17.9
Pod documented
298 0 my($self, $url, $filePath) = @_;
299
300 0 my $content = $self->convertUrl($url);
301
302 0 ▶ my $file = IO::File->new( $filePath, '>' ) or die "Unable to open output file - $!\n";
Branch: 1 branch
BranchTrueFalseTotal
my $file = "IO::File"->new($filePath, ">") or die "Unable to open output file - $!\n" 0 0 0
303 0 $file->binmode;
304 0 $file->print( $content );
305 0 $file->close;
306 }
307
308 =head2 convertUrlAsync( $url )
309
310 Convert the specified url to PDF using an asynchronous call.
311 SelectPdf online API can convert http:// and https:// publicly available urls.
312 Not available in demo mode (dies with a SelectPdf::DemoUnsupportedException).
313
314 $content = $client->convertUrlAsync($url);
315
316 Parameters:
317
318 - $url Address of the web page being converted.
319
320 Returns:
321
322 - Byte array containing the resulted PDF.
323 =cut
324 0 ▶sub convertUrlAsync($) {
Subroutine convertUrlAsync: not called CC=4 SCAR=30.0
Pod documented
325 0 my($self, $url) = @_;
326
327 0 $self->_requireNonDemoForAsync();
328
329 0 $self->{parameters}{"url"} = $url;
330 0 $self->{parameters}{"html"} = "";
331 0 $self->{parameters}{"base_url"} = "";
332
333 0 ▶ my $JobID = $self->SUPER::startAsyncJob() or die "An error occurred launching the asynchronous call.";
Branch: 1 branch
BranchTrueFalseTotal
my $JobID = $self->SUPER::startAsyncJob or die "An error occurred launching the asynchronous call." 0 0 0
334
335 0 my $noPings = 0;
336
337 do
338 {
339 0 $noPings++;
340
341 # sleep for a few seconds before next ping
342 0 sleep($self->{AsyncCallsPingInterval});
343
344 0 my $asyncJobClient = new SelectPdf::AsyncJobClient($self->{parameters}{"key"}, $JobID);
345 0 $asyncJobClient->setApiEndpoint($self->{apiAsyncEndpoint});
346
347 0 my $result = $asyncJobClient->getResult();
348
349 0 ▶ if ($asyncJobClient->finished)
Branch: 1 branch
BranchTrueFalseTotal
if ($asyncJobClient->finished) 0 0 0
350 {
351 0 $self->{numberOfPages} = $asyncJobClient->getNumberOfPages();
352
353 0 return $result;
354 }
355
356 0 ▶ } while ($noPings <= $self->{AsyncCallsMaxPings});
Branch: 1 branch
BranchTrueFalseTotal
$noPings <= $self->{"AsyncCallsMaxPings"} and do { do { ++$noPings; sleep $self->{"AsyncCallsPingInterval"}; my $asyncJobClient = "SelectPdf::AsyncJobClient"->new($self->{"parameters"}{"key"}, $JobID); $asyncJobClient->setApiEndpoint($self->{"apiAsyncEndpoint"}); my $result = $asyncJobClient->getResult; if ($asyncJobClient->finished) { $self->{"numberOfPages"} = $asyncJobClient->getNumberOfPages; return $result; } } } 0 0 0
357
358 0 die "Asynchronous call did not finish in expected timeframe.";
359
360 }
361
362 =head2 convertUrlToFileAsync( $url, $filePath )
363
364 Convert the specified url to PDF using an asynchronous call and writes the resulted PDF to a local file.
365 SelectPdf online API can convert http:// and https:// publicly available urls.
366 Not available in demo mode (dies with a SelectPdf::DemoUnsupportedException).
367
368 $client->convertUrlToFileAsync($url, $filePath);
369
370 Parameters:
371
372 - $url Address of the web page being converted.
373
374 - $filePath Local file including path if necessary.
375 =cut
376 0 ▶sub convertUrlToFileAsync($;$) {
Subroutine convertUrlToFileAsync: not called CC=2 SCAR=17.9
Pod documented
377 0 my($self, $url, $filePath) = @_;
378
379 0 my $content = $self->convertUrlAsync($url);
380
381 0 ▶ my $file = IO::File->new( $filePath, '>' ) or die "Unable to open output file - $!\n";
Branch: 1 branch
BranchTrueFalseTotal
my $file = "IO::File"->new($filePath, ">") or die "Unable to open output file - $!\n" 0 0 0
382 0 $file->binmode;
383 0 $file->print( $content );
384 0 $file->close;
385 }
386
387 =head2 convertHtmlStringWithBaseUrl( $htmlString, $baseUrl )
388
389 Convert the specified HTML string to PDF. Use a base url to resolve relative paths to resources.
390
391 $content = $client->convertHtmlStringWithBaseUrl($htmlString, $baseUrl);
392
393 Parameters:
394
395 - $htmlString HTML string with the content being converted.
396
397 - $baseUrl Base url used to resolve relative paths to resources (css, images, javascript, etc). Must be a http:// or https:// publicly available url.
398
399 Returns:
400
401 - Byte array containing the resulted PDF.
402 =cut
403 0 ▶sub convertHtmlStringWithBaseUrl($$) {
Subroutine convertHtmlStringWithBaseUrl: not called CC=1 SCAR=6.9
Pod documented
404 0 my($self, $htmlString, $baseUrl) = @_;
405
406 0 $self->{parameters}{"url"} = "";
407 0 $self->{parameters}{"async"} = "False";
408 0 $self->{parameters}{"html"} = $htmlString;
409 0 $self->{parameters}{"base_url"} = $baseUrl;
410
411 0 return $self->SUPER::performPost();
412 }
413
414 =head2 convertHtmlStringWithBaseUrlToFile( $htmlString, $baseUrl, $filePath )
415
416 Convert the specified HTML string to PDF and writes the resulted PDF to a local file. Use a base url to resolve relative paths to resources.
417
418 $client->convertHtmlStringWithBaseUrlToFile($htmlString, $baseUrl, $filePath);
419
420 Parameters:
421
422 - $htmlString HTML string with the content being converted.
423
424 - $baseUrl Base url used to resolve relative paths to resources (css, images, javascript, etc). Must be a http:// or https:// publicly available url.
425
426 - $filePath: Local file including path if necessary.
427
428 =cut
429 0 ▶sub convertHtmlStringWithBaseUrlToFile($$$) {
Subroutine convertHtmlStringWithBaseUrlToFile: not called CC=2 SCAR=17.9
Pod documented
430 0 my($self, $htmlString, $baseUrl, $filePath) = @_;
431
432 0 my $content = $self->convertHtmlStringWithBaseUrl($htmlString, $baseUrl);
433
434 0 ▶ my $file = IO::File->new( $filePath, '>' ) or die "Unable to open output file - $!\n";
Branch: 1 branch
BranchTrueFalseTotal
my $file = "IO::File"->new($filePath, ">") or die "Unable to open output file - $!\n" 0 0 0
435 0 $file->binmode;
436 0 $file->print( $content );
437 0 $file->close;
438 }
439
440 =head2 convertHtmlStringWithBaseUrlAsync( $htmlString, $baseUrl )
441
442 Convert the specified HTML string to PDF with an asynchronous call. Use a base url to resolve relative paths to resources.
443 Not available in demo mode (dies with a SelectPdf::DemoUnsupportedException).
444
445 $content = $client->convertHtmlStringWithBaseUrlAsync($htmlString, $baseUrl);
446
447 Parameters:
448
449 - $htmlString HTML string with the content being converted.
450
451 - $baseUrl Base url used to resolve relative paths to resources (css, images, javascript, etc). Must be a http:// or https:// publicly available url.
452
453 Returns:
454
455 - Byte array containing the resulted PDF.
456 =cut
457 1 ▶sub convertHtmlStringWithBaseUrlAsync($$) {
Subroutine convertHtmlStringWithBaseUrlAsync: called CC=4 SCAR=27.9
Pod documented
458 1 my($self, $htmlString, $baseUrl) = @_;
459
460 1 $self->_requireNonDemoForAsync();
461
462 0 $self->{parameters}{"url"} = "";
463 0 $self->{parameters}{"async"} = "False";
464 0 $self->{parameters}{"html"} = $htmlString;
465 0 $self->{parameters}{"base_url"} = $baseUrl;
466
467 0 ▶ my $JobID = $self->SUPER::startAsyncJob() or die "An error occurred launching the asynchronous call.";
Branch: 1 branch
BranchTrueFalseTotal
my $JobID = $self->SUPER::startAsyncJob or die "An error occurred launching the asynchronous call." 0 0 0
468
469 0 my $noPings = 0;
470
471 do
472 {
473 0 $noPings++;
474
475 # sleep for a few seconds before next ping
476 0 sleep($self->{AsyncCallsPingInterval});
477
478 0 my $asyncJobClient = new SelectPdf::AsyncJobClient($self->{parameters}{"key"}, $JobID);
479 0 $asyncJobClient->setApiEndpoint($self->{apiAsyncEndpoint});
480
481 0 my $result = $asyncJobClient->getResult();
482
483 0 ▶ if ($asyncJobClient->finished)
Branch: 1 branch
BranchTrueFalseTotal
if ($asyncJobClient->finished) 0 0 0
484 {
485 0 $self->{numberOfPages} = $asyncJobClient->getNumberOfPages();
486
487 0 return $result;
488 }
489
490 0 ▶ } while ($noPings <= $self->{AsyncCallsMaxPings});
Branch: 1 branch
BranchTrueFalseTotal
$noPings <= $self->{"AsyncCallsMaxPings"} and do { do { ++$noPings; sleep $self->{"AsyncCallsPingInterval"}; my $asyncJobClient = "SelectPdf::AsyncJobClient"->new($self->{"parameters"}{"key"}, $JobID); $asyncJobClient->setApiEndpoint($self->{"apiAsyncEndpoint"}); my $result = $asyncJobClient->getResult; if ($asyncJobClient->finished) { $self->{"numberOfPages"} = $asyncJobClient->getNumberOfPages; return $result; } } } 0 0 0
491
492 0 die "Asynchronous call did not finish in expected timeframe.";
493
494 }
495
496 =head2 convertHtmlStringWithBaseUrlToFileAsync( $htmlString, $baseUrl, $filePath )
497
498 Convert the specified HTML string to PDF with an asynchronous call and writes the resulted PDF to a local file. Use a base url to resolve relative paths to resources.
499 Not available in demo mode (dies with a SelectPdf::DemoUnsupportedException).
500
501 $client->convertHtmlStringWithBaseUrlToFileAsync($htmlString, $baseUrl, $filePath);
502
503 Parameters:
504
505 - $htmlString HTML string with the content being converted.
506
507 - $baseUrl Base url used to resolve relative paths to resources (css, images, javascript, etc). Must be a http:// or https:// publicly available url.
508
509 - $filePath: Local file including path if necessary.
510
511 =cut
512 0 ▶sub convertHtmlStringWithBaseUrlToFileAsync($$$) {
Subroutine convertHtmlStringWithBaseUrlToFileAsync: not called CC=2 SCAR=17.9
Pod documented
513 0 my($self, $htmlString, $baseUrl, $filePath) = @_;
514
515 0 my $content = $self->convertHtmlStringWithBaseUrlAsync($htmlString, $baseUrl);
516
517 0 ▶ my $file = IO::File->new( $filePath, '>' ) or die "Unable to open output file - $!\n";
Branch: 1 branch
BranchTrueFalseTotal
my $file = "IO::File"->new($filePath, ">") or die "Unable to open output file - $!\n" 0 0 0
518 0 $file->binmode;
519 0 $file->print( $content );
520 0 $file->close;
521 }
522
523 =head2 convertHtmlString( $htmlString )
524
525 Convert the specified HTML string to PDF.
526
527 $content = $client->convertHtmlString($htmlString);
528
529 Parameters:
530
531 - $htmlString HTML string with the content being converted.
532
533 Returns:
534
535 - Byte array containing the resulted PDF.
536 =cut
537 0 ▶sub convertHtmlString($) {
Subroutine convertHtmlString: not called CC=1 SCAR=6.9
Pod documented
538 0 my($self, $htmlString) = @_;
539
540 0 return $self->convertHtmlStringWithBaseUrl($htmlString, "");
541 }
542
543 =head2 convertHtmlStringToFile( $htmlString, $filePath )
544
545 Convert the specified HTML string to PDF and writes the resulted PDF to a local file.
546
547 $client->convertHtmlStringToFile($htmlString, $filePath);
548
549 Parameters:
550
551 - $htmlString HTML string with the content being converted.
552
553 - $filePath: Local file including path if necessary.
554
555 =cut
556 0 ▶sub convertHtmlStringToFile($$) {
Subroutine convertHtmlStringToFile: not called CC=1 SCAR=6.9
Pod documented
557 0 my($self, $htmlString, $filePath) = @_;
558
559 0 $self->convertHtmlStringWithBaseUrlToFile($htmlString, "", $filePath);
560 }
561
562 =head2 convertHtmlStringAsync( $htmlString )
563
564 Convert the specified HTML string to PDF with an asynchronous call.
565 Not available in demo mode (dies with a SelectPdf::DemoUnsupportedException).
566
567 $content = $client->convertHtmlStringAsync($htmlString);
568
569 Parameters:
570
571 - $htmlString HTML string with the content being converted.
572
573 Returns:
574
575 - Byte array containing the resulted PDF.
576 =cut
577 1 ▶sub convertHtmlStringAsync($) {
Subroutine convertHtmlStringAsync: called CC=1 SCAR=0.0
Pod documented
578 1 my($self, $htmlString) = @_;
579
580 1 return $self->convertHtmlStringWithBaseUrlAsync($htmlString, "");
581 }
582
583 =head2 convertHtmlStringToFileAsync( $htmlString, $filePath )
584
585 Convert the specified HTML string to PDF with an asynchronous call and writes the resulted PDF to a local file.
586 Not available in demo mode (dies with a SelectPdf::DemoUnsupportedException).
587
588 $client->convertHtmlStringToFileAsync($htmlString, $filePath);
589
590 Parameters:
591
592 - $htmlString HTML string with the content being converted.
593
594 - $filePath: Local file including path if necessary.
595
596 =cut
597 0 ▶sub convertHtmlStringToFileAsync($$) {
Subroutine convertHtmlStringToFileAsync: not called CC=1 SCAR=6.9
Pod documented
598 0 my($self, $htmlString, $filePath) = @_;
599
600 0 $self->convertHtmlStringWithBaseUrlToFileAsync($htmlString, "", $filePath);
601 }
602
603 =head2 setPageSize( $pageSize )
604
605 Set PDF page size. Default value is A4. If page size is set to Custom, use setPageWidth and setPageHeight methods to set the custom width/height of the PDF pages.
606
607 Parameters:
608
609 - $pageSize: PDF page size. Possible values: Custom, A0, A1, A2, A3, A4, A5, A6, A7, A8, Letter, HalfLetter, Ledger, Legal.
610
611 Returns:
612
613 - Reference to the current object.
614 =cut
615 0 ▶sub setPageSize($) {
Subroutine setPageSize: not called CC=2 SCAR=17.9
Pod documented
616 0 my($self, $pageSize) = @_;
617
618 0 ▶ if ($pageSize !~ m/^(Custom|A0|A1|A2|A3|A4|A5|A6|A7|A8|Letter|HalfLetter|Ledger|Legal)$/i) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pageSize =~ /^(Custom|A0|A1|A2|A3|A4|A5|A6|A7|A8|Letter|HalfLetter|Ledger|Legal)$/i) 0 0 0
619 0 die ("Allowed values for Page Size: Custom, A0, A1, A2, A3, A4, A5, A6, A7, A8, Letter, HalfLetter, Ledger, Legal.");
620 }
621
622 0 $self->{parameters}{"page_size"} = $pageSize;
623 0 return $self;
624 }
625
626 =head2 setPageWidth( $pageWidth )
627
628 Set PDF page width in points. Default value is 595pt (A4 page width in points). 1pt = 1/72 inch.
629 This is taken into account only if page size is set to Custom using setPageSize method.
630
631 Parameters:
632
633 - $pageWidth: Page width in points.
634
635 Returns:
636
637 - Reference to the current object.
638 =cut
639 0 ▶sub setPageWidth($) {
Subroutine setPageWidth: not called CC=1 SCAR=6.9
Pod documented
640 0 my($self, $pageWidth) = @_;
641
642 0 $self->{parameters}{"page_width"} = $pageWidth;
643 0 return $self;
644 }
645
646 =head2 setPageHeight( $pageHeight )
647
648 Set PDF page height in points. Default value is 842pt (A4 page height in points). 1pt = 1/72 inch.
649 This is taken into account only if page size is set to Custom using setPageSize method.
650
651 Parameters:
652
653 - $pageHeight: Page height in points.
654
655 Returns:
656
657 - Reference to the current object.
658 =cut
659 0 ▶sub setPageHeight($) {
Subroutine setPageHeight: not called CC=1 SCAR=6.9
Pod documented
660 0 my($self, $pageHeight) = @_;
661
662 0 $self->{parameters}{"page_height"} = $pageHeight;
663 0 return $self;
664 }
665
666 =head2 setPageOrientation( $pageOrientation )
667
668 Set PDF page orientation. Default value is Portrait.
669
670 Parameters:
671
672 - $pageOrientation: PDF page orientation. Possible values: Portrait, Landscape.
673
674 Returns:
675
676 - Reference to the current object.
677 =cut
678 0 ▶sub setPageOrientation($) {
Subroutine setPageOrientation: not called CC=2 SCAR=17.9
Pod documented
679 0 my($self, $pageOrientation) = @_;
680
681 0 ▶ if ($pageOrientation !~ m/^(Portrait|Landscape)$/i) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pageOrientation =~ /^(Portrait|Landscape)$/i) 0 0 0
682 0 die ("Allowed values for Page Orientation: Portrait, Landscape.");
683 }
684
685 0 $self->{parameters}{"page_orientation"} = $pageOrientation;
686 0 return $self;
687 }
688
689 =head2 setMarginTop( $marginTop )
690
691 Set top margin of the PDF pages. Default value is 5pt.
692
693 Parameters:
694
695 - $marginTop: Margin value in points. 1pt = 1/72 inch.
696
697 Returns:
698
699 - Reference to the current object.
700 =cut
701 0 ▶sub setMarginTop($) {
Subroutine setMarginTop: not called CC=1 SCAR=6.9
Pod documented
702 0 my($self, $marginTop) = @_;
703
704 0 $self->{parameters}{"margin_top"} = $marginTop;
705 0 return $self;
706 }
707
708 =head2 setMarginRight( $marginRight )
709
710 Set right margin of the PDF pages. Default value is 5pt.
711
712 Parameters:
713
714 - $marginRight: Margin value in points. 1pt = 1/72 inch.
715
716 Returns:
717
718 - Reference to the current object.
719 =cut
720 0 ▶sub setMarginRight($) {
Subroutine setMarginRight: not called CC=1 SCAR=6.9
Pod documented
721 0 my($self, $marginRight) = @_;
722
723 0 $self->{parameters}{"margin_right"} = $marginRight;
724 0 return $self;
725 }
726
727 =head2 setMarginBottom( $marginBottom )
728
729 Set bottom margin of the PDF pages. Default value is 5pt.
730
731 Parameters:
732
733 - $marginBottom: Margin value in points. 1pt = 1/72 inch.
734
735 Returns:
736
737 - Reference to the current object.
738 =cut
739 0 ▶sub setMarginBottom($) {
Subroutine setMarginBottom: not called CC=1 SCAR=6.9
Pod documented
740 0 my($self, $marginBottom) = @_;
741
742 0 $self->{parameters}{"margin_bottom"} = $marginBottom;
743 0 return $self;
744 }
745
746 =head2 setMarginLeft( $marginLeft )
747
748 Set left margin of the PDF pages. Default value is 5pt.
749
750 Parameters:
751
752 - $marginLeft: Margin value in points. 1pt = 1/72 inch.
753
754 Returns:
755
756 - Reference to the current object.
757 =cut
758 0 ▶sub setMarginLeft($) {
Subroutine setMarginLeft: not called CC=1 SCAR=6.9
Pod documented
759 0 my($self, $marginLeft) = @_;
760
761 0 $self->{parameters}{"margin_left"} = $marginLeft;
762 0 return $self;
763 }
764
765 =head2 setMargins( $margin )
766
767 Set all margins of the PDF pages to the same value. Default value is 5pt.
768
769 Parameters:
770
771 - $margin: Margin value in points. 1pt = 1/72 inch.
772
773 Returns:
774
775 - Reference to the current object.
776 =cut
777 0 ▶sub setMargins($) {
Subroutine setMargins: not called CC=1 SCAR=6.9
Pod documented
778 0 my($self, $margin) = @_;
779
780 0 return $self->setMarginTop($margin)->setMarginRight($margin)->setMarginBottom($margin)->setMarginLeft($margin);
781 }
782
783 =head2 setPdfName( $pdfName )
784
785 Specify the name of the pdf document that will be created. The default value is Document.pdf.
786
787 Parameters:
788
789 - $pdfName: Name of the generated PDF document.
790
791 Returns:
792
793 - Reference to the current object.
794 =cut
795 0 ▶sub setPdfName($) {
Subroutine setPdfName: not called CC=1 SCAR=6.9
Pod documented
796 0 my($self, $pdfName) = @_;
797
798 0 $self->{parameters}{"pdf_name"} = $pdfName;
799 0 return $self;
800 }
801
802 =head2 setRenderingEngine( $renderingEngine )
803
804 Set the rendering engine used for the HTML to PDF conversion. Default value is WebKit.
805
806 Parameters:
807
808 - $renderingEngine: HTML rendering engine. Possible values: WebKit, Restricted, Blink, Chromium (see SelectPdf::RenderingEngine constants).
809
810 Returns:
811
812 - Reference to the current object.
813 =cut
814 1 ▶sub setRenderingEngine($) {
Subroutine setRenderingEngine: called CC=2 SCAR=7.4
Pod documented
815 1 my($self, $renderingEngine) = @_;
816
817 1 ▶ if ($renderingEngine !~ m/^(WebKit|Restricted|Blink|Chromium)$/i) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($renderingEngine =~ /^(WebKit|Restricted|Blink|Chromium)$/i) 0 1 1
818 0 die ("Allowed values for Rendering Engine: WebKit, Restricted, Blink, Chromium.");
819 }
820
821 1 $self->{parameters}{"engine"} = $renderingEngine;
822 1 return $self;
823 }
824
825 =head2 setTagged( $tagged )
826
827 Produce a tagged, accessible PDF: a logical structure tree covering headings, paragraphs, lists, tables,
828 figures with alternate text, links and reading order. Default is False.
829
830 Requires the Blink or Chromium rendering engine - the WebKit engines cannot produce a structure tree.
831 If no engine is set, the API promotes the request to Chromium and reports it in the X-SelectPdf-Engine response header.
832 Setting an explicit WebKit engine together with tagged output is rejected by the API.
833
834 A tagged document also needs a title, so set setDocTitle - the converter falls back to the HTML document title when it is not set.
835
836 Parameters:
837
838 - $tagged: Produce a tagged, accessible PDF.
839
840 Returns:
841
842 - Reference to the current object.
843 =cut
844 1 ▶sub setTagged($) {
Subroutine setTagged: called CC=1 SCAR=0.0
Pod documented
845 1 my($self, $tagged) = @_;
846
847 1 $self->{parameters}{"tagged"} = $self->SUPER::serializeBoolean($tagged);
848 1 return $self;
849 }
850
851 =head2 setPdfStandard( $pdfStandard )
852
853 Set the PDF conformance target - PDF/A for archiving, PDF/X for graphics exchange, PDF/SiqQ for digital signatures. Default is Full.
854
855 PdfA3A is the accessible level of PDF/A-3: it implies a tagged document, so it carries the same rendering-engine requirement as setTagged.
856
857 Parameters:
858
859 - $pdfStandard: PDF conformance target. Possible values: Full, PdfA, PdfA2B, PdfA3A, PdfA3B, PdfA3U, PdfX, PdfSiqQ_A, PdfSiqQ_B (see SelectPdf::PdfStandard constants).
860
861 Returns:
862
863 - Reference to the current object.
864 =cut
865 2 ▶sub setPdfStandard($) {
Subroutine setPdfStandard: called CC=3 SCAR=11.0
Pod documented
866 2 my($self, $pdfStandard) = @_;
867
868 2 ▶ if (not defined($pdfStandard) or $pdfStandard !~ m/^(Full|PdfA|PdfA2B|PdfA3A|PdfA3B|PdfA3U|PdfX|PdfSiqQ_A|PdfSiqQ_B)$/i) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $pdfStandard and $pdfStandard =~ /^(Full|PdfA|PdfA2B|PdfA3A|PdfA3B|PdfA3U|PdfX|PdfSiqQ_A|PdfSiqQ_B)$/i) 1 1 2
Condition66%2/3
defined $pdfStandard and $pdfStandard =~ /^(Full|PdfA|PdfA2B|PdfA3A|PdfA3B|PdfA3U|PdfX|PdfSiqQ_A|PdfSiqQ_B)$/i
!ll&&!rl&&r
011
MC/DC50%1/2
defined $pdfStandard and $pdfStandard =~ /^(Full|PdfA|PdfA2B|PdfA3A|PdfA3B|PdfA3U|PdfX|PdfSiqQ_A|PdfSiqQ_B)$/i
defined $pdfStandard $pdfStandard =~ /^(Full|PdfA|PdfA2B|PdfA3A|PdfA3B|PdfA3U|PdfX|PdfSiqQ_A|PdfSiqQ_B)$/i
Truth table66%2/3
A and B
A= defined $pdfStandardB= $pdfStandard =~ /^(Full|PdfA|PdfA2B|PdfA3A|PdfA3B|PdfA3U|PdfX|PdfSiqQ_A|PdfSiqQ_B)$/i
ABresult
0X0
100
111
869 1 die ("Allowed values for Pdf Standard: Full, PdfA, PdfA2B, PdfA3A, PdfA3B, PdfA3U, PdfX, PdfSiqQ_A, PdfSiqQ_B.");
870 }
871
872 1 $self->{parameters}{"pdf_standard"} = $pdfStandard;
873 1 return $self;
874 }
875
876 =head2 setDocumentLanguage( $documentLanguage )
877
878 Set the natural language of the document, for example "en-US" or "de-DE".
879 Written as the PDF /Lang entry and onto tagged structure elements. Default is "en-US".
880
881 Parameters:
882
883 - $documentLanguage: Language tag, for example "en-US".
884
885 Returns:
886
887 - Reference to the current object.
888 =cut
889 1 ▶sub setDocumentLanguage($) {
Subroutine setDocumentLanguage: called CC=1 SCAR=0.0
Pod documented
890 1 my($self, $documentLanguage) = @_;
891
892 1 $self->{parameters}{"doc_language"} = $documentLanguage;
893 1 return $self;
894 }
895
896 =head2 setUserPassword( $userPassword )
897
898 Set PDF user password.
899
900 Not available in demo mode: if the client was constructed for the keyless demo endpoint,
901 this method dies with a SelectPdf::DemoUnsupportedException.
902
903 Parameters:
904
905 - $userPassword: PDF user password.
906
907 Returns:
908
909 - Reference to the current object.
910 =cut
911 1 ▶sub setUserPassword($) {
Subroutine setUserPassword: called CC=4 SCAR=18.7
Pod documented
912 1 my($self, $userPassword) = @_;
913
914 1 ▶ if ($self->{isDemoMode} and defined($userPassword) and $userPassword ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"isDemoMode"} and defined $userPassword and $userPassword ne "") 1 0 1
Condition33%2/6
$self->{"isDemoMode"} and defined $userPassword and $userPassword ne ""
!ll&&!rl&&r
001
$self->{"isDemoMode"} and defined $userPassword
!ll&&!rl&&r
001
MC/DC0%0/3
$self->{"isDemoMode"} and defined $userPassword and $userPassword ne ""
$self->{"isDemoMode"} defined $userPassword $userPassword ne ""
Truth table25%1/4
A and B and C
A= $self->{"isDemoMode"}B= defined $userPasswordC= $userPassword ne ""
ABCresult
0XX0
10X0
1100
1111
915 1 die SelectPdf::DemoUnsupportedException->newLocal("user_password");
916 }
917
918 0 $self->{parameters}{"user_password"} = $userPassword;
919 0 return $self;
920 }
921
922 =head2 setOwnerPassword( $ownerPassword )
923
924 Set PDF owner password.
925
926 Not available in demo mode: if the client was constructed for the keyless demo endpoint,
927 this method dies with a SelectPdf::DemoUnsupportedException.
928
929 Parameters:
930
931 - $ownerPassword: PDF owner password.
932
933 Returns:
934
935 - Reference to the current object.
936 =cut
937 1 ▶sub setOwnerPassword($) {
Subroutine setOwnerPassword: called CC=4 SCAR=18.7
Pod documented
938 1 my($self, $ownerPassword) = @_;
939
940 1 ▶ if ($self->{isDemoMode} and defined($ownerPassword) and $ownerPassword ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"isDemoMode"} and defined $ownerPassword and $ownerPassword ne "") 1 0 1
Condition33%2/6
$self->{"isDemoMode"} and defined $ownerPassword and $ownerPassword ne ""
!ll&&!rl&&r
001
$self->{"isDemoMode"} and defined $ownerPassword
!ll&&!rl&&r
001
MC/DC0%0/3
$self->{"isDemoMode"} and defined $ownerPassword and $ownerPassword ne ""
$self->{"isDemoMode"} defined $ownerPassword $ownerPassword ne ""
Truth table25%1/4
A and B and C
A= $self->{"isDemoMode"}B= defined $ownerPasswordC= $ownerPassword ne ""
ABCresult
0XX0
10X0
1100
1111
941 1 die SelectPdf::DemoUnsupportedException->newLocal("owner_password");
942 }
943
944 0 $self->{parameters}{"owner_password"} = $ownerPassword;
945 0 return $self;
946 }
947
948 =head2 setWebPageWidth( $webPageWidth )
949
950 Set the width used by the converter's internal browser window in pixels. The default value is 1024px.
951
952 Parameters:
953
954 - $webPageWidth: Browser window width in pixels.
955
956 Returns:
957
958 - Reference to the current object.
959 =cut
960 0 ▶sub setWebPageWidth($) {
Subroutine setWebPageWidth: not called CC=1 SCAR=6.9
Pod documented
961 0 my($self, $webPageWidth) = @_;
962
963 0 $self->{parameters}{"web_page_width"} = $webPageWidth;
964 0 return $self;
965 }
966
967 =head2 setWebPageHeight( $webPageHeight )
968
969 Set the height used by the converter's internal browser window in pixels.
970 The default value is 0px and it means that the page height is automatically calculated by the converter.
971
972 Parameters:
973
974 - $webPageHeight: Browser window height in pixels. Set it to 0px to automatically calculate page height.
975
976 Returns:
977
978 - Reference to the current object.
979 =cut
980 0 ▶sub setWebPageHeight($) {
Subroutine setWebPageHeight: not called CC=1 SCAR=6.9
Pod documented
981 0 my($self, $webPageHeight) = @_;
982
983 0 $self->{parameters}{"web_page_height"} = $webPageHeight;
984 0 return $self;
985 }
986
987 =head2 setWebPageFixedSize( $webPageFixedSize )
988
989 Leave out the content below the web page height (set with setWebPageHeight) instead of letting the page flow onto further pages.
990
991 When not set, each rendering engine keeps its own behavior: WebKit and WebKit Restricted leave the content out whenever a web page height is set,
992 Blink and Chromium convert the whole page. Set it to True or False to choose explicitly. It needs a non-zero web page height; with 0 there is no
993 height to fix the page at and the setting is ignored. With WebKit, a fixed size also cuts off content wider than the web page width.
994
995 Parameters:
996
997 - $webPageFixedSize: True to cut the page at the web page height, False to convert the whole page.
998
999 Returns:
1000
1001 - Reference to the current object.
1002 =cut
1003 1 ▶sub setWebPageFixedSize($) {
Subroutine setWebPageFixedSize: called CC=1 SCAR=0.0
Pod documented
1004 1 my($self, $webPageFixedSize) = @_;
1005
1006 1 $self->{parameters}{"web_page_fixed_size"} = $self->SUPER::serializeBoolean($webPageFixedSize);
1007 1 return $self;
1008 }
1009
1010 =head2 setMinLoadTime( $minLoadTime )
1011
1012 Introduce a delay (in seconds) before the actual conversion to allow the web page to fully load. This method is an alias for setConversionDelay.
1013 The default value is 1 second. Use a larger value if the web page has content that takes time to render when it is displayed in the browser.
1014
1015 Parameters:
1016
1017 - $minLoadTime: Delay in seconds.
1018
1019 Returns:
1020
1021 - Reference to the current object.
1022 =cut
1023 0 ▶sub setMinLoadTime($) {
Subroutine setMinLoadTime: not called CC=1 SCAR=6.9
Pod documented
1024 0 my($self, $minLoadTime) = @_;
1025
1026 0 $self->{parameters}{"min_load_time"} = $minLoadTime;
1027 0 return $self;
1028 }
1029
1030 =head2 setConversionDelay( $delay )
1031
1032 Introduce a delay (in seconds) before the actual conversion to allow the web page to fully load. This method is an alias for setMinLoadTime.
1033 The default value is 1 second. Use a larger value if the web page has content that takes time to render when it is displayed in the browser.
1034
1035 Parameters:
1036
1037 - $delay: Delay in seconds.
1038
1039 Returns:
1040
1041 - Reference to the current object.
1042 =cut
1043 0 ▶sub setConversionDelay($) {
Subroutine setConversionDelay: not called CC=1 SCAR=6.9
Pod documented
1044 0 my($self, $delay) = @_;
1045
1046 0 return $self->setMinLoadTime($delay);
1047 }
1048
1049 =head2 setMaxLoadTime( $maxLoadTime )
1050
1051 Set the maximum amount of time (in seconds) that the convert will wait for the page to load. This method is an alias for setNavigationTimeout.
1052 A timeout error is displayed when this time elapses. The default value is 30 seconds.
1053 Use a larger value (up to 120 seconds allowed) for pages that take a long time to load.
1054
1055 Parameters:
1056
1057 - $maxLoadTime: Timeout in seconds.
1058
1059 Returns:
1060
1061 - Reference to the current object.
1062 =cut
1063 0 ▶sub setMaxLoadTime($) {
Subroutine setMaxLoadTime: not called CC=1 SCAR=6.9
Pod documented
1064 0 my($self, $maxLoadTime) = @_;
1065
1066 0 $self->{parameters}{"max_load_time"} = $maxLoadTime;
1067 0 return $self;
1068 }
1069
1070 =head2 setNavigationTimeout( $timeout )
1071
1072 Set the maximum amount of time (in seconds) that the convert will wait for the page to load. This method is an alias for setMaxLoadTime.
1073 A timeout error is displayed when this time elapses. The default value is 30 seconds.
1074 Use a larger value (up to 120 seconds allowed) for pages that take a long time to load.
1075
1076 Parameters:
1077
1078 - $timeout: Timeout in seconds.
1079
1080 Returns:
1081
1082 - Reference to the current object.
1083 =cut
1084 0 ▶sub setNavigationTimeout($) {
Subroutine setNavigationTimeout: not called CC=1 SCAR=6.9
Pod documented
1085 0 my($self, $timeout) = @_;
1086
1087 0 return $self->setMaxLoadTime($timeout);
1088 }
1089
1090 =head2 setSecureProtocol( $secureProtocol )
1091
1092 Set the protocol used for secure (HTTPS) connections. Set this only if you have an older server that only works with older SSL connections.
1093
1094 Parameters:
1095
1096 - $secureProtocol: Secure protocol. Possible values: 0 (TLS 1.1 or newer), 1 (TLS 1.0), 2 (SSL v3 only).
1097
1098 Returns:
1099
1100 - Reference to the current object.
1101 =cut
1102 0 ▶sub setSecureProtocol($) {
Subroutine setSecureProtocol: not called CC=4 SCAR=30.0
Pod documented
1103 0 my($self, $secureProtocol) = @_;
1104
1105 0 ▶ if ($secureProtocol ne 0 and $secureProtocol ne 1 and $secureProtocol ne 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($secureProtocol ne 0 and $secureProtocol ne 1 and $secureProtocol ne 2) 0 0 0
Condition0%0/6
$secureProtocol ne 0 and $secureProtocol ne 1 and $secureProtocol ne 2
!ll&&!rl&&r
000
$secureProtocol ne 0 and $secureProtocol ne 1
!ll&&!rl&&r
000
MC/DC0%0/3
$secureProtocol ne 0 and $secureProtocol ne 1 and $secureProtocol ne 2
$secureProtocol ne 0 $secureProtocol ne 1 $secureProtocol ne 2
Truth table0%0/4
A and B and C
A= $secureProtocol ne 0B= $secureProtocol ne 1C= $secureProtocol ne 2
ABCresult
0XX0
10X0
1100
1111
1106 0 die ("Allowed values for Secure Protocol: 0 (TLS 1.1 or newer), 1 (TLS 1.0), 2 (SSL v3 only).");
1107 }
1108
1109 0 $self->{parameters}{"protocol"} = $secureProtocol;
1110 0 return $self;
1111 }
1112
1113 =head2 setUseCssPrint( $useCssPrint )
1114
1115 Specify if the CSS Print media type is used instead of the Screen media type. The default value is False.
1116
1117 Parameters:
1118
1119 - $useCssPrint: Use CSS Print media or not.
1120
1121 Returns:
1122
1123 - Reference to the current object.
1124 =cut
1125 0 ▶sub setUseCssPrint($) {
Subroutine setUseCssPrint: not called CC=1 SCAR=6.9
Pod documented
1126 0 my($self, $useCssPrint) = @_;
1127
1128 0 $self->{parameters}{"use_css_print"} = $self->SUPER::serializeBoolean($useCssPrint);
1129 0 return $self;
1130 }
1131
1132 =head2 setBackgroundColor( $backgroundColor )
1133
1134 Specify the background color of the PDF page in RGB html format. The default is #FFFFFF.
1135
1136 Parameters:
1137
1138 - $backgroundColor: Background color in #RRGGBB format.
1139
1140 Returns:
1141
1142 - Reference to the current object.
1143 =cut
1144 0 ▶sub setBackgroundColor($) {
Subroutine setBackgroundColor: not called CC=2 SCAR=17.9
Pod documented
1145 0 my($self, $backgroundColor) = @_;
1146
1147 0 ▶ if ($backgroundColor !~ m/^#?[0-9a-fA-F]{6}$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($backgroundColor =~ /^#?[0-9a-fA-F]{6}$/) 0 0 0
1148 0 die ("Color value must be in #RRGGBB format.");
1149 }
1150
1151 0 $self->{parameters}{"background_color"} = $backgroundColor;
1152 0 return $self;
1153 }
1154
1155 =head2 setDrawHtmlBackground( $drawHtmlBackground )
1156
1157 Set a flag indicating if the web page background is rendered in PDF. The default value is True.
1158
1159 Parameters:
1160
1161 - $drawHtmlBackground: Draw the HTML background or not.
1162
1163 Returns:
1164
1165 - Reference to the current object.
1166 =cut
1167 0 ▶sub setDrawHtmlBackground($) {
Subroutine setDrawHtmlBackground: not called CC=1 SCAR=6.9
Pod documented
1168 0 my($self, $drawHtmlBackground) = @_;
1169
1170 0 $self->{parameters}{"draw_html_background"} = $self->SUPER::serializeBoolean($drawHtmlBackground);
1171 0 return $self;
1172 }
1173
1174 =head2 setDisableJavascript( $disableJavascript )
1175
1176 Do not run JavaScript in web pages. The default value is False and javascript is executed.
1177
1178 Parameters:
1179
1180 - $disableJavascript: Disable javascript or not.
1181
1182 Returns:
1183
1184 - Reference to the current object.
1185 =cut
1186 0 ▶sub setDisableJavascript($) {
Subroutine setDisableJavascript: not called CC=1 SCAR=6.9
Pod documented
1187 0 my($self, $disableJavascript) = @_;
1188
1189 0 $self->{parameters}{"disable_javascript"} = $self->SUPER::serializeBoolean($disableJavascript);
1190 0 return $self;
1191 }
1192
1193 =head2 setDisableInternalLinks( $disableInternalLinks )
1194
1195 Do not create internal links in the PDF. The default value is False and internal links are created.
1196
1197 Parameters:
1198
1199 - $disableInternalLinks: Disable internal links or not.
1200
1201 Returns:
1202
1203 - Reference to the current object.
1204 =cut
1205 0 ▶sub setDisableInternalLinks($) {
Subroutine setDisableInternalLinks: not called CC=1 SCAR=6.9
Pod documented
1206 0 my($self, $disableInternalLinks) = @_;
1207
1208 0 $self->{parameters}{"disable_internal_links"} = $self->SUPER::serializeBoolean($disableInternalLinks);
1209 0 return $self;
1210 }
1211
1212 =head2 setDisableExternalLinks( $disableExternalLinks )
1213
1214 Do not create external links in the PDF. The default value is False and external links are created.
1215
1216 Parameters:
1217
1218 - $disableExternalLinks: Disable external links or not.
1219
1220 Returns:
1221
1222 - Reference to the current object.
1223 =cut
1224 0 ▶sub setDisableExternalLinks($) {
Subroutine setDisableExternalLinks: not called CC=1 SCAR=6.9
Pod documented
1225 0 my($self, $disableExternalLinks) = @_;
1226
1227 0 $self->{parameters}{"disable_external_links"} = $self->SUPER::serializeBoolean($disableExternalLinks);
1228 0 return $self;
1229 }
1230
1231 =head2 setRenderOnTimeout( $renderOnTimeout )
1232
1233 Try to render the PDF even in case of the web page loading timeout. The default value is False and an exception is raised in case of web page navigation timeout.
1234
1235 Parameters:
1236
1237 - $renderOnTimeout: Render in case of timeout or not.
1238
1239 Returns:
1240
1241 - Reference to the current object.
1242 =cut
1243 0 ▶sub setRenderOnTimeout($) {
Subroutine setRenderOnTimeout: not called CC=1 SCAR=6.9
Pod documented
1244 0 my($self, $renderOnTimeout) = @_;
1245
1246 0 $self->{parameters}{"render_on_timeout"} = $self->SUPER::serializeBoolean($renderOnTimeout);
1247 0 return $self;
1248 }
1249
1250 =head2 setKeepImagesTogether( $keepImagesTogether )
1251
1252 Avoid breaking images between PDF pages. The default value is False and images are split between pages if larger.
1253
1254 Parameters:
1255
1256 - $keepImagesTogether: Try to keep images on same page or not.
1257
1258 Returns:
1259
1260 - Reference to the current object.
1261 =cut
1262 0 ▶sub setKeepImagesTogether($) {
Subroutine setKeepImagesTogether: not called CC=1 SCAR=6.9
Pod documented
1263 0 my($self, $keepImagesTogether) = @_;
1264
1265 0 $self->{parameters}{"keep_images_together"} = $self->SUPER::serializeBoolean($keepImagesTogether);
1266 0 return $self;
1267 }
1268
1269 =head2 setDocTitle( $docTitle )
1270
1271 Set the PDF document title.
1272
1273 Parameters:
1274
1275 - $docTitle: Document title.
1276
1277 Returns:
1278
1279 - Reference to the current object.
1280 =cut
1281 0 ▶sub setDocTitle($) {
Subroutine setDocTitle: not called CC=1 SCAR=6.9
Pod documented
1282 0 my($self, $docTitle) = @_;
1283
1284 0 $self->{parameters}{"doc_title"} = $docTitle;
1285 0 return $self;
1286 }
1287
1288 =head2 setDocSubject( $docSubject )
1289
1290 Set the PDF document subject.
1291
1292 Parameters:
1293
1294 - $docSubject: Document subject.
1295
1296 Returns:
1297
1298 - Reference to the current object.
1299 =cut
1300 0 ▶sub setDocSubject($) {
Subroutine setDocSubject: not called CC=1 SCAR=6.9
Pod documented
1301 0 my($self, $docSubject) = @_;
1302
1303 0 $self->{parameters}{"doc_subject"} = $docSubject;
1304 0 return $self;
1305 }
1306
1307 =head2 setDocKeywords( $docKeywords )
1308
1309 Set the PDF document keywords.
1310
1311 Parameters:
1312
1313 - $docKeywords: Document keywords.
1314
1315 Returns:
1316
1317 - Reference to the current object.
1318 =cut
1319 0 ▶sub setDocKeywords($) {
Subroutine setDocKeywords: not called CC=1 SCAR=6.9
Pod documented
1320 0 my($self, $docKeywords) = @_;
1321
1322 0 $self->{parameters}{"doc_keywords"} = $docKeywords;
1323 0 return $self;
1324 }
1325
1326 =head2 setDocAuthor( $docAuthor )
1327
1328 Set the PDF document author.
1329
1330 Parameters:
1331
1332 - $docAuthor: Document author.
1333
1334 Returns:
1335
1336 - Reference to the current object.
1337 =cut
1338 0 ▶sub setDocAuthor($) {
Subroutine setDocAuthor: not called CC=1 SCAR=6.9
Pod documented
1339 0 my($self, $docAuthor) = @_;
1340
1341 0 $self->{parameters}{"doc_author"} = $docAuthor;
1342 0 return $self;
1343 }
1344
1345 =head2 setDocAddCreationDate( $docAddCreationDate )
1346
1347 Add the date and time when the PDF document was created to the PDF document information. The default value is False.
1348
1349 Parameters:
1350
1351 - $docAddCreationDate: Add creation date to the document metadata or not.
1352
1353 Returns:
1354
1355 - Reference to the current object.
1356 =cut
1357 0 ▶sub setDocAddCreationDate($) {
Subroutine setDocAddCreationDate: not called CC=1 SCAR=6.9
Pod documented
1358 0 my($self, $docAddCreationDate) = @_;
1359
1360 0 $self->{parameters}{"doc_add_creation_date"} = $self->SUPER::serializeBoolean($docAddCreationDate);
1361 0 return $self;
1362 }
1363
1364 =head2 setViewerPageLayout( $pageLayout )
1365
1366 Set the page layout to be used when the document is opened in a PDF viewer. The default value is 1 - OneColumn.
1367
1368 Parameters:
1369
1370 - $pageLayout: Page layout. Possible values: 0 (Single Page), 1 (One Column), 2 (Two Column Left), 3 (Two Column Right).
1371
1372 Returns:
1373
1374 - Reference to the current object.
1375 =cut
1376 0 ▶sub setViewerPageLayout($) {
Subroutine setViewerPageLayout: not called CC=5 SCAR=34.0
Pod documented
1377 0 my($self, $pageLayout) = @_;
1378
1379 0 ▶ if ($pageLayout ne 0 and $pageLayout ne 1 and $pageLayout ne 2 and $pageLayout ne 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pageLayout ne 0 and $pageLayout ne 1 and $pageLayout ne 2 and $pageLayout ne 3) 0 0 0
Condition0%0/9
$pageLayout ne 0 and $pageLayout ne 1 and $pageLayout ne 2 and $pageLayout ne 3
!ll&&!rl&&r
000
$pageLayout ne 0 and $pageLayout ne 1 and $pageLayout ne 2
!ll&&!rl&&r
000
$pageLayout ne 0 and $pageLayout ne 1
!ll&&!rl&&r
000
MC/DC0%0/4
$pageLayout ne 0 and $pageLayout ne 1 and $pageLayout ne 2 and $pageLayout ne 3
$pageLayout ne 0 $pageLayout ne 1 $pageLayout ne 2 $pageLayout ne 3
Truth table0%0/5
A and B and C and D
A= $pageLayout ne 0B= $pageLayout ne 1C= $pageLayout ne 2D= $pageLayout ne 3
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1380 0 die ("Allowed values for Page Layout: 0 (Single Page), 1 (One Column), 2 (Two Column Left), 3 (Two Column Right).");
1381 }
1382
1383 0 $self->{parameters}{"viewer_page_layout"} = $pageLayout;
1384 0 return $self;
1385 }
1386
1387 =head2 setViewerPageMode( $pageMode )
1388
1389 Set the document page mode when the pdf document is opened in a PDF viewer. The default value is 0 - UseNone.
1390
1391 Parameters:
1392
1393 - $pageMode: Page mode. Possible values: 0 (Use None), 1 (Use Outlines), 2 (Use Thumbs), 3 (Full Screen), 4 (Use OC), 5 (Use Attachments).
1394
1395 Returns:
1396
1397 - Reference to the current object.
1398 =cut
1399 0 ▶sub setViewerPageMode($) {
Subroutine setViewerPageMode: not called CC=7 SCAR=40.3
Pod documented
1400 0 my($self, $pageMode) = @_;
1401
1402 0 ▶ if ($pageMode ne 0 and $pageMode ne 1 and $pageMode ne 2 and $pageMode ne 3 and $pageMode ne 4 and $pageMode ne 5) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pageMode ne 0 and $pageMode ne 1 and $pageMode ne 2 and $pageMode ne 3 and $pageMode ne 4 and $pageMode ne 5) 0 0 0
Condition0%0/15
$pageMode ne 0 and $pageMode ne 1 and $pageMode ne 2 and $pageMode ne 3 and $pageMode ne 4 and $pageMode ne 5
!ll&&!rl&&r
000
$pageMode ne 0 and $pageMode ne 1 and $pageMode ne 2 and $pageMode ne 3 and $pageMode ne 4
!ll&&!rl&&r
000
$pageMode ne 0 and $pageMode ne 1 and $pageMode ne 2 and $pageMode ne 3
!ll&&!rl&&r
000
$pageMode ne 0 and $pageMode ne 1 and $pageMode ne 2
!ll&&!rl&&r
000
$pageMode ne 0 and $pageMode ne 1
!ll&&!rl&&r
000
MC/DC0%0/6
$pageMode ne 0 and $pageMode ne 1 and $pageMode ne 2 and $pageMode ne 3 and $pageMode ne 4 and $pageMode ne 5
$pageMode ne 0 $pageMode ne 1 $pageMode ne 2 $pageMode ne 3 $pageMode ne 4 $pageMode ne 5
Truth table0%0/7
A and B and C and D and E and F
A= $pageMode ne 0B= $pageMode ne 1C= $pageMode ne 2D= $pageMode ne 3E= $pageMode ne 4F= $pageMode ne 5
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
1403 0 die ("Allowed values for Page Mode: 0 (Use None), 1 (Use Outlines), 2 (Use Thumbs), 3 (Full Screen), 4 (Use OC), 5 (Use Attachments).");
1404 }
1405
1406 0 $self->{parameters}{"viewer_page_mode"} = $pageMode;
1407 0 return $self;
1408 }
1409
1410 =head2 setViewerCenterWindow( $viewerCenterWindow )
1411
1412 Set a flag specifying whether to position the document's window in the center of the screen. The default value is False.
1413
1414 Parameters:
1415
1416 - $viewerCenterWindow: Center window or not.
1417
1418 Returns:
1419
1420 - Reference to the current object.
1421 =cut
1422 0 ▶sub setViewerCenterWindow($) {
Subroutine setViewerCenterWindow: not called CC=1 SCAR=6.9
Pod documented
1423 0 my($self, $viewerCenterWindow) = @_;
1424
1425 0 $self->{parameters}{"viewer_center_window"} = $self->SUPER::serializeBoolean($viewerCenterWindow);
1426 0 return $self;
1427 }
1428
1429 =head2 setViewerDisplayDocTitle( $viewerDisplayDocTitle )
1430
1431 Set a flag specifying whether the window's title bar should display the document title taken from document information. The default value is False.
1432
1433 Parameters:
1434
1435 - $viewerDisplayDocTitle: Display title or not.
1436
1437 Returns:
1438
1439 - Reference to the current object.
1440 =cut
1441 0 ▶sub setViewerDisplayDocTitle($) {
Subroutine setViewerDisplayDocTitle: not called CC=1 SCAR=6.9
Pod documented
1442 0 my($self, $viewerDisplayDocTitle) = @_;
1443
1444 0 $self->{parameters}{"viewer_display_doc_title"} = $self->SUPER::serializeBoolean($viewerDisplayDocTitle);
1445 0 return $self;
1446 }
1447
1448 =head2 setViewerFitWindow( $viewerFitWindow )
1449
1450 Set a flag specifying whether to resize the document's window to fit the size of the first displayed page. The default value is False.
1451
1452 Parameters:
1453
1454 - $viewerFitWindow: Fit window or not.
1455
1456 Returns:
1457
1458 - Reference to the current object.
1459 =cut
1460 0 ▶sub setViewerFitWindow($) {
Subroutine setViewerFitWindow: not called CC=1 SCAR=6.9
Pod documented
1461 0 my($self, $viewerFitWindow) = @_;
1462
1463 0 $self->{parameters}{"viewer_fit_window"} = $self->SUPER::serializeBoolean($viewerFitWindow);
1464 0 return $self;
1465 }
1466
1467 =head2 setViewerHideMenuBar( $viewerHideMenuBar )
1468
1469 Set a flag specifying whether to hide the pdf viewer application's menu bar when the document is active. The default value is False.
1470
1471 Parameters:
1472
1473 - $viewerHideMenuBar: Hide menu bar or not.
1474
1475 Returns:
1476
1477 - Reference to the current object.
1478 =cut
1479 0 ▶sub setViewerHideMenuBar($) {
Subroutine setViewerHideMenuBar: not called CC=1 SCAR=6.9
Pod documented
1480 0 my($self, $viewerHideMenuBar) = @_;
1481
1482 0 $self->{parameters}{"viewer_hide_menu_bar"} = $self->SUPER::serializeBoolean($viewerHideMenuBar);
1483 0 return $self;
1484 }
1485
1486 =head2 setViewerHideToolbar( $viewerHideToolbar )
1487
1488 Set a flag specifying whether to hide the pdf viewer application's tool bars when the document is active. The default value is False.
1489
1490 Parameters:
1491
1492 - $viewerHideToolbar: Hide tool bars or not.
1493
1494 Returns:
1495
1496 - Reference to the current object.
1497 =cut
1498 0 ▶sub setViewerHideToolbar($) {
Subroutine setViewerHideToolbar: not called CC=1 SCAR=6.9
Pod documented
1499 0 my($self, $viewerHideToolbar) = @_;
1500
1501 0 $self->{parameters}{"viewer_hide_toolbar"} = $self->SUPER::serializeBoolean($viewerHideToolbar);
1502 0 return $self;
1503 }
1504
1505 =head2 setViewerHideWindowUI( $viewerHideWindowUI )
1506
1507 Set a flag specifying whether to hide user interface elements in the document's window (such as scroll bars and navigation controls),
1508 leaving only the document's contents displayed.
1509
1510 Parameters:
1511
1512 - $viewerHideWindowUI: Hide window UI or not.
1513
1514 Returns:
1515
1516 - Reference to the current object.
1517 =cut
1518 0 ▶sub setViewerHideWindowUI($) {
Subroutine setViewerHideWindowUI: not called CC=1 SCAR=6.9
Pod documented
1519 0 my($self, $viewerHideWindowUI) = @_;
1520
1521 0 $self->{parameters}{"viewer_hide_window_ui"} = $self->SUPER::serializeBoolean($viewerHideWindowUI);
1522 0 return $self;
1523 }
1524
1525 =head2 setShowHeader( $showHeader )
1526
1527 Control if a custom header is displayed in the generated PDF document. The default value is False.
1528
1529 Parameters:
1530
1531 - $showHeader: Show header or not.
1532
1533 Returns:
1534
1535 - Reference to the current object.
1536 =cut
1537 0 ▶sub setShowHeader($) {
Subroutine setShowHeader: not called CC=1 SCAR=6.9
Pod documented
1538 0 my($self, $showHeader) = @_;
1539
1540 0 $self->{parameters}{"show_header"} = $self->SUPER::serializeBoolean($showHeader);
1541 0 return $self;
1542 }
1543
1544 =head2 setHeaderHeight( $height )
1545
1546 The height of the pdf document header. This height is specified in points. 1 point is 1/72 inch. The default value is 50.
1547
1548 Parameters:
1549
1550 - $height: Header height.
1551
1552 Returns:
1553
1554 - Reference to the current object.
1555 =cut
1556 0 ▶sub setHeaderHeight($) {
Subroutine setHeaderHeight: not called CC=1 SCAR=6.9
Pod documented
1557 0 my($self, $height) = @_;
1558
1559 0 $self->{parameters}{"header_height"} = $height;
1560 0 return $self;
1561 }
1562
1563 =head2 setHeaderUrl( $url )
1564
1565 Set the url of the web page that is converted and rendered in the PDF document header.
1566
1567 Parameters:
1568
1569 - $url: The url of the web page that is converted and rendered in the pdf document header.
1570
1571 Returns:
1572
1573 - Reference to the current object.
1574 =cut
1575 0 ▶sub setHeaderUrl($) {
Subroutine setHeaderUrl: not called CC=1 SCAR=6.9
Pod documented
1576 0 my($self, $url) = @_;
1577
1578 0 $self->{parameters}{"header_url"} = $url;
1579 0 return $self;
1580 }
1581
1582 =head2 setHeaderHtml( $html )
1583
1584 Set the raw html that is converted and rendered in the pdf document header.
1585
1586 Parameters:
1587
1588 - $html: The raw html that is converted and rendered in the pdf document header.
1589
1590 Returns:
1591
1592 - Reference to the current object.
1593 =cut
1594 0 ▶sub setHeaderHtml($) {
Subroutine setHeaderHtml: not called CC=1 SCAR=6.9
Pod documented
1595 0 my($self, $html) = @_;
1596
1597 0 $self->{parameters}{"header_html"} = $html;
1598 0 return $self;
1599 }
1600
1601 =head2 setHeaderBaseUrl( $baseUrl )
1602
1603 Set an optional base url parameter can be used together with the header HTML to resolve relative paths from the html string.
1604
1605 Parameters:
1606
1607 - $baseUrl: Header base url.
1608
1609 Returns:
1610
1611 - Reference to the current object.
1612 =cut
1613 0 ▶sub setHeaderBaseUrl($) {
Subroutine setHeaderBaseUrl: not called CC=1 SCAR=6.9
Pod documented
1614 0 my($self, $baseUrl) = @_;
1615
1616 0 $self->{parameters}{"header_base_url"} = $baseUrl;
1617 0 return $self;
1618 }
1619
1620 =head2 setHeaderDisplayOnFirstPage( $displayOnFirstPage )
1621
1622 Control the visibility of the header on the first page of the generated pdf document. The default value is True.
1623
1624 Parameters:
1625
1626 - $displayOnFirstPage: Display header on the first page or not.
1627
1628 Returns:
1629
1630 - Reference to the current object.
1631 =cut
1632 0 ▶sub setHeaderDisplayOnFirstPage($) {
Subroutine setHeaderDisplayOnFirstPage: not called CC=1 SCAR=6.9
Pod documented
1633 0 my($self, $displayOnFirstPage) = @_;
1634
1635 0 $self->{parameters}{"header_display_on_first_page"} = $self->SUPER::serializeBoolean($displayOnFirstPage);
1636 0 return $self;
1637 }
1638
1639 =head2 setHeaderDisplayOnOddPages( $displayOnOddPages )
1640
1641 Control the visibility of the header on the odd numbered pages of the generated pdf document. The default value is True.
1642
1643 Parameters:
1644
1645 - $displayOnOddPages: Display header on odd pages or not.
1646
1647 Returns:
1648
1649 - Reference to the current object.
1650 =cut
1651 0 ▶sub setHeaderDisplayOnOddPages($) {
Subroutine setHeaderDisplayOnOddPages: not called CC=1 SCAR=6.9
Pod documented
1652 0 my($self, $displayOnOddPages) = @_;
1653
1654 0 $self->{parameters}{"header_display_on_odd_pages"} = $self->SUPER::serializeBoolean($displayOnOddPages);
1655 0 return $self;
1656 }
1657
1658 =head2 setHeaderDisplayOnEvenPages( $displayOnEvenPages )
1659
1660 Control the visibility of the header on the even numbered pages of the generated pdf document. The default value is True.
1661
1662 Parameters:
1663
1664 - $displayOnEvenPages: Display header on even pages or not.
1665
1666 Returns:
1667
1668 - Reference to the current object.
1669 =cut
1670 0 ▶sub setHeaderDisplayOnEvenPages($) {
Subroutine setHeaderDisplayOnEvenPages: not called CC=1 SCAR=6.9
Pod documented
1671 0 my($self, $displayOnEvenPages) = @_;
1672
1673 0 $self->{parameters}{"header_display_on_even_pages"} = $self->SUPER::serializeBoolean($displayOnEvenPages);
1674 0 return $self;
1675 }
1676
1677 =head2 setHeaderWebPageWidth( $headerWebPageWidth )
1678
1679 Set the width in pixels used by the converter's internal browser window during the conversion of the header content. The default value is 1024px.
1680
1681 Parameters:
1682
1683 - $headerWebPageWidth: Browser window width in pixels.
1684
1685 Returns:
1686
1687 - Reference to the current object.
1688 =cut
1689 0 ▶sub setHeaderWebPageWidth($) {
Subroutine setHeaderWebPageWidth: not called CC=1 SCAR=6.9
Pod documented
1690 0 my($self, $headerWebPageWidth) = @_;
1691
1692 0 $self->{parameters}{"header_web_page_width"} = $headerWebPageWidth;
1693 0 return $self;
1694 }
1695
1696 =head2 setHeaderWebPageHeight( $headerWebPageHeight )
1697
1698 Set the height in pixels used by the converter's internal browser window during the conversion of the header content.
1699 The default value is 0px and it means that the page height is automatically calculated by the converter.
1700
1701 Parameters:
1702
1703 - $headerWebPageHeight: Browser window height in pixels. Set it to 0px to automatically calculate page height.
1704
1705 Returns:
1706
1707 - Reference to the current object.
1708 =cut
1709 0 ▶sub setHeaderWebPageHeight($) {
Subroutine setHeaderWebPageHeight: not called CC=1 SCAR=6.9
Pod documented
1710 0 my($self, $headerWebPageHeight) = @_;
1711
1712 0 $self->{parameters}{"header_web_page_height"} = $headerWebPageHeight;
1713 0 return $self;
1714 }
1715
1716
1717
1718 =head2 setShowFooter( $showFooter )
1719
1720 Control if a custom footer is displayed in the generated PDF document. The default value is False.
1721
1722 Parameters:
1723
1724 - $showFooter: Show footer or not.
1725
1726 Returns:
1727
1728 - Reference to the current object.
1729 =cut
1730 0 ▶sub setShowFooter($) {
Subroutine setShowFooter: not called CC=1 SCAR=6.9
Pod documented
1731 0 my($self, $showFooter) = @_;
1732
1733 0 $self->{parameters}{"show_footer"} = $self->SUPER::serializeBoolean($showFooter);
1734 0 return $self;
1735 }
1736
1737 =head2 setFooterHeight( $height )
1738
1739 The height of the pdf document footer. This height is specified in points. 1 point is 1/72 inch. The default value is 50.
1740
1741 Parameters:
1742
1743 - $height: Footer height.
1744
1745 Returns:
1746
1747 - Reference to the current object.
1748 =cut
1749 0 ▶sub setFooterHeight($) {
Subroutine setFooterHeight: not called CC=1 SCAR=6.9
Pod documented
1750 0 my($self, $height) = @_;
1751
1752 0 $self->{parameters}{"footer_height"} = $height;
1753 0 return $self;
1754 }
1755
1756 =head2 setFooterUrl( $url )
1757
1758 Set the url of the web page that is converted and rendered in the PDF document footer.
1759
1760 Parameters:
1761
1762 - $url: The url of the web page that is converted and rendered in the pdf document footer.
1763
1764 Returns:
1765
1766 - Reference to the current object.
1767 =cut
1768 0 ▶sub setFooterUrl($) {
Subroutine setFooterUrl: not called CC=1 SCAR=6.9
Pod documented
1769 0 my($self, $url) = @_;
1770
1771 0 $self->{parameters}{"footer_url"} = $url;
1772 0 return $self;
1773 }
1774
1775 =head2 setFooterHtml( $html )
1776
1777 Set the raw html that is converted and rendered in the pdf document footer.
1778
1779 Parameters:
1780
1781 - $html: The raw html that is converted and rendered in the pdf document footer.
1782
1783 Returns:
1784
1785 - Reference to the current object.
1786 =cut
1787 0 ▶sub setFooterHtml($) {
Subroutine setFooterHtml: not called CC=1 SCAR=6.9
Pod documented
1788 0 my($self, $html) = @_;
1789
1790 0 $self->{parameters}{"footer_html"} = $html;
1791 0 return $self;
1792 }
1793
1794 =head2 setFooterBaseUrl( $baseUrl )
1795
1796 Set an optional base url parameter can be used together with the footer HTML to resolve relative paths from the html string.
1797
1798 Parameters:
1799
1800 - $baseUrl: Footer base url.
1801
1802 Returns:
1803
1804 - Reference to the current object.
1805 =cut
1806 0 ▶sub setFooterBaseUrl($) {
Subroutine setFooterBaseUrl: not called CC=1 SCAR=6.9
Pod documented
1807 0 my($self, $baseUrl) = @_;
1808
1809 0 $self->{parameters}{"footer_base_url"} = $baseUrl;
1810 0 return $self;
1811 }
1812
1813 =head2 setFooterDisplayOnFirstPage( $displayOnFirstPage )
1814
1815 Control the visibility of the footer on the first page of the generated pdf document. The default value is True.
1816
1817 Parameters:
1818
1819 - $displayOnFirstPage: Display footer on the first page or not.
1820
1821 Returns:
1822
1823 - Reference to the current object.
1824 =cut
1825 0 ▶sub setFooterDisplayOnFirstPage($) {
Subroutine setFooterDisplayOnFirstPage: not called CC=1 SCAR=6.9
Pod documented
1826 0 my($self, $displayOnFirstPage) = @_;
1827
1828 0 $self->{parameters}{"footer_display_on_first_page"} = $self->SUPER::serializeBoolean($displayOnFirstPage);
1829 0 return $self;
1830 }
1831
1832 =head2 setFooterDisplayOnOddPages( $displayOnOddPages )
1833
1834 Control the visibility of the footer on the odd numbered pages of the generated pdf document. The default value is True.
1835
1836 Parameters:
1837
1838 - $displayOnOddPages: Display footer on odd pages or not.
1839
1840 Returns:
1841
1842 - Reference to the current object.
1843 =cut
1844 0 ▶sub setFooterDisplayOnOddPages($) {
Subroutine setFooterDisplayOnOddPages: not called CC=1 SCAR=6.9
Pod documented
1845 0 my($self, $displayOnOddPages) = @_;
1846
1847 0 $self->{parameters}{"footer_display_on_odd_pages"} = $self->SUPER::serializeBoolean($displayOnOddPages);
1848 0 return $self;
1849 }
1850
1851 =head2 setFooterDisplayOnEvenPages( $displayOnEvenPages )
1852
1853 Control the visibility of the footer on the even numbered pages of the generated pdf document. The default value is True.
1854
1855 Parameters:
1856
1857 - $displayOnEvenPages: Display footer on even pages or not.
1858
1859 Returns:
1860
1861 - Reference to the current object.
1862 =cut
1863 0 ▶sub setFooterDisplayOnEvenPages($) {
Subroutine setFooterDisplayOnEvenPages: not called CC=1 SCAR=6.9
Pod documented
1864 0 my($self, $displayOnEvenPages) = @_;
1865
1866 0 $self->{parameters}{"footer_display_on_even_pages"} = $self->SUPER::serializeBoolean($displayOnEvenPages);
1867 0 return $self;
1868 }
1869
1870 =head2 setFooterDisplayOnLastPage( $displayOnLastPage )
1871
1872 Add a special footer on the last page of the generated pdf document only. The default value is False.
1873 Use setFooterUrl or setFooterHtml and setFooterBaseUrl to specify the content of the last page footer.
1874 Use setFooterHeight to specify the height of the special last page footer.
1875
1876 Parameters:
1877
1878 - $displayOnLastPage: Display special footer on the last page or not.
1879
1880 Returns:
1881
1882 - Reference to the current object.
1883 =cut
1884 0 ▶sub setFooterDisplayOnLastPage($) {
Subroutine setFooterDisplayOnLastPage: not called CC=1 SCAR=6.9
Pod documented
1885 0 my($self, $displayOnLastPage) = @_;
1886
1887 0 $self->{parameters}{"footer_display_on_last_page"} = $self->SUPER::serializeBoolean($displayOnLastPage);
1888 0 return $self;
1889 }
1890
1891 =head2 setFooterWebPageWidth( $footerWebPageWidth )
1892
1893 Set the width in pixels used by the converter's internal browser window during the conversion of the footer content. The default value is 1024px.
1894
1895 Parameters:
1896
1897 - $footerWebPageWidth: Browser window width in pixels.
1898
1899 Returns:
1900
1901 - Reference to the current object.
1902 =cut
1903 0 ▶sub setFooterWebPageWidth($) {
Subroutine setFooterWebPageWidth: not called CC=1 SCAR=6.9
Pod documented
1904 0 my($self, $footerWebPageWidth) = @_;
1905
1906 0 $self->{parameters}{"footer_web_page_width"} = $footerWebPageWidth;
1907 0 return $self;
1908 }
1909
1910 =head2 setFooterWebPageHeight( $footerWebPageHeight )
1911
1912 Set the height in pixels used by the converter's internal browser window during the conversion of the footer content.
1913 The default value is 0px and it means that the page height is automatically calculated by the converter.
1914
1915 Parameters:
1916
1917 - $footerWebPageHeight: Browser window height in pixels. Set it to 0px to automatically calculate page height.
1918
1919 Returns:
1920
1921 - Reference to the current object.
1922 =cut
1923 0 ▶sub setFooterWebPageHeight($) {
Subroutine setFooterWebPageHeight: not called CC=1 SCAR=6.9
Pod documented
1924 0 my($self, $footerWebPageHeight) = @_;
1925
1926 0 $self->{parameters}{"footer_web_page_height"} = $footerWebPageHeight;
1927 0 return $self;
1928 }
1929
1930
1931 =head2 setShowPageNumbers( $showPageNumbers )
1932
1933 Show page numbers. Default value is True. Page numbers will be displayed in the footer of the PDF document.
1934
1935 Parameters:
1936
1937 - $showPageNumbers: Show page numbers or not.
1938
1939 Returns:
1940
1941 - Reference to the current object.
1942 =cut
1943 0 ▶sub setShowPageNumbers($) {
Subroutine setShowPageNumbers: not called CC=1 SCAR=6.9
Pod documented
1944 0 my($self, $showPageNumbers) = @_;
1945
1946 0 $self->{parameters}{"page_numbers"} = $self->SUPER::serializeBoolean($showPageNumbers);
1947 0 return $self;
1948 }
1949
1950 =head2 setPageNumbersFirst( $firstPageNumber )
1951
1952 Control the page number for the first page being rendered. The default value is 1.
1953
1954 Parameters:
1955
1956 - $firstPageNumber: First page number.
1957
1958 Returns:
1959
1960 - Reference to the current object.
1961 =cut
1962 0 ▶sub setPageNumbersFirst($) {
Subroutine setPageNumbersFirst: not called CC=1 SCAR=6.9
Pod documented
1963 0 my($self, $firstPageNumber) = @_;
1964
1965 0 $self->{parameters}{"page_numbers_first"} = $firstPageNumber;
1966 0 return $self;
1967 }
1968
1969 =head2 setPageNumbersOffset( $totalPagesOffset )
1970
1971 Control the total number of pages offset in the generated pdf document. The default value is 0.
1972
1973 Parameters:
1974
1975 - $totalPagesOffset: Offset for the total number of pages in the generated pdf document.
1976
1977 Returns:
1978
1979 - Reference to the current object.
1980 =cut
1981 0 ▶sub setPageNumbersOffset($) {
Subroutine setPageNumbersOffset: not called CC=1 SCAR=6.9
Pod documented
1982 0 my($self, $totalPagesOffset) = @_;
1983
1984 0 $self->{parameters}{"page_numbers_offset"} = $totalPagesOffset;
1985 0 return $self;
1986 }
1987
1988 =head2 setPageNumbersTemplate( $template )
1989
1990 Set the text that is used to display the page numbers. It can contain the placeholder {page_number} for the current page number and {total_pages}
1991 for the total number of pages. The default value is "Page: {page_number} of {total_pages}".
1992
1993 Parameters:
1994
1995 - $template: Page numbers template.
1996
1997 Returns:
1998
1999 - Reference to the current object.
2000 =cut
2001 0 ▶sub setPageNumbersTemplate($) {
Subroutine setPageNumbersTemplate: not called CC=1 SCAR=6.9
Pod documented
2002 0 my($self, $template) = @_;
2003
2004 0 $self->{parameters}{"page_numbers_template"} = $template;
2005 0 return $self;
2006 }
2007
2008 =head2 setPageNumbersFontName( $fontName )
2009
2010 Set the font used to display the page numbers text. The default value is "Helvetica".
2011
2012 Parameters:
2013
2014 - $fontName: The font used to display the page numbers text.
2015
2016 Returns:
2017
2018 - Reference to the current object.
2019 =cut
2020 0 ▶sub setPageNumbersFontName($) {
Subroutine setPageNumbersFontName: not called CC=1 SCAR=6.9
Pod documented
2021 0 my($self, $fontName) = @_;
2022
2023 0 $self->{parameters}{"page_numbers_font_name"} = $fontName;
2024 0 return $self;
2025 }
2026
2027 =head2 setPageNumbersFontSize( $fontSize )
2028
2029 Set the size of the font used to display the page numbers. The default value is 10 points.
2030
2031 Parameters:
2032
2033 - $fontSize: The size in points of the font used to display the page numbers.
2034
2035 Returns:
2036
2037 - Reference to the current object.
2038 =cut
2039 0 ▶sub setPageNumbersFontSize($) {
Subroutine setPageNumbersFontSize: not called CC=1 SCAR=6.9
Pod documented
2040 0 my($self, $fontSize) = @_;
2041
2042 0 $self->{parameters}{"page_numbers_font_size"} = $fontSize;
2043 0 return $self;
2044 }
2045
2046 =head2 setPageNumbersAlignment( $alignment )
2047
2048 Set the alignment of the page numbers text. The default value is "2" - Right.
2049
2050 Parameters:
2051
2052 - $alignment: The alignment of the page numbers text. Possible values: 1 (Left), 2 (Center), 3 (Right).
2053
2054 Returns:
2055
2056 - Reference to the current object.
2057 =cut
2058 0 ▶sub setPageNumbersAlignment($) {
Subroutine setPageNumbersAlignment: not called CC=4 SCAR=30.0
Pod documented
2059 0 my($self, $alignment) = @_;
2060
2061 0 ▶ if ($alignment ne 1 and $alignment ne 2 and $alignment ne 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($alignment ne 1 and $alignment ne 2 and $alignment ne 3) 0 0 0
Condition0%0/6
$alignment ne 1 and $alignment ne 2 and $alignment ne 3
!ll&&!rl&&r
000
$alignment ne 1 and $alignment ne 2
!ll&&!rl&&r
000
MC/DC0%0/3
$alignment ne 1 and $alignment ne 2 and $alignment ne 3
$alignment ne 1 $alignment ne 2 $alignment ne 3
Truth table0%0/4
A and B and C
A= $alignment ne 1B= $alignment ne 2C= $alignment ne 3
ABCresult
0XX0
10X0
1100
1111
2062 0 die ("Allowed values for Page Numbers Alignment: 1 (Left), 2 (Center), 3 (Right).");
2063 }
2064
2065 0 $self->{parameters}{"page_numbers_alignment"} = $alignment;
2066 0 return $self;
2067 }
2068
2069 =head2 setPageNumbersColor( $color )
2070
2071 Specify the color of the page numbers text in #RRGGBB html format. The default value is #333333.
2072
2073 Parameters:
2074
2075 - $color: Page numbers color.
2076
2077 Returns:
2078
2079 - Reference to the current object.
2080 =cut
2081 0 ▶sub setPageNumbersColor($) {
Subroutine setPageNumbersColor: not called CC=2 SCAR=17.9
Pod documented
2082 0 my($self, $color) = @_;
2083
2084 0 ▶ if ($color !~ m/^#?[0-9a-fA-F]{6}$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($color =~ /^#?[0-9a-fA-F]{6}$/) 0 0 0
2085 0 die ("Color value must be in #RRGGBB format.");
2086 }
2087
2088 0 $self->{parameters}{"page_numbers_color"} = $color;
2089 0 return $self;
2090 }
2091
2092 =head2 setPageNumbersVerticalPosition( $position )
2093
2094 Specify the position in points on the vertical where the page numbers text is displayed in the footer. The default value is 10 points.
2095
2096 Parameters:
2097
2098 - $position: Page numbers Y position in points.
2099
2100 Returns:
2101
2102 - Reference to the current object.
2103 =cut
2104 0 ▶sub setPageNumbersVerticalPosition($) {
Subroutine setPageNumbersVerticalPosition: not called CC=1 SCAR=6.9
Pod documented
2105 0 my($self, $position) = @_;
2106
2107 0 $self->{parameters}{"page_numbers_pos_y"} = $position;
2108 0 return $self;
2109 }
2110
2111 =head2 setPdfBookmarksSelectors( $selectors )
2112
2113 Generate automatic bookmarks in pdf. The elements that will be bookmarked are defined using CSS selectors.
2114 For example, the selector for all the H1 elements is "H1", the selector for all the elements with the CSS class name 'myclass' is "*.myclass" and
2115 the selector for the elements with the id 'myid' is "*#myid".
2116 Read more about CSS selectors <a href="http://www.w3schools.com/cssref/css_selectors.asp" target="_blank">here</a>.
2117
2118 Parameters:
2119
2120 - $selectors: CSS selectors used to identify HTML elements, comma separated.
2121
2122 Returns:
2123
2124 - Reference to the current object.
2125 =cut
2126 0 ▶sub setPdfBookmarksSelectors($) {
Subroutine setPdfBookmarksSelectors: not called CC=1 SCAR=6.9
Pod documented
2127 0 my($self, $selectors) = @_;
2128
2129 0 $self->{parameters}{"pdf_bookmarks_selectors"} = $selectors;
2130 0 return $self;
2131 }
2132
2133 =head2 setPdfHideElements( $selectors )
2134
2135 Exclude page elements from the conversion. The elements that will be excluded are defined using CSS selectors.
2136 For example, the selector for all the H1 elements is "H1", the selector for all the elements with the CSS class name 'myclass' is "*.myclass" and
2137 the selector for the elements with the id 'myid' is "*#myid".
2138 Read more about CSS selectors <a href="http://www.w3schools.com/cssref/css_selectors.asp" target="_blank">here</a>.
2139
2140 Parameters:
2141
2142 - $selectors: CSS selectors used to identify HTML elements, comma separated.
2143
2144 Returns:
2145
2146 - Reference to the current object.
2147 =cut
2148 0 ▶sub setPdfHideElements($) {
Subroutine setPdfHideElements: not called CC=1 SCAR=6.9
Pod documented
2149 0 my($self, $selectors) = @_;
2150
2151 0 $self->{parameters}{"pdf_hide_elements"} = $selectors;
2152 0 return $self;
2153 }
2154
2155 =head2 setPdfShowOnlyElementID( $elementID )
2156
2157 Convert only a specific section of the web page to pdf. The section that will be converted to pdf is specified by the html element ID.
2158 The element can be anything (image, table, table row, div, text, etc).
2159
2160 Parameters:
2161
2162 - $elementID: HTML element ID.
2163
2164 Returns:
2165
2166 - Reference to the current object.
2167 =cut
2168 0 ▶sub setPdfShowOnlyElementID($) {
Subroutine setPdfShowOnlyElementID: not called CC=1 SCAR=6.9
Pod documented
2169 0 my($self, $elementID) = @_;
2170
2171 0 $self->{parameters}{"pdf_show_only_element_id"} = $elementID;
2172 0 return $self;
2173 }
2174
2175 =head2 setPdfWebElementsSelectors( $selectors )
2176
2177 Get the locations of page elements from the conversion. The elements that will have their locations retrieved are defined using CSS selectors.
2178 For example, the selector for all the H1 elements is "H1", the selector for all the elements with the CSS class name 'myclass' is "*.myclass" and
2179 the selector for the elements with the id 'myid' is "*#myid".
2180 Read more about CSS selectors <a href="http://www.w3schools.com/cssref/css_selectors.asp" target="_blank">here</a>.
2181
2182 Parameters:
2183
2184 - $selectors: CSS selectors used to identify HTML elements, comma separated.
2185
2186 Returns:
2187
2188 - Reference to the current object.
2189 =cut
2190 0 ▶sub setPdfWebElementsSelectors($) {
Subroutine setPdfWebElementsSelectors: not called CC=1 SCAR=6.9
Pod documented
2191 0 my($self, $selectors) = @_;
2192
2193 0 $self->{parameters}{"pdf_web_elements_selectors"} = $selectors;
2194 0 return $self;
2195 }
2196
2197 =head2 setStartupMode( $startupMode )
2198
2199 Set converter startup mode. The default value is Automatic and the conversion is started immediately.
2200 By default this is set to Automatic and the conversion is started as soon as the page loads (and conversion delay set with setConversionDelay elapses).
2201 If set to Manual, the conversion is started only by a javascript call to SelectPdf.startConversion() from within the web page.
2202
2203 Parameters:
2204
2205 - $startupMode: Converter startup mode. Possible values: Automatic, Manual.
2206
2207 Returns:
2208
2209 - Reference to the current object.
2210 =cut
2211 0 ▶sub setStartupMode($) {
Subroutine setStartupMode: not called CC=2 SCAR=17.9
Pod documented
2212 0 my($self, $startupMode) = @_;
2213
2214 0 ▶ if ($startupMode !~ m/^(Automatic|Manual)$/i) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($startupMode =~ /^(Automatic|Manual)$/i) 0 0 0
2215 0 die ("Allowed values for Startup Mode: Automatic, Manual.");
2216 }
2217
2218 0 $self->{parameters}{"startup_mode"} = $startupMode;
2219 0 return $self;
2220 }
2221
2222 =head2 setSkipDecoding( $skipDecoding )
2223
2224 Internal use only.
2225
2226 Parameters:
2227
2228 - $skipDecoding: The default value is True.
2229
2230 Returns:
2231
2232 - Reference to the current object.
2233 =cut
2234 0 ▶sub setSkipDecoding($) {
Subroutine setSkipDecoding: not called CC=1 SCAR=6.9
Pod documented
2235 0 my($self, $skipDecoding) = @_;
2236
2237 0 $self->{parameters}{"skip_decoding"} = $self->SUPER::serializeBoolean($skipDecoding);
2238 0 return $self;
2239 }
2240
2241 =head2 setScaleImages( $scaleImages )
2242
2243 Set a flag indicating if the images from the page are scaled during the conversion process. The default value is False and images are not scaled.
2244
2245 Parameters:
2246
2247 - $scaleImages: Scale images or not.
2248
2249 Returns:
2250
2251 - Reference to the current object.
2252 =cut
2253 0 ▶sub setScaleImages($) {
Subroutine setScaleImages: not called CC=1 SCAR=6.9
Pod documented
2254 0 my($self, $scaleImages) = @_;
2255
2256 0 $self->{parameters}{"scale_images"} = $self->SUPER::serializeBoolean($scaleImages);
2257 0 return $self;
2258 }
2259
2260 =head2 setSinglePagePdf( $generateSinglePagePdf )
2261
2262 Generate a single page PDF. The converter will automatically resize the PDF page to fit all the content in a single page.
2263 The default value of this property is False and the PDF will contain several pages if the content is large.
2264
2265 Parameters:
2266
2267 - $generateSinglePagePdf: Generate a single page PDF or not.
2268
2269 Returns:
2270
2271 - Reference to the current object.
2272 =cut
2273 0 ▶sub setSinglePagePdf($) {
Subroutine setSinglePagePdf: not called CC=1 SCAR=6.9
Pod documented
2274 0 my($self, $generateSinglePagePdf) = @_;
2275
2276 0 $self->{parameters}{"single_page_pdf"} = $self->SUPER::serializeBoolean($generateSinglePagePdf);
2277 0 return $self;
2278 }
2279
2280 =head2 setPageBreaksEnhancedAlgorithm( $enableEnhancedPageBreaksAlgorithm )
2281
2282 Get or set a flag indicating if an enhanced custom page breaks algorithm is used.
2283 The enhanced algorithm is a little bit slower but it will prevent the appearance of hidden text in the PDF when custom page breaks are used.
2284 The default value for this property is False.
2285
2286 Parameters:
2287
2288 - $enableEnhancedPageBreaksAlgorithm: Enable enhanced page breaks algorithm or not.
2289
2290 Returns:
2291
2292 - Reference to the current object.
2293 =cut
2294 0 ▶sub setPageBreaksEnhancedAlgorithm($) {
Subroutine setPageBreaksEnhancedAlgorithm: not called CC=1 SCAR=6.9
Pod documented
2295 0 my($self, $enableEnhancedPageBreaksAlgorithm) = @_;
2296
2297 0 $self->{parameters}{"page_breaks_enhanced_algorithm"} = $self->SUPER::serializeBoolean($enableEnhancedPageBreaksAlgorithm);
2298 0 return $self;
2299 }
2300
2301 =head2 setCookies( $cookies )
2302
2303 Set HTTP cookies for the web page being converted.
2304
2305 Parameters:
2306
2307 - $cookies: Dictionary with HTTP cookies that will be sent to the page being converted.
2308
2309 Returns:
2310
2311 - Reference to the current object.
2312 =cut
2313 0 ▶sub setCookies($) {
Subroutine setCookies: not called CC=1 SCAR=6.9
Pod documented
2314 0 my($self, $cookies) = @_;
2315
2316 0 my $url = URI->new('', 'http');
2317 0 $url->query_form(%$cookies);
2318 0 my $cookiesString = $url->query;
2319
2320 0 $self->{parameters}{"cookies_string"} = $cookiesString;
2321 0 return $self;
2322 }
2323
2324 =head2 setAuthUsername( $authUsername )
2325
2326 Set the user name for HTTP Basic authentication on the web page being converted.
2327
2328 Use it together with setAuthPassword. The demo endpoint does not send credentials; it reports the value in getDroppedFields.
2329
2330 Parameters:
2331
2332 - $authUsername: User name for HTTP Basic authentication.
2333
2334 Returns:
2335
2336 - Reference to the current object.
2337 =cut
2338 1 ▶sub setAuthUsername($) {
Subroutine setAuthUsername: called CC=1 SCAR=0.0
Pod documented
2339 1 my($self, $authUsername) = @_;
2340
2341 1 $self->{parameters}{"auth_username"} = $authUsername;
2342 1 return $self;
2343 }
2344
2345 =head2 setAuthPassword( $authPassword )
2346
2347 Set the password for HTTP Basic authentication on the web page being converted.
2348
2349 Use it together with setAuthUsername. The demo endpoint does not send credentials; it reports the value in getDroppedFields.
2350
2351 Parameters:
2352
2353 - $authPassword: Password for HTTP Basic authentication.
2354
2355 Returns:
2356
2357 - Reference to the current object.
2358 =cut
2359 1 ▶sub setAuthPassword($) {
Subroutine setAuthPassword: called CC=1 SCAR=0.0
Pod documented
2360 1 my($self, $authPassword) = @_;
2361
2362 1 $self->{parameters}{"auth_password"} = $authPassword;
2363 1 return $self;
2364 }
2365
2366 =head2 setCustomParameter( $parameterName, $parameterValue )
2367
2368 Set a custom parameter. Do not use this method unless advised by SelectPdf.
2369
2370 Parameters:
2371
2372 - $parameterName: Parameter name.
2373
2374 - $parameterValue: Parameter value.
2375
2376 Returns:
2377
2378 - Reference to the current object.
2379 =cut
2380 0 ▶sub setCustomParameter($$) {
Subroutine setCustomParameter: not called CC=1 SCAR=6.9
Pod documented
2381 0 my($self, $parameterName, $parameterValue) = @_;
2382
2383 0 $self->{parameters}{$parameterName} = $parameterValue;
2384 0 return $self;
2385 }
2386
2387 =head2 getWebElements
2388
2389 Get the locations of certain web elements. This is retrieved if pdf_web_elements_selectors parameter is set and elements were found to match the selectors.
2390
2391 Returns:
2392
2393 - Json with web elements locations.
2394 =cut
2395 0 ▶sub getWebElements {
Subroutine getWebElements: not called CC=2 SCAR=17.9
Pod documented
2396 0 my($self) = @_;
2397 0 ▶ die SelectPdf::DemoUnsupportedException->newLocal("pdf_web_elements_selectors") if ($self->{isDemoMode});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"isDemoMode"} 0 0 0
2398
2399 0 my $webElementsClient = SelectPdf::WebElementsClient->new($self->{parameters}{"key"}, $self->{jobId});
2400 0 $webElementsClient->setApiEndpoint($self->{apiWebElementsEndpoint});
2401
2402 0 return $webElementsClient->getWebElements();
2403 }
2404
2405
2406
2407 1 1;
« SelectPdf/PdfMergeClient.pm ↑ Summary SelectPdf/DemoExceptions.pm »