SelectPdf/HtmlToPdfClient.pm

filter: Statementstmt 3.8% 14 / 367 Branchbran 0.0% 0 / 40 Conditioncond 0.0% 0 / 36 MC/DCmcdc 0.0% 0 / 16 Subroutinesub 4.0% 4 / 100 Podpod 98.9% 95 / 96 totaltotal 17.2% 113 / 655 SCAR 69.3
CC
33
Cov
3%
setViewerPageMode
56.0
setViewerPageLayout
30.0
convertUrlAsync
20.0
CRAP 1022.0
↑ Summary SelectPdf/ApiClient.pm »
1 package SelectPdf::HtmlToPdfClient;
2
3 1 ▶use SelectPdf::ApiClient;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use SelectPdf::AsyncJobClient;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use SelectPdf::WebElementsClient;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 our @ISA = qw(SelectPdf::ApiClient);
8
9 =head1 NAME
10
11 SelectPdf::HtmlToPdfClient - Html To Pdf Conversion with SelectPdf Online API.
12
13 =head1 SYNOPSIS
14
15 use SelectPdf;
16 print "This is SelectPdf-$SelectPdf::VERSION\n";
17
18 my $url = "https://selectpdf.com/";
19 my $local_file = "Test.pdf";
20 my $apiKey = "Your API key here";
21
22 eval {
23 my $client = new HtmlToPdfClient($apiKey);
24
25 $client
26 ->setPageSize("A4")
27 ->setMargins(0)
28 ->setShowPageNumbers('False')
29 ->setPageBreaksEnhancedAlgorithm('True')
30 ;
31
32 $client->convertUrlToFile($url, $local_file);
33 };
34
35 if ($@) {
36 print "An error occurred: $@\n";
37 }
38
39 =head1 METHODS
40
41 =head2 new( $apiKey )
42
43 Construct the Html To Pdf Client.
44
45 my $client = SelectPdf::HtmlToPdfClient->new($apiKey);
46
47 Parameters:
48
49 - $apiKey API Key.
50 =cut
51 sub new {
52 0 ▶ my $type = shift;
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
53 0 my $self = $type->SUPER::new;
54
55 # API endpoint
56 0 $self->{apiEndpoint} = "https://selectpdf.com/api2/convert/";
57
58 0 $self->{parameters}{"key"} = shift;
59
60 0 bless $self, $type;
61 0 return $self;
62 }
63
64 =head2 convertUrl( $url )
65
66 Convert the specified url to PDF.
67 SelectPdf online API can convert http:// and https:// publicly available urls.
68
69 $content = $client->convertUrl($url);
70
71 Parameters:
72
73 - $url Address of the web page being converted.
74
75 Returns:
76
77 - Byte array containing the resulted PDF.
78 =cut
79 sub convertUrl($) {
80 0 ▶ my($self, $url) = @_;
Subroutine convertUrl: not called CC=1 SCAR=6.9
Pod documented
81
82 0 $self->{parameters}{"url"} = $url;
83 0 $self->{parameters}{"async"} = "False";
84 0 $self->{parameters}{"html"} = "";
85 0 $self->{parameters}{"base_url"} = "";
86
87 0 return $self->SUPER::performPost();
88 }
89
90 =head2 convertUrl( $url, $filePath )
91
92 Convert the specified url to PDF and writes the resulted PDF to a local file.
93 SelectPdf online API can convert http:// and https:// publicly available urls.
94
95 $client->convertUrlToFile($url, $filePath);
96
97 Parameters:
98
99 - $url Address of the web page being converted.
100
101 - $filePath Local file including path if necessary.
102 =cut
103 sub convertUrlToFile($;$) {
104 0 ▶ my($self, $url, $filePath) = @_;
Subroutine convertUrlToFile: not called CC=2 SCAR=17.9
Pod undocumented
105
106 0 my $content = $self->convertUrl($url);
107
108 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
109 0 $file->binmode;
110 0 $file->print( $content );
111 0 $file->close;
112 }
113
114 =head2 convertUrlAsync( $url )
115
116 Convert the specified url to PDF using an asynchronous call.
117 SelectPdf online API can convert http:// and https:// publicly available urls.
118
119 $content = $client->convertUrlAsync($url);
120
121 Parameters:
122
123 - $url Address of the web page being converted.
124
125 Returns:
126
127 - Byte array containing the resulted PDF.
128 =cut
129 sub convertUrlAsync($) {
130 0 ▶ my($self, $url) = @_;
Subroutine convertUrlAsync: not called CC=4 SCAR=30.0
Pod documented
131
132 0 $self->{parameters}{"url"} = $url;
133 0 $self->{parameters}{"html"} = "";
134 0 $self->{parameters}{"base_url"} = "";
135
136 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
137
138 0 my $noPings = 0;
139
140 do
141 {
142 0 $noPings++;
143
144 # sleep for a few seconds before next ping
145 0 sleep($self->{AsyncCallsPingInterval});
146
147 0 my $asyncJobClient = new SelectPdf::AsyncJobClient($self->{parameters}{"key"}, $JobID);
148 0 $asyncJobClient->setApiEndpoint($self->{apiAsyncEndpoint});
149
150 0 my $result = $asyncJobClient->getResult();
151
152 0 ▶ if ($asyncJobClient->finished)
Branch: 1 branch
BranchTrueFalseTotal
if ($asyncJobClient->finished) 0 0 0
153 {
154 0 $self->{numberOfPages} = $asyncJobClient->getNumberOfPages();
155
156 0 return $result;
157 }
158
159 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
160
161 0 die "Asynchronous call did not finish in expected timeframe.";
162
163 }
164
165 =head2 convertUrlToFileAsync( $url, $filePath )
166
167 Convert the specified url to PDF using an asynchronous call and writes the resulted PDF to a local file.
168 SelectPdf online API can convert http:// and https:// publicly available urls.
169
170 $client->convertUrlToFileAsync($url, $filePath);
171
172 Parameters:
173
174 - $url Address of the web page being converted.
175
176 - $filePath Local file including path if necessary.
177 =cut
178 sub convertUrlToFileAsync($;$) {
179 0 ▶ my($self, $url, $filePath) = @_;
Subroutine convertUrlToFileAsync: not called CC=2 SCAR=17.9
Pod documented
180
181 0 my $content = $self->convertUrlAsync($url);
182
183 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
184 0 $file->binmode;
185 0 $file->print( $content );
186 0 $file->close;
187 }
188
189 =head2 convertHtmlStringWithBaseUrl( $htmlString, $baseUrl )
190
191 Convert the specified HTML string to PDF. Use a base url to resolve relative paths to resources.
192
193 $content = $client->convertHtmlStringWithBaseUrl($htmlString, $baseUrl);
194
195 Parameters:
196
197 - $htmlString HTML string with the content being converted.
198
199 - $baseUrl Base url used to resolve relative paths to resources (css, images, javascript, etc). Must be a http:// or https:// publicly available url.
200
201 Returns:
202
203 - Byte array containing the resulted PDF.
204 =cut
205 sub convertHtmlStringWithBaseUrl($,$) {
206 0 ▶ my($self, $htmlString, $baseUrl) = @_;
Subroutine convertHtmlStringWithBaseUrl: not called CC=1 SCAR=6.9
Pod documented
207
208 0 $self->{parameters}{"url"} = "";
209 0 $self->{parameters}{"async"} = "False";
210 0 $self->{parameters}{"html"} = $htmlString;
211 0 $self->{parameters}{"base_url"} = $baseUrl;
212
213 0 return $self->SUPER::performPost();
214 }
215
216 =head2 convertHtmlStringWithBaseUrlToFile( $htmlString, $baseUrl, $filePath )
217
218 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.
219
220 $client->convertHtmlStringWithBaseUrlToFile($htmlString, $baseUrl, $filePath);
221
222 Parameters:
223
224 - $htmlString HTML string with the content being converted.
225
226 - $baseUrl Base url used to resolve relative paths to resources (css, images, javascript, etc). Must be a http:// or https:// publicly available url.
227
228 - $filePath: Local file including path if necessary.
229
230 =cut
231 sub convertHtmlStringWithBaseUrlToFile($,$,$) {
232 0 ▶ my($self, $htmlString, $baseUrl, $filePath) = @_;
Subroutine convertHtmlStringWithBaseUrlToFile: not called CC=2 SCAR=17.9
Pod documented
233
234 0 my $content = $self->convertHtmlStringWithBaseUrl($htmlString, $baseUrl);
235
236 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
237 0 $file->binmode;
238 0 $file->print( $content );
239 0 $file->close;
240 }
241
242 =head2 convertHtmlStringWithBaseUrlAsync( $htmlString, $baseUrl )
243
244 Convert the specified HTML string to PDF with an asynchronous call. Use a base url to resolve relative paths to resources.
245
246 $content = $client->convertHtmlStringWithBaseUrlAsync($htmlString, $baseUrl);
247
248 Parameters:
249
250 - $htmlString HTML string with the content being converted.
251
252 - $baseUrl Base url used to resolve relative paths to resources (css, images, javascript, etc). Must be a http:// or https:// publicly available url.
253
254 Returns:
255
256 - Byte array containing the resulted PDF.
257 =cut
258 sub convertHtmlStringWithBaseUrlAsync($,$) {
259 0 ▶ my($self, $htmlString, $baseUrl) = @_;
Subroutine convertHtmlStringWithBaseUrlAsync: not called CC=4 SCAR=30.0
Pod documented
260
261 0 $self->{parameters}{"url"} = "";
262 0 $self->{parameters}{"async"} = "False";
263 0 $self->{parameters}{"html"} = $htmlString;
264 0 $self->{parameters}{"base_url"} = $baseUrl;
265
266 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
267
268 0 my $noPings = 0;
269
270 do
271 {
272 0 $noPings++;
273
274 # sleep for a few seconds before next ping
275 0 sleep($self->{AsyncCallsPingInterval});
276
277 0 my $asyncJobClient = new SelectPdf::AsyncJobClient($self->{parameters}{"key"}, $JobID);
278 0 $asyncJobClient->setApiEndpoint($self->{apiAsyncEndpoint});
279
280 0 my $result = $asyncJobClient->getResult();
281
282 0 ▶ if ($asyncJobClient->finished)
Branch: 1 branch
BranchTrueFalseTotal
if ($asyncJobClient->finished) 0 0 0
283 {
284 0 $self->{numberOfPages} = $asyncJobClient->getNumberOfPages();
285
286 0 return $result;
287 }
288
289 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
290
291 0 die "Asynchronous call did not finish in expected timeframe.";
292
293 }
294
295 =head2 convertHtmlStringWithBaseUrlToFileAsync( $htmlString, $baseUrl, $filePath )
296
297 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.
298
299 $client->convertHtmlStringWithBaseUrlToFileAsync($htmlString, $baseUrl, $filePath);
300
301 Parameters:
302
303 - $htmlString HTML string with the content being converted.
304
305 - $baseUrl Base url used to resolve relative paths to resources (css, images, javascript, etc). Must be a http:// or https:// publicly available url.
306
307 - $filePath: Local file including path if necessary.
308
309 =cut
310 sub convertHtmlStringWithBaseUrlToFileAsync($,$,$) {
311 0 ▶ my($self, $htmlString, $baseUrl, $filePath) = @_;
Subroutine convertHtmlStringWithBaseUrlToFileAsync: not called CC=2 SCAR=17.9
Pod documented
312
313 0 my $content = $self->convertHtmlStringWithBaseUrlAsync($htmlString, $baseUrl);
314
315 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
316 0 $file->binmode;
317 0 $file->print( $content );
318 0 $file->close;
319 }
320
321 =head2 convertHtmlString( $htmlString )
322
323 Convert the specified HTML string to PDF.
324
325 $content = $client->convertHtmlString($htmlString);
326
327 Parameters:
328
329 - $htmlString HTML string with the content being converted.
330
331 Returns:
332
333 - Byte array containing the resulted PDF.
334 =cut
335 sub convertHtmlString($) {
336 0 ▶ my($self, $htmlString) = @_;
Subroutine convertHtmlString: not called CC=1 SCAR=6.9
Pod documented
337
338 0 return $self->convertHtmlStringWithBaseUrl($htmlString, "");
339 }
340
341 =head2 convertHtmlStringToFile( $htmlString, $filePath )
342
343 Convert the specified HTML string to PDF and writes the resulted PDF to a local file.
344
345 $client->convertHtmlStringToFile($htmlString, $filePath);
346
347 Parameters:
348
349 - $htmlString HTML string with the content being converted.
350
351 - $filePath: Local file including path if necessary.
352
353 =cut
354 sub convertHtmlStringToFile($,$) {
355 0 ▶ my($self, $htmlString, $filePath) = @_;
Subroutine convertHtmlStringToFile: not called CC=1 SCAR=6.9
Pod documented
356
357 0 $self->convertHtmlStringWithBaseUrlToFile($htmlString, "", $filePath);
358 }
359
360 =head2 convertHtmlStringAsync( $htmlString )
361
362 Convert the specified HTML string to PDF with an asynchronous call.
363
364 $content = $client->convertHtmlStringAsync($htmlString);
365
366 Parameters:
367
368 - $htmlString HTML string with the content being converted.
369
370 Returns:
371
372 - Byte array containing the resulted PDF.
373 =cut
374 sub convertHtmlStringAsync($) {
375 0 ▶ my($self, $htmlString) = @_;
Subroutine convertHtmlStringAsync: not called CC=1 SCAR=6.9
Pod documented
376
377 0 return $self->convertHtmlStringWithBaseUrlAsync($htmlString, "");
378 }
379
380 =head2 convertHtmlStringToFileAsync( $htmlString, $filePath )
381
382 Convert the specified HTML string to PDF with an asynchronous call and writes the resulted PDF to a local file.
383
384 $client->convertHtmlStringToFileAsync($htmlString, $filePath);
385
386 Parameters:
387
388 - $htmlString HTML string with the content being converted.
389
390 - $filePath: Local file including path if necessary.
391
392 =cut
393 sub convertHtmlStringToFileAsync($,$) {
394 0 ▶ my($self, $htmlString, $filePath) = @_;
Subroutine convertHtmlStringToFileAsync: not called CC=1 SCAR=6.9
Pod documented
395
396 0 $self->convertHtmlStringWithBaseUrlToFileAsync($htmlString, "", $filePath);
397 }
398
399 =head2 setPageSize( $pageSize )
400
401 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.
402
403 Parameters:
404
405 - $pageSize: PDF page size. Possible values: Custom, A0, A1, A2, A3, A4, A5, A6, A7, A8, Letter, HalfLetter, Ledger, Legal.
406
407 Returns:
408
409 - Reference to the current object.
410 =cut
411 sub setPageSize($) {
412 0 ▶ my($self, $pageSize) = @_;
Subroutine setPageSize: not called CC=2 SCAR=17.9
Pod documented
413
414 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
415 0 die ("Allowed values for Page Size: Custom, A0, A1, A2, A3, A4, A5, A6, A7, A8, Letter, HalfLetter, Ledger, Legal.");
416 }
417
418 0 $self->{parameters}{"page_size"} = $pageSize;
419 0 return $self;
420 }
421
422 =head2 setPageWidth( $pageWidth )
423
424 Set PDF page width in points. Default value is 595pt (A4 page width in points). 1pt = 1/72 inch.
425 This is taken into account only if page size is set to Custom using setPageSize method.
426
427 Parameters:
428
429 - $pageWidth: Page width in points.
430
431 Returns:
432
433 - Reference to the current object.
434 =cut
435 sub setPageWidth($) {
436 0 ▶ my($self, $pageWidth) = @_;
Subroutine setPageWidth: not called CC=1 SCAR=6.9
Pod documented
437
438 0 $self->{parameters}{"page_width"} = $pageWidth;
439 0 return $self;
440 }
441
442 =head2 setPageHeight( $pageHeight )
443
444 Set PDF page height in points. Default value is 842pt (A4 page height in points). 1pt = 1/72 inch.
445 This is taken into account only if page size is set to Custom using setPageSize method.
446
447 Parameters:
448
449 - $pageHeight: Page height in points.
450
451 Returns:
452
453 - Reference to the current object.
454 =cut
455 sub setPageHeight($) {
456 0 ▶ my($self, $pageHeight) = @_;
Subroutine setPageHeight: not called CC=1 SCAR=6.9
Pod documented
457
458 0 $self->{parameters}{"page_height"} = $pageHeight;
459 0 return $self;
460 }
461
462 =head2 setPageOrientation( $pageOrientation )
463
464 Set PDF page orientation. Default value is Portrait.
465
466 Parameters:
467
468 - $pageOrientation: PDF page orientation. Possible values: Portrait, Landscape.
469
470 Returns:
471
472 - Reference to the current object.
473 =cut
474 sub setPageOrientation($) {
475 0 ▶ my($self, $pageOrientation) = @_;
Subroutine setPageOrientation: not called CC=2 SCAR=17.9
Pod documented
476
477 0 ▶ if ($pageOrientation !~ m/^(Portrait|Landscape)$/i) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pageOrientation =~ /^(Portrait|Landscape)$/i) 0 0 0
478 0 die ("Allowed values for Page Orientation: Portrait, Landscape.");
479 }
480
481 0 $self->{parameters}{"page_orientation"} = $pageOrientation;
482 0 return $self;
483 }
484
485 =head2 setMarginTop( $marginTop )
486
487 Set top margin of the PDF pages. Default value is 5pt.
488
489 Parameters:
490
491 - $marginTop: Margin value in points. 1pt = 1/72 inch.
492
493 Returns:
494
495 - Reference to the current object.
496 =cut
497 sub setMarginTop($) {
498 0 ▶ my($self, $marginTop) = @_;
Subroutine setMarginTop: not called CC=1 SCAR=6.9
Pod documented
499
500 0 $self->{parameters}{"margin_top"} = $marginTop;
501 0 return $self;
502 }
503
504 =head2 setMarginRight( $marginRight )
505
506 Set right margin of the PDF pages. Default value is 5pt.
507
508 Parameters:
509
510 - $marginRight: Margin value in points. 1pt = 1/72 inch.
511
512 Returns:
513
514 - Reference to the current object.
515 =cut
516 sub setMarginRight($) {
517 0 ▶ my($self, $marginRight) = @_;
Subroutine setMarginRight: not called CC=1 SCAR=6.9
Pod documented
518
519 0 $self->{parameters}{"margin_right"} = $marginRight;
520 0 return $self;
521 }
522
523 =head2 setMarginBottom( $marginBottom )
524
525 Set bottom margin of the PDF pages. Default value is 5pt.
526
527 Parameters:
528
529 - $marginBottom: Margin value in points. 1pt = 1/72 inch.
530
531 Returns:
532
533 - Reference to the current object.
534 =cut
535 sub setMarginBottom($) {
536 0 ▶ my($self, $marginBottom) = @_;
Subroutine setMarginBottom: not called CC=1 SCAR=6.9
Pod documented
537
538 0 $self->{parameters}{"margin_bottom"} = $marginBottom;
539 0 return $self;
540 }
541
542 =head2 setMarginLeft( $marginLeft )
543
544 Set left margin of the PDF pages. Default value is 5pt.
545
546 Parameters:
547
548 - $marginLeft: Margin value in points. 1pt = 1/72 inch.
549
550 Returns:
551
552 - Reference to the current object.
553 =cut
554 sub setMarginLeft($) {
555 0 ▶ my($self, $marginLeft) = @_;
Subroutine setMarginLeft: not called CC=1 SCAR=6.9
Pod documented
556
557 0 $self->{parameters}{"margin_left"} = $marginLeft;
558 0 return $self;
559 }
560
561 =head2 setMargins( $margin )
562
563 Set all margins of the PDF pages to the same value. Default value is 5pt.
564
565 Parameters:
566
567 - $margin: Margin value in points. 1pt = 1/72 inch.
568
569 Returns:
570
571 - Reference to the current object.
572 =cut
573 sub setMargins($) {
574 0 ▶ my($self, $margin) = @_;
Subroutine setMargins: not called CC=1 SCAR=6.9
Pod documented
575
576 0 return $self->setMarginTop($margin)->setMarginRight($margin)->setMarginBottom($margin)->setMarginLeft($margin);
577 }
578
579 =head2 setPdfName( $pdfName )
580
581 Specify the name of the pdf document that will be created. The default value is Document.pdf.
582
583 Parameters:
584
585 - $pdfName: Name of the generated PDF document.
586
587 Returns:
588
589 - Reference to the current object.
590 =cut
591 sub setPdfName($) {
592 0 ▶ my($self, $pdfName) = @_;
Subroutine setPdfName: not called CC=1 SCAR=6.9
Pod documented
593
594 0 $self->{parameters}{"pdf_name"} = $pdfName;
595 0 return $self;
596 }
597
598 =head2 setRenderingEngine( $renderingEngine )
599
600 Set the rendering engine used for the HTML to PDF conversion. Default value is WebKit.
601
602 Parameters:
603
604 - $renderingEngine: HTML rendering engine. Possible values: WebKit, Restricted, Blink.
605
606 Returns:
607
608 - Reference to the current object.
609 =cut
610 sub setRenderingEngine($) {
611 0 ▶ my($self, $renderingEngine) = @_;
Subroutine setRenderingEngine: not called CC=2 SCAR=17.9
Pod documented
612
613 0 ▶ if ($renderingEngine !~ m/^(WebKit|Restricted|Blink)$/i) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($renderingEngine =~ /^(WebKit|Restricted|Blink)$/i) 0 0 0
614 0 die ("Allowed values for Rendering Engine: WebKit, Restricted, Blink.");
615 }
616
617 0 $self->{parameters}{"engine"} = $renderingEngine;
618 0 return $self;
619 }
620
621 =head2 setUserPassword( $userPassword )
622
623 Set PDF user password.
624
625 Parameters:
626
627 - $userPassword: PDF user password.
628
629 Returns:
630
631 - Reference to the current object.
632 =cut
633 sub setUserPassword($) {
634 0 ▶ my($self, $userPassword) = @_;
Subroutine setUserPassword: not called CC=1 SCAR=6.9
Pod documented
635
636 0 $self->{parameters}{"user_password"} = $userPassword;
637 0 return $self;
638 }
639
640 =head2 setOwnerPassword( $ownerPassword )
641
642 Set PDF owner password.
643
644 Parameters:
645
646 - $ownerPassword: PDF owner password.
647
648 Returns:
649
650 - Reference to the current object.
651 =cut
652 sub setOwnerPassword($) {
653 0 ▶ my($self, $ownerPassword) = @_;
Subroutine setOwnerPassword: not called CC=1 SCAR=6.9
Pod documented
654
655 0 $self->{parameters}{"owner_password"} = $ownerPassword;
656 0 return $self;
657 }
658
659 =head2 setWebPageWidth( $webPageWidth )
660
661 Set the width used by the converter's internal browser window in pixels. The default value is 1024px.
662
663 Parameters:
664
665 - $webPageWidth: Browser window width in pixels.
666
667 Returns:
668
669 - Reference to the current object.
670 =cut
671 sub setWebPageWidth($) {
672 0 ▶ my($self, $webPageWidth) = @_;
Subroutine setWebPageWidth: not called CC=1 SCAR=6.9
Pod documented
673
674 0 $self->{parameters}{"web_page_width"} = $webPageWidth;
675 0 return $self;
676 }
677
678 =head2 setWebPageHeight( $webPageHeight )
679
680 Set the height used by the converter's internal browser window in pixels.
681 The default value is 0px and it means that the page height is automatically calculated by the converter.
682
683 Parameters:
684
685 - $webPageHeight: Browser window height in pixels. Set it to 0px to automatically calculate page height.
686
687 Returns:
688
689 - Reference to the current object.
690 =cut
691 sub setWebPageHeight($) {
692 0 ▶ my($self, $webPageHeight) = @_;
Subroutine setWebPageHeight: not called CC=1 SCAR=6.9
Pod documented
693
694 0 $self->{parameters}{"web_page_height"} = $webPageHeight;
695 0 return $self;
696 }
697
698 =head2 setMinLoadTime( $minLoadTime )
699
700 Introduce a delay (in seconds) before the actual conversion to allow the web page to fully load. This method is an alias for setConversionDelay.
701 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.
702
703 Parameters:
704
705 - $minLoadTime: Delay in seconds.
706
707 Returns:
708
709 - Reference to the current object.
710 =cut
711 sub setMinLoadTime($) {
712 0 ▶ my($self, $minLoadTime) = @_;
Subroutine setMinLoadTime: not called CC=1 SCAR=6.9
Pod documented
713
714 0 $self->{parameters}{"min_load_time"} = $minLoadTime;
715 0 return $self;
716 }
717
718 =head2 setConversionDelay( $delay )
719
720 Introduce a delay (in seconds) before the actual conversion to allow the web page to fully load. This method is an alias for setMinLoadTime.
721 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.
722
723 Parameters:
724
725 - $delay: Delay in seconds.
726
727 Returns:
728
729 - Reference to the current object.
730 =cut
731 sub setConversionDelay($) {
732 0 ▶ my($self, $delay) = @_;
Subroutine setConversionDelay: not called CC=1 SCAR=6.9
Pod documented
733
734 0 return $self->setMinLoadTime($delay);
735 }
736
737 =head2 setMaxLoadTime( $maxLoadTime )
738
739 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.
740 A timeout error is displayed when this time elapses. The default value is 30 seconds.
741 Use a larger value (up to 120 seconds allowed) for pages that take a long time to load.
742
743 Parameters:
744
745 - $maxLoadTime: Timeout in seconds.
746
747 Returns:
748
749 - Reference to the current object.
750 =cut
751 sub setMaxLoadTime($) {
752 0 ▶ my($self, $maxLoadTime) = @_;
Subroutine setMaxLoadTime: not called CC=1 SCAR=6.9
Pod documented
753
754 0 $self->{parameters}{"max_load_time"} = $maxLoadTime;
755 0 return $self;
756 }
757
758 =head2 setNavigationTimeout( $timeout )
759
760 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.
761 A timeout error is displayed when this time elapses. The default value is 30 seconds.
762 Use a larger value (up to 120 seconds allowed) for pages that take a long time to load.
763
764 Parameters:
765
766 - $timeout: Timeout in seconds.
767
768 Returns:
769
770 - Reference to the current object.
771 =cut
772 sub setNavigationTimeout($) {
773 0 ▶ my($self, $timeout) = @_;
Subroutine setNavigationTimeout: not called CC=1 SCAR=6.9
Pod documented
774
775 0 return $self->setMaxLoadTime($timeout);
776 }
777
778 =head2 setSecureProtocol( $secureProtocol )
779
780 Set the protocol used for secure (HTTPS) connections. Set this only if you have an older server that only works with older SSL connections.
781
782 Parameters:
783
784 - $secureProtocol: Secure protocol. Possible values: 0 (TLS 1.1 or newer), 1 (TLS 1.0), 2 (SSL v3 only).
785
786 Returns:
787
788 - Reference to the current object.
789 =cut
790 sub setSecureProtocol($) {
791 0 ▶ my($self, $secureProtocol) = @_;
Subroutine setSecureProtocol: not called CC=4 SCAR=30.0
Pod documented
792
793 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
794 0 die ("Allowed values for Secure Protocol: 0 (TLS 1.1 or newer), 1 (TLS 1.0), 2 (SSL v3 only).");
795 }
796
797 0 $self->{parameters}{"protocol"} = $secureProtocol;
798 0 return $self;
799 }
800
801 =head2 setUseCssPrint( $useCssPrint )
802
803 Specify if the CSS Print media type is used instead of the Screen media type. The default value is False.
804
805 Parameters:
806
807 - $useCssPrint: Use CSS Print media or not.
808
809 Returns:
810
811 - Reference to the current object.
812 =cut
813 sub setUseCssPrint($) {
814 0 ▶ my($self, $useCssPrint) = @_;
Subroutine setUseCssPrint: not called CC=1 SCAR=6.9
Pod documented
815
816 0 $self->{parameters}{"use_css_print"} = $self->SUPER::serializeBoolean($useCssPrint);
817 0 return $self;
818 }
819
820 =head2 setBackgroundColor( $backgroundColor )
821
822 Specify the background color of the PDF page in RGB html format. The default is #FFFFFF.
823
824 Parameters:
825
826 - $backgroundColor: Background color in #RRGGBB format.
827
828 Returns:
829
830 - Reference to the current object.
831 =cut
832 sub setBackgroundColor($) {
833 0 ▶ my($self, $backgroundColor) = @_;
Subroutine setBackgroundColor: not called CC=2 SCAR=17.9
Pod documented
834
835 0 ▶ if ($backgroundColor !~ m/^#?[0-9a-fA-F]{6}$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($backgroundColor =~ /^#?[0-9a-fA-F]{6}$/) 0 0 0
836 0 die ("Color value must be in #RRGGBB format.");
837 }
838
839 0 $self->{parameters}{"background_color"} = $backgroundColor;
840 0 return $self;
841 }
842
843 =head2 setDrawHtmlBackground( $drawHtmlBackground )
844
845 Set a flag indicating if the web page background is rendered in PDF. The default value is True.
846
847 Parameters:
848
849 - $drawHtmlBackground: Draw the HTML background or not.
850
851 Returns:
852
853 - Reference to the current object.
854 =cut
855 sub setDrawHtmlBackground($) {
856 0 ▶ my($self, $drawHtmlBackground) = @_;
Subroutine setDrawHtmlBackground: not called CC=1 SCAR=6.9
Pod documented
857
858 0 $self->{parameters}{"draw_html_background"} = $self->SUPER::serializeBoolean($drawHtmlBackground);
859 0 return $self;
860 }
861
862 =head2 setDisableJavascript( $disableJavascript )
863
864 Do not run JavaScript in web pages. The default value is False and javascript is executed.
865
866 Parameters:
867
868 - $disableJavascript: Disable javascript or not.
869
870 Returns:
871
872 - Reference to the current object.
873 =cut
874 sub setDisableJavascript($) {
875 0 ▶ my($self, $disableJavascript) = @_;
Subroutine setDisableJavascript: not called CC=1 SCAR=6.9
Pod documented
876
877 0 $self->{parameters}{"disable_javascript"} = $self->SUPER::serializeBoolean($disableJavascript);
878 0 return $self;
879 }
880
881 =head2 setDisableInternalLinks( $disableInternalLinks )
882
883 Do not create internal links in the PDF. The default value is False and internal links are created.
884
885 Parameters:
886
887 - $disableInternalLinks: Disable internal links or not.
888
889 Returns:
890
891 - Reference to the current object.
892 =cut
893 sub setDisableInternalLinks($) {
894 0 ▶ my($self, $disableInternalLinks) = @_;
Subroutine setDisableInternalLinks: not called CC=1 SCAR=6.9
Pod documented
895
896 0 $self->{parameters}{"disable_internal_links"} = $self->SUPER::serializeBoolean($disableInternalLinks);
897 0 return $self;
898 }
899
900 =head2 setDisableExternalLinks( $disableExternalLinks )
901
902 Do not create external links in the PDF. The default value is False and external links are created.
903
904 Parameters:
905
906 - $disableExternalLinks: Disable external links or not.
907
908 Returns:
909
910 - Reference to the current object.
911 =cut
912 sub setDisableExternalLinks($) {
913 0 ▶ my($self, $disableExternalLinks) = @_;
Subroutine setDisableExternalLinks: not called CC=1 SCAR=6.9
Pod documented
914
915 0 $self->{parameters}{"disable_external_links"} = $self->SUPER::serializeBoolean($disableExternalLinks);
916 0 return $self;
917 }
918
919 =head2 setRenderOnTimeout( $renderOnTimeout )
920
921 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.
922
923 Parameters:
924
925 - $renderOnTimeout: Render in case of timeout or not.
926
927 Returns:
928
929 - Reference to the current object.
930 =cut
931 sub setRenderOnTimeout($) {
932 0 ▶ my($self, $renderOnTimeout) = @_;
Subroutine setRenderOnTimeout: not called CC=1 SCAR=6.9
Pod documented
933
934 0 $self->{parameters}{"render_on_timeout"} = $self->SUPER::serializeBoolean($renderOnTimeout);
935 0 return $self;
936 }
937
938 =head2 setKeepImagesTogether( $keepImagesTogether )
939
940 Avoid breaking images between PDF pages. The default value is False and images are split between pages if larger.
941
942 Parameters:
943
944 - $keepImagesTogether: Try to keep images on same page or not.
945
946 Returns:
947
948 - Reference to the current object.
949 =cut
950 sub setKeepImagesTogether($) {
951 0 ▶ my($self, $keepImagesTogether) = @_;
Subroutine setKeepImagesTogether: not called CC=1 SCAR=6.9
Pod documented
952
953 0 $self->{parameters}{"keep_images_together"} = $self->SUPER::serializeBoolean($keepImagesTogether);
954 0 return $self;
955 }
956
957 =head2 setDocTitle( $docTitle )
958
959 Set the PDF document title.
960
961 Parameters:
962
963 - $docTitle: Document title.
964
965 Returns:
966
967 - Reference to the current object.
968 =cut
969 sub setDocTitle($) {
970 0 ▶ my($self, $docTitle) = @_;
Subroutine setDocTitle: not called CC=1 SCAR=6.9
Pod documented
971
972 0 $self->{parameters}{"doc_title"} = $docTitle;
973 0 return $self;
974 }
975
976 =head2 setDocSubject( $docSubject )
977
978 Set the PDF document subject.
979
980 Parameters:
981
982 - $docSubject: Document subject.
983
984 Returns:
985
986 - Reference to the current object.
987 =cut
988 sub setDocSubject($) {
989 0 ▶ my($self, $docSubject) = @_;
Subroutine setDocSubject: not called CC=1 SCAR=6.9
Pod documented
990
991 0 $self->{parameters}{"doc_subject"} = $docSubject;
992 0 return $self;
993 }
994
995 =head2 setDocKeywords( $docKeywords )
996
997 Set the PDF document keywords.
998
999 Parameters:
1000
1001 - $docKeywords: Document keywords.
1002
1003 Returns:
1004
1005 - Reference to the current object.
1006 =cut
1007 sub setDocKeywords($) {
1008 0 ▶ my($self, $docKeywords) = @_;
Subroutine setDocKeywords: not called CC=1 SCAR=6.9
Pod documented
1009
1010 0 $self->{parameters}{"doc_keywords"} = $docKeywords;
1011 0 return $self;
1012 }
1013
1014 =head2 setDocAuthor( $docAuthor )
1015
1016 Set the PDF document author.
1017
1018 Parameters:
1019
1020 - $docAuthor: Document author.
1021
1022 Returns:
1023
1024 - Reference to the current object.
1025 =cut
1026 sub setDocAuthor($) {
1027 0 ▶ my($self, $docAuthor) = @_;
Subroutine setDocAuthor: not called CC=1 SCAR=6.9
Pod documented
1028
1029 0 $self->{parameters}{"doc_author"} = $docAuthor;
1030 0 return $self;
1031 }
1032
1033 =head2 setDocAddCreationDate( $docAddCreationDate )
1034
1035 Add the date and time when the PDF document was created to the PDF document information. The default value is False.
1036
1037 Parameters:
1038
1039 - $docAddCreationDate: Add creation date to the document metadata or not.
1040
1041 Returns:
1042
1043 - Reference to the current object.
1044 =cut
1045 sub setDocAddCreationDate($) {
1046 0 ▶ my($self, $docAddCreationDate) = @_;
Subroutine setDocAddCreationDate: not called CC=1 SCAR=6.9
Pod documented
1047
1048 0 $self->{parameters}{"doc_add_creation_date"} = $self->SUPER::serializeBoolean($docAddCreationDate);
1049 0 return $self;
1050 }
1051
1052 =head2 setViewerPageLayout( $pageLayout )
1053
1054 Set the page layout to be used when the document is opened in a PDF viewer. The default value is 1 - OneColumn.
1055
1056 Parameters:
1057
1058 - $pageLayout: Page layout. Possible values: 0 (Single Page), 1 (One Column), 2 (Two Column Left), 3 (Two Column Right).
1059
1060 Returns:
1061
1062 - Reference to the current object.
1063 =cut
1064 sub setViewerPageLayout($) {
1065 0 ▶ my($self, $pageLayout) = @_;
Subroutine setViewerPageLayout: not called CC=5 SCAR=34.0
Pod documented
1066
1067 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
1068 0 die ("Allowed values for Page Layout: 0 (Single Page), 1 (One Column), 2 (Two Column Left), 3 (Two Column Right).");
1069 }
1070
1071 0 $self->{parameters}{"viewer_page_layout"} = $pageLayout;
1072 0 return $self;
1073 }
1074
1075 =head2 setViewerPageMode( $pageMode )
1076
1077 Set the document page mode when the pdf document is opened in a PDF viewer. The default value is 0 - UseNone.
1078
1079 Parameters:
1080
1081 - $pageMode: Page mode. Possible values: 0 (Use None), 1 (Use Outlines), 2 (Use Thumbs), 3 (Full Screen), 4 (Use OC), 5 (Use Attachments).
1082
1083 Returns:
1084
1085 - Reference to the current object.
1086 =cut
1087 sub setViewerPageMode($) {
1088 0 ▶ my($self, $pageMode) = @_;
Subroutine setViewerPageMode: not called CC=7 SCAR=40.3
Pod documented
1089
1090 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
1091 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).");
1092 }
1093
1094 0 $self->{parameters}{"viewer_page_mode"} = $pageMode;
1095 0 return $self;
1096 }
1097
1098 =head2 setViewerCenterWindow( $viewerCenterWindow )
1099
1100 Set a flag specifying whether to position the document's window in the center of the screen. The default value is False.
1101
1102 Parameters:
1103
1104 - $viewerCenterWindow: Center window or not.
1105
1106 Returns:
1107
1108 - Reference to the current object.
1109 =cut
1110 sub setViewerCenterWindow($) {
1111 0 ▶ my($self, $viewerCenterWindow) = @_;
Subroutine setViewerCenterWindow: not called CC=1 SCAR=6.9
Pod documented
1112
1113 0 $self->{parameters}{"viewer_center_window"} = $self->SUPER::serializeBoolean($viewerCenterWindow);
1114 0 return $self;
1115 }
1116
1117 =head2 setViewerDisplayDocTitle( $viewerDisplayDocTitle )
1118
1119 Set a flag specifying whether the window's title bar should display the document title taken from document information. The default value is False.
1120
1121 Parameters:
1122
1123 - $viewerDisplayDocTitle: Display title or not.
1124
1125 Returns:
1126
1127 - Reference to the current object.
1128 =cut
1129 sub setViewerDisplayDocTitle($) {
1130 0 ▶ my($self, $viewerDisplayDocTitle) = @_;
Subroutine setViewerDisplayDocTitle: not called CC=1 SCAR=6.9
Pod documented
1131
1132 0 $self->{parameters}{"viewer_display_doc_title"} = $self->SUPER::serializeBoolean($viewerDisplayDocTitle);
1133 0 return $self;
1134 }
1135
1136 =head2 setViewerFitWindow( $viewerFitWindow )
1137
1138 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.
1139
1140 Parameters:
1141
1142 - $viewerFitWindow: Fit window or not.
1143
1144 Returns:
1145
1146 - Reference to the current object.
1147 =cut
1148 sub setViewerFitWindow($) {
1149 0 ▶ my($self, $viewerFitWindow) = @_;
Subroutine setViewerFitWindow: not called CC=1 SCAR=6.9
Pod documented
1150
1151 0 $self->{parameters}{"viewer_fit_window"} = $self->SUPER::serializeBoolean($viewerFitWindow);
1152 0 return $self;
1153 }
1154
1155 =head2 setViewerHideMenuBar( $viewerHideMenuBar )
1156
1157 Set a flag specifying whether to hide the pdf viewer application's menu bar when the document is active. The default value is False.
1158
1159 Parameters:
1160
1161 - $viewerHideMenuBar: Hide menu bar or not.
1162
1163 Returns:
1164
1165 - Reference to the current object.
1166 =cut
1167 sub setViewerHideMenuBar($) {
1168 0 ▶ my($self, $viewerHideMenuBar) = @_;
Subroutine setViewerHideMenuBar: not called CC=1 SCAR=6.9
Pod documented
1169
1170 0 $self->{parameters}{"viewer_hide_menu_bar"} = $self->SUPER::serializeBoolean($viewerHideMenuBar);
1171 0 return $self;
1172 }
1173
1174 =head2 setViewerHideToolbar( $viewerHideToolbar )
1175
1176 Set a flag specifying whether to hide the pdf viewer application's tool bars when the document is active. The default value is False.
1177
1178 Parameters:
1179
1180 - $viewerHideToolbar: Hide tool bars or not.
1181
1182 Returns:
1183
1184 - Reference to the current object.
1185 =cut
1186 sub setViewerHideToolbar($) {
1187 0 ▶ my($self, $viewerHideToolbar) = @_;
Subroutine setViewerHideToolbar: not called CC=1 SCAR=6.9
Pod documented
1188
1189 0 $self->{parameters}{"viewer_hide_toolbar"} = $self->SUPER::serializeBoolean($viewerHideToolbar);
1190 0 return $self;
1191 }
1192
1193 =head2 setViewerHideWindowUI( $viewerHideWindowUI )
1194
1195 Set a flag specifying whether to hide user interface elements in the document's window (such as scroll bars and navigation controls),
1196 leaving only the document's contents displayed.
1197
1198 Parameters:
1199
1200 - $viewerHideWindowUI: Hide window UI or not.
1201
1202 Returns:
1203
1204 - Reference to the current object.
1205 =cut
1206 sub setViewerHideWindowUI($) {
1207 0 ▶ my($self, $viewerHideWindowUI) = @_;
Subroutine setViewerHideWindowUI: not called CC=1 SCAR=6.9
Pod documented
1208
1209 0 $self->{parameters}{"viewer_hide_window_ui"} = $self->SUPER::serializeBoolean($viewerHideWindowUI);
1210 0 return $self;
1211 }
1212
1213 =head2 setShowHeader( $showHeader )
1214
1215 Control if a custom header is displayed in the generated PDF document. The default value is False.
1216
1217 Parameters:
1218
1219 - $showHeader: Show header or not.
1220
1221 Returns:
1222
1223 - Reference to the current object.
1224 =cut
1225 sub setShowHeader($) {
1226 0 ▶ my($self, $showHeader) = @_;
Subroutine setShowHeader: not called CC=1 SCAR=6.9
Pod documented
1227
1228 0 $self->{parameters}{"show_header"} = $self->SUPER::serializeBoolean($showHeader);
1229 0 return $self;
1230 }
1231
1232 =head2 setHeaderHeight( $height )
1233
1234 The height of the pdf document header. This height is specified in points. 1 point is 1/72 inch. The default value is 50.
1235
1236 Parameters:
1237
1238 - $height: Header height.
1239
1240 Returns:
1241
1242 - Reference to the current object.
1243 =cut
1244 sub setHeaderHeight($) {
1245 0 ▶ my($self, $height) = @_;
Subroutine setHeaderHeight: not called CC=1 SCAR=6.9
Pod documented
1246
1247 0 $self->{parameters}{"header_height"} = $height;
1248 0 return $self;
1249 }
1250
1251 =head2 setHeaderUrl( $url )
1252
1253 Set the url of the web page that is converted and rendered in the PDF document header.
1254
1255 Parameters:
1256
1257 - $url: The url of the web page that is converted and rendered in the pdf document header.
1258
1259 Returns:
1260
1261 - Reference to the current object.
1262 =cut
1263 sub setHeaderUrl($) {
1264 0 ▶ my($self, $url) = @_;
Subroutine setHeaderUrl: not called CC=1 SCAR=6.9
Pod documented
1265
1266 0 $self->{parameters}{"header_url"} = $url;
1267 0 return $self;
1268 }
1269
1270 =head2 setHeaderHtml( $html )
1271
1272 Set the raw html that is converted and rendered in the pdf document header.
1273
1274 Parameters:
1275
1276 - $html: The raw html that is converted and rendered in the pdf document header.
1277
1278 Returns:
1279
1280 - Reference to the current object.
1281 =cut
1282 sub setHeaderHtml($) {
1283 0 ▶ my($self, $html) = @_;
Subroutine setHeaderHtml: not called CC=1 SCAR=6.9
Pod documented
1284
1285 0 $self->{parameters}{"header_html"} = $html;
1286 0 return $self;
1287 }
1288
1289 =head2 setHeaderBaseUrl( $baseUrl )
1290
1291 Set an optional base url parameter can be used together with the header HTML to resolve relative paths from the html string.
1292
1293 Parameters:
1294
1295 - $baseUrl: Header base url.
1296
1297 Returns:
1298
1299 - Reference to the current object.
1300 =cut
1301 sub setHeaderBaseUrl($) {
1302 0 ▶ my($self, $baseUrl) = @_;
Subroutine setHeaderBaseUrl: not called CC=1 SCAR=6.9
Pod documented
1303
1304 0 $self->{parameters}{"header_base_url"} = $baseUrl;
1305 0 return $self;
1306 }
1307
1308 =head2 setHeaderDisplayOnFirstPage( $displayOnFirstPage )
1309
1310 Control the visibility of the header on the first page of the generated pdf document. The default value is True.
1311
1312 Parameters:
1313
1314 - $displayOnFirstPage: Display header on the first page or not.
1315
1316 Returns:
1317
1318 - Reference to the current object.
1319 =cut
1320 sub setHeaderDisplayOnFirstPage($) {
1321 0 ▶ my($self, $displayOnFirstPage) = @_;
Subroutine setHeaderDisplayOnFirstPage: not called CC=1 SCAR=6.9
Pod documented
1322
1323 0 $self->{parameters}{"header_display_on_first_page"} = $self->SUPER::serializeBoolean($displayOnFirstPage);
1324 0 return $self;
1325 }
1326
1327 =head2 setHeaderDisplayOnOddPages( $displayOnOddPages )
1328
1329 Control the visibility of the header on the odd numbered pages of the generated pdf document. The default value is True.
1330
1331 Parameters:
1332
1333 - $displayOnOddPages: Display header on odd pages or not.
1334
1335 Returns:
1336
1337 - Reference to the current object.
1338 =cut
1339 sub setHeaderDisplayOnOddPages($) {
1340 0 ▶ my($self, $displayOnOddPages) = @_;
Subroutine setHeaderDisplayOnOddPages: not called CC=1 SCAR=6.9
Pod documented
1341
1342 0 $self->{parameters}{"header_display_on_odd_pages"} = $self->SUPER::serializeBoolean($displayOnOddPages);
1343 0 return $self;
1344 }
1345
1346 =head2 setHeaderDisplayOnEvenPages( $displayOnEvenPages )
1347
1348 Control the visibility of the header on the even numbered pages of the generated pdf document. The default value is True.
1349
1350 Parameters:
1351
1352 - $displayOnEvenPages: Display header on even pages or not.
1353
1354 Returns:
1355
1356 - Reference to the current object.
1357 =cut
1358 sub setHeaderDisplayOnEvenPages($) {
1359 0 ▶ my($self, $displayOnEvenPages) = @_;
Subroutine setHeaderDisplayOnEvenPages: not called CC=1 SCAR=6.9
Pod documented
1360
1361 0 $self->{parameters}{"header_display_on_even_pages"} = $self->SUPER::serializeBoolean($displayOnEvenPages);
1362 0 return $self;
1363 }
1364
1365 =head2 setHeaderWebPageWidth( $headerWebPageWidth )
1366
1367 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.
1368
1369 Parameters:
1370
1371 - $headerWebPageWidth: Browser window width in pixels.
1372
1373 Returns:
1374
1375 - Reference to the current object.
1376 =cut
1377 sub setHeaderWebPageWidth($) {
1378 0 ▶ my($self, $headerWebPageWidth) = @_;
Subroutine setHeaderWebPageWidth: not called CC=1 SCAR=6.9
Pod documented
1379
1380 0 $self->{parameters}{"header_web_page_width"} = $headerWebPageWidth;
1381 0 return $self;
1382 }
1383
1384 =head2 setHeaderWebPageHeight( $headerWebPageHeight )
1385
1386 Set the height in pixels used by the converter's internal browser window during the conversion of the header content.
1387 The default value is 0px and it means that the page height is automatically calculated by the converter.
1388
1389 Parameters:
1390
1391 - $headerWebPageHeight: Browser window height in pixels. Set it to 0px to automatically calculate page height.
1392
1393 Returns:
1394
1395 - Reference to the current object.
1396 =cut
1397 sub setHeaderWebPageHeight($) {
1398 0 ▶ my($self, $headerWebPageHeight) = @_;
Subroutine setHeaderWebPageHeight: not called CC=1 SCAR=6.9
Pod documented
1399
1400 0 $self->{parameters}{"header_web_page_height"} = $headerWebPageHeight;
1401 0 return $self;
1402 }
1403
1404
1405
1406 =head2 setShowFooter( $showFooter )
1407
1408 Control if a custom footer is displayed in the generated PDF document. The default value is False.
1409
1410 Parameters:
1411
1412 - $showFooter: Show footer or not.
1413
1414 Returns:
1415
1416 - Reference to the current object.
1417 =cut
1418 sub setShowFooter($) {
1419 0 ▶ my($self, $showFooter) = @_;
Subroutine setShowFooter: not called CC=1 SCAR=6.9
Pod documented
1420
1421 0 $self->{parameters}{"show_footer"} = $self->SUPER::serializeBoolean($showFooter);
1422 0 return $self;
1423 }
1424
1425 =head2 setFooterHeight( $height )
1426
1427 The height of the pdf document footer. This height is specified in points. 1 point is 1/72 inch. The default value is 50.
1428
1429 Parameters:
1430
1431 - $height: Footer height.
1432
1433 Returns:
1434
1435 - Reference to the current object.
1436 =cut
1437 sub setFooterHeight($) {
1438 0 ▶ my($self, $height) = @_;
Subroutine setFooterHeight: not called CC=1 SCAR=6.9
Pod documented
1439
1440 0 $self->{parameters}{"footer_height"} = $height;
1441 0 return $self;
1442 }
1443
1444 =head2 setFooterUrl( $url )
1445
1446 Set the url of the web page that is converted and rendered in the PDF document footer.
1447
1448 Parameters:
1449
1450 - $url: The url of the web page that is converted and rendered in the pdf document footer.
1451
1452 Returns:
1453
1454 - Reference to the current object.
1455 =cut
1456 sub setFooterUrl($) {
1457 0 ▶ my($self, $url) = @_;
Subroutine setFooterUrl: not called CC=1 SCAR=6.9
Pod documented
1458
1459 0 $self->{parameters}{"footer_url"} = $url;
1460 0 return $self;
1461 }
1462
1463 =head2 setFooterHtml( $html )
1464
1465 Set the raw html that is converted and rendered in the pdf document footer.
1466
1467 Parameters:
1468
1469 - $html: The raw html that is converted and rendered in the pdf document footer.
1470
1471 Returns:
1472
1473 - Reference to the current object.
1474 =cut
1475 sub setFooterHtml($) {
1476 0 ▶ my($self, $html) = @_;
Subroutine setFooterHtml: not called CC=1 SCAR=6.9
Pod documented
1477
1478 0 $self->{parameters}{"footer_html"} = $html;
1479 0 return $self;
1480 }
1481
1482 =head2 setFooterBaseUrl( $baseUrl )
1483
1484 Set an optional base url parameter can be used together with the footer HTML to resolve relative paths from the html string.
1485
1486 Parameters:
1487
1488 - $baseUrl: Footer base url.
1489
1490 Returns:
1491
1492 - Reference to the current object.
1493 =cut
1494 sub setFooterBaseUrl($) {
1495 0 ▶ my($self, $baseUrl) = @_;
Subroutine setFooterBaseUrl: not called CC=1 SCAR=6.9
Pod documented
1496
1497 0 $self->{parameters}{"footer_base_url"} = $baseUrl;
1498 0 return $self;
1499 }
1500
1501 =head2 setFooterDisplayOnFirstPage( $displayOnFirstPage )
1502
1503 Control the visibility of the footer on the first page of the generated pdf document. The default value is True.
1504
1505 Parameters:
1506
1507 - $displayOnFirstPage: Display footer on the first page or not.
1508
1509 Returns:
1510
1511 - Reference to the current object.
1512 =cut
1513 sub setFooterDisplayOnFirstPage($) {
1514 0 ▶ my($self, $displayOnFirstPage) = @_;
Subroutine setFooterDisplayOnFirstPage: not called CC=1 SCAR=6.9
Pod documented
1515
1516 0 $self->{parameters}{"footer_display_on_first_page"} = $self->SUPER::serializeBoolean($displayOnFirstPage);
1517 0 return $self;
1518 }
1519
1520 =head2 setFooterDisplayOnOddPages( $displayOnOddPages )
1521
1522 Control the visibility of the footer on the odd numbered pages of the generated pdf document. The default value is True.
1523
1524 Parameters:
1525
1526 - $displayOnOddPages: Display footer on odd pages or not.
1527
1528 Returns:
1529
1530 - Reference to the current object.
1531 =cut
1532 sub setFooterDisplayOnOddPages($) {
1533 0 ▶ my($self, $displayOnOddPages) = @_;
Subroutine setFooterDisplayOnOddPages: not called CC=1 SCAR=6.9
Pod documented
1534
1535 0 $self->{parameters}{"footer_display_on_odd_pages"} = $self->SUPER::serializeBoolean($displayOnOddPages);
1536 0 return $self;
1537 }
1538
1539 =head2 setFooterDisplayOnEvenPages( $displayOnEvenPages )
1540
1541 Control the visibility of the footer on the even numbered pages of the generated pdf document. The default value is True.
1542
1543 Parameters:
1544
1545 - $displayOnEvenPages: Display footer on even pages or not.
1546
1547 Returns:
1548
1549 - Reference to the current object.
1550 =cut
1551 sub setFooterDisplayOnEvenPages($) {
1552 0 ▶ my($self, $displayOnEvenPages) = @_;
Subroutine setFooterDisplayOnEvenPages: not called CC=1 SCAR=6.9
Pod documented
1553
1554 0 $self->{parameters}{"footer_display_on_even_pages"} = $self->SUPER::serializeBoolean($displayOnEvenPages);
1555 0 return $self;
1556 }
1557
1558 =head2 setFooterDisplayOnLastPage( $displayOnLastPage )
1559
1560 Add a special footer on the last page of the generated pdf document only. The default value is False.
1561 Use setFooterUrl or setFooterHtml and setFooterBaseUrl to specify the content of the last page footer.
1562 Use setFooterHeight to specify the height of the special last page footer.
1563
1564 Parameters:
1565
1566 - $displayOnLastPage: Display special footer on the last page or not.
1567
1568 Returns:
1569
1570 - Reference to the current object.
1571 =cut
1572 sub setFooterDisplayOnLastPage($) {
1573 0 ▶ my($self, $displayOnLastPage) = @_;
Subroutine setFooterDisplayOnLastPage: not called CC=1 SCAR=6.9
Pod documented
1574
1575 0 $self->{parameters}{"footer_display_on_last_page"} = $self->SUPER::serializeBoolean($displayOnLastPage);
1576 0 return $self;
1577 }
1578
1579 =head2 setFooterWebPageWidth( $footerWebPageWidth )
1580
1581 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.
1582
1583 Parameters:
1584
1585 - $footerWebPageWidth: Browser window width in pixels.
1586
1587 Returns:
1588
1589 - Reference to the current object.
1590 =cut
1591 sub setFooterWebPageWidth($) {
1592 0 ▶ my($self, $footerWebPageWidth) = @_;
Subroutine setFooterWebPageWidth: not called CC=1 SCAR=6.9
Pod documented
1593
1594 0 $self->{parameters}{"footer_web_page_width"} = $footerWebPageWidth;
1595 0 return $self;
1596 }
1597
1598 =head2 setFooterWebPageHeight( $footerWebPageHeight )
1599
1600 Set the height in pixels used by the converter's internal browser window during the conversion of the footer content.
1601 The default value is 0px and it means that the page height is automatically calculated by the converter.
1602
1603 Parameters:
1604
1605 - $footerWebPageHeight: Browser window height in pixels. Set it to 0px to automatically calculate page height.
1606
1607 Returns:
1608
1609 - Reference to the current object.
1610 =cut
1611 sub setFooterWebPageHeight($) {
1612 0 ▶ my($self, $footerWebPageHeight) = @_;
Subroutine setFooterWebPageHeight: not called CC=1 SCAR=6.9
Pod documented
1613
1614 0 $self->{parameters}{"footer_web_page_height"} = $footerWebPageHeight;
1615 0 return $self;
1616 }
1617
1618
1619 =head2 setShowPageNumbers( $showPageNumbers )
1620
1621 Show page numbers. Default value is True. Page numbers will be displayed in the footer of the PDF document.
1622
1623 Parameters:
1624
1625 - $showPageNumbers: Show page numbers or not.
1626
1627 Returns:
1628
1629 - Reference to the current object.
1630 =cut
1631 sub setShowPageNumbers($) {
1632 0 ▶ my($self, $showPageNumbers) = @_;
Subroutine setShowPageNumbers: not called CC=1 SCAR=6.9
Pod documented
1633
1634 0 $self->{parameters}{"page_numbers"} = $self->SUPER::serializeBoolean($showPageNumbers);
1635 0 return $self;
1636 }
1637
1638 =head2 setPageNumbersFirst( $firstPageNumber )
1639
1640 Control the page number for the first page being rendered. The default value is 1.
1641
1642 Parameters:
1643
1644 - $firstPageNumber: First page number.
1645
1646 Returns:
1647
1648 - Reference to the current object.
1649 =cut
1650 sub setPageNumbersFirst($) {
1651 0 ▶ my($self, $firstPageNumber) = @_;
Subroutine setPageNumbersFirst: not called CC=1 SCAR=6.9
Pod documented
1652
1653 0 $self->{parameters}{"page_numbers_first"} = $firstPageNumber;
1654 0 return $self;
1655 }
1656
1657 =head2 setPageNumbersOffset( $totalPagesOffset )
1658
1659 Control the total number of pages offset in the generated pdf document. The default value is 0.
1660
1661 Parameters:
1662
1663 - $totalPagesOffset: Offset for the total number of pages in the generated pdf document.
1664
1665 Returns:
1666
1667 - Reference to the current object.
1668 =cut
1669 sub setPageNumbersOffset($) {
1670 0 ▶ my($self, $totalPagesOffset) = @_;
Subroutine setPageNumbersOffset: not called CC=1 SCAR=6.9
Pod documented
1671
1672 0 $self->{parameters}{"page_numbers_offset"} = $totalPagesOffset;
1673 0 return $self;
1674 }
1675
1676 =head2 setPageNumbersTemplate( $template )
1677
1678 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}
1679 for the total number of pages. The default value is "Page: {page_number} of {total_pages}".
1680
1681 Parameters:
1682
1683 - $template: Page numbers template.
1684
1685 Returns:
1686
1687 - Reference to the current object.
1688 =cut
1689 sub setPageNumbersTemplate($) {
1690 0 ▶ my($self, $template) = @_;
Subroutine setPageNumbersTemplate: not called CC=1 SCAR=6.9
Pod documented
1691
1692 0 $self->{parameters}{"page_numbers_template"} = $template;
1693 0 return $self;
1694 }
1695
1696 =head2 setPageNumbersFontName( $fontName )
1697
1698 Set the font used to display the page numbers text. The default value is "Helvetica".
1699
1700 Parameters:
1701
1702 - $fontName: The font used to display the page numbers text.
1703
1704 Returns:
1705
1706 - Reference to the current object.
1707 =cut
1708 sub setPageNumbersFontName($) {
1709 0 ▶ my($self, $fontName) = @_;
Subroutine setPageNumbersFontName: not called CC=1 SCAR=6.9
Pod documented
1710
1711 0 $self->{parameters}{"page_numbers_font_name"} = $fontName;
1712 0 return $self;
1713 }
1714
1715 =head2 setPageNumbersFontSize( $fontSize )
1716
1717 Set the size of the font used to display the page numbers. The default value is 10 points.
1718
1719 Parameters:
1720
1721 - $fontSize: The size in points of the font used to display the page numbers.
1722
1723 Returns:
1724
1725 - Reference to the current object.
1726 =cut
1727 sub setPageNumbersFontSize($) {
1728 0 ▶ my($self, $fontSize) = @_;
Subroutine setPageNumbersFontSize: not called CC=1 SCAR=6.9
Pod documented
1729
1730 0 $self->{parameters}{"page_numbers_font_size"} = $fontSize;
1731 0 return $self;
1732 }
1733
1734 =head2 setPageNumbersAlignment( $alignment )
1735
1736 Set the alignment of the page numbers text. The default value is "2" - Right.
1737
1738 Parameters:
1739
1740 - $alignment: The alignment of the page numbers text. Possible values: 1 (Left), 2 (Center), 3 (Right).
1741
1742 Returns:
1743
1744 - Reference to the current object.
1745 =cut
1746 sub setPageNumbersAlignment($) {
1747 0 ▶ my($self, $alignment) = @_;
Subroutine setPageNumbersAlignment: not called CC=4 SCAR=30.0
Pod documented
1748
1749 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
1750 0 die ("Allowed values for Page Numbers Alignment: 1 (Left), 2 (Center), 3 (Right).");
1751 }
1752
1753 0 $self->{parameters}{"page_numbers_alignment"} = $alignment;
1754 0 return $self;
1755 }
1756
1757 =head2 setPageNumbersColor( $color )
1758
1759 Specify the color of the page numbers text in #RRGGBB html format. The default value is #333333.
1760
1761 Parameters:
1762
1763 - $color: Page numbers color.
1764
1765 Returns:
1766
1767 - Reference to the current object.
1768 =cut
1769 sub setPageNumbersColor($) {
1770 0 ▶ my($self, $color) = @_;
Subroutine setPageNumbersColor: not called CC=2 SCAR=17.9
Pod documented
1771
1772 0 ▶ if ($color !~ m/^#?[0-9a-fA-F]{6}$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($color =~ /^#?[0-9a-fA-F]{6}$/) 0 0 0
1773 0 die ("Color value must be in #RRGGBB format.");
1774 }
1775
1776 0 $self->{parameters}{"page_numbers_color"} = $color;
1777 0 return $self;
1778 }
1779
1780 =head2 setPageNumbersVerticalPosition( $position )
1781
1782 Specify the position in points on the vertical where the page numbers text is displayed in the footer. The default value is 10 points.
1783
1784 Parameters:
1785
1786 - $position: Page numbers Y position in points.
1787
1788 Returns:
1789
1790 - Reference to the current object.
1791 =cut
1792 sub setPageNumbersVerticalPosition($) {
1793 0 ▶ my($self, $position) = @_;
Subroutine setPageNumbersVerticalPosition: not called CC=1 SCAR=6.9
Pod documented
1794
1795 0 $self->{parameters}{"page_numbers_pos_y"} = $position;
1796 0 return $self;
1797 }
1798
1799 =head2 setPdfBookmarksSelectors( $selectors )
1800
1801 Generate automatic bookmarks in pdf. The elements that will be bookmarked are defined using CSS selectors.
1802 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
1803 the selector for the elements with the id 'myid' is "*#myid".
1804 Read more about CSS selectors <a href="http://www.w3schools.com/cssref/css_selectors.asp" target="_blank">here</a>.
1805
1806 Parameters:
1807
1808 - $selectors: CSS selectors used to identify HTML elements, comma separated.
1809
1810 Returns:
1811
1812 - Reference to the current object.
1813 =cut
1814 sub setPdfBookmarksSelectors($) {
1815 0 ▶ my($self, $selectors) = @_;
Subroutine setPdfBookmarksSelectors: not called CC=1 SCAR=6.9
Pod documented
1816
1817 0 $self->{parameters}{"pdf_bookmarks_selectors"} = $selectors;
1818 0 return $self;
1819 }
1820
1821 =head2 setPdfHideElements( $selectors )
1822
1823 Exclude page elements from the conversion. The elements that will be excluded are defined using CSS selectors.
1824 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
1825 the selector for the elements with the id 'myid' is "*#myid".
1826 Read more about CSS selectors <a href="http://www.w3schools.com/cssref/css_selectors.asp" target="_blank">here</a>.
1827
1828 Parameters:
1829
1830 - $selectors: CSS selectors used to identify HTML elements, comma separated.
1831
1832 Returns:
1833
1834 - Reference to the current object.
1835 =cut
1836 sub setPdfHideElements($) {
1837 0 ▶ my($self, $selectors) = @_;
Subroutine setPdfHideElements: not called CC=1 SCAR=6.9
Pod documented
1838
1839 0 $self->{parameters}{"pdf_hide_elements"} = $selectors;
1840 0 return $self;
1841 }
1842
1843 =head2 setPdfShowOnlyElementID( $elementID )
1844
1845 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.
1846 The element can be anything (image, table, table row, div, text, etc).
1847
1848 Parameters:
1849
1850 - $elementID: HTML element ID.
1851
1852 Returns:
1853
1854 - Reference to the current object.
1855 =cut
1856 sub setPdfShowOnlyElementID($) {
1857 0 ▶ my($self, $elementID) = @_;
Subroutine setPdfShowOnlyElementID: not called CC=1 SCAR=6.9
Pod documented
1858
1859 0 $self->{parameters}{"pdf_show_only_element_id"} = $elementID;
1860 0 return $self;
1861 }
1862
1863 =head2 setPdfWebElementsSelectors( $selectors )
1864
1865 Get the locations of page elements from the conversion. The elements that will have their locations retrieved are defined using CSS selectors.
1866 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
1867 the selector for the elements with the id 'myid' is "*#myid".
1868 Read more about CSS selectors <a href="http://www.w3schools.com/cssref/css_selectors.asp" target="_blank">here</a>.
1869
1870 Parameters:
1871
1872 - $selectors: CSS selectors used to identify HTML elements, comma separated.
1873
1874 Returns:
1875
1876 - Reference to the current object.
1877 =cut
1878 sub setPdfWebElementsSelectors($) {
1879 0 ▶ my($self, $selectors) = @_;
Subroutine setPdfWebElementsSelectors: not called CC=1 SCAR=6.9
Pod documented
1880
1881 0 $self->{parameters}{"pdf_web_elements_selectors"} = $selectors;
1882 0 return $self;
1883 }
1884
1885 =head2 setStartupMode( $startupMode )
1886
1887 Set converter startup mode. The default value is Automatic and the conversion is started immediately.
1888 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).
1889 If set to Manual, the conversion is started only by a javascript call to SelectPdf.startConversion() from within the web page.
1890
1891 Parameters:
1892
1893 - $startupMode: Converter startup mode. Possible values: Automatic, Manual.
1894
1895 Returns:
1896
1897 - Reference to the current object.
1898 =cut
1899 sub setStartupMode($) {
1900 0 ▶ my($self, $startupMode) = @_;
Subroutine setStartupMode: not called CC=2 SCAR=17.9
Pod documented
1901
1902 0 ▶ if ($startupMode !~ m/^(Automatic|Manual)$/i) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($startupMode =~ /^(Automatic|Manual)$/i) 0 0 0
1903 0 die ("Allowed values for Startup Mode: Automatic, Manual.");
1904 }
1905
1906 0 $self->{parameters}{"startup_mode"} = $startupMode;
1907 0 return $self;
1908 }
1909
1910 =head2 setSkipDecoding( $skipDecoding )
1911
1912 Internal use only.
1913
1914 Parameters:
1915
1916 - $skipDecoding: The default value is True.
1917
1918 Returns:
1919
1920 - Reference to the current object.
1921 =cut
1922 sub setSkipDecoding($) {
1923 0 ▶ my($self, $skipDecoding) = @_;
Subroutine setSkipDecoding: not called CC=1 SCAR=6.9
Pod documented
1924
1925 0 $self->{parameters}{"skip_decoding"} = $self->SUPER::serializeBoolean($skipDecoding);
1926 0 return $self;
1927 }
1928
1929 =head2 setScaleImages( $scaleImages )
1930
1931 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.
1932
1933 Parameters:
1934
1935 - $scaleImages: Scale images or not.
1936
1937 Returns:
1938
1939 - Reference to the current object.
1940 =cut
1941 sub setScaleImages($) {
1942 0 ▶ my($self, $scaleImages) = @_;
Subroutine setScaleImages: not called CC=1 SCAR=6.9
Pod documented
1943
1944 0 $self->{parameters}{"scale_images"} = $self->SUPER::serializeBoolean($scaleImages);
1945 0 return $self;
1946 }
1947
1948 =head2 setSinglePagePdf( $generateSinglePagePdf )
1949
1950 Generate a single page PDF. The converter will automatically resize the PDF page to fit all the content in a single page.
1951 The default value of this property is False and the PDF will contain several pages if the content is large.
1952
1953 Parameters:
1954
1955 - $generateSinglePagePdf: Generate a single page PDF or not.
1956
1957 Returns:
1958
1959 - Reference to the current object.
1960 =cut
1961 sub setSinglePagePdf($) {
1962 0 ▶ my($self, $generateSinglePagePdf) = @_;
Subroutine setSinglePagePdf: not called CC=1 SCAR=6.9
Pod documented
1963
1964 0 $self->{parameters}{"single_page_pdf"} = $self->SUPER::serializeBoolean($generateSinglePagePdf);
1965 0 return $self;
1966 }
1967
1968 =head2 setPageBreaksEnhancedAlgorithm( $enableEnhancedPageBreaksAlgorithm )
1969
1970 Get or set a flag indicating if an enhanced custom page breaks algorithm is used.
1971 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.
1972 The default value for this property is False.
1973
1974 Parameters:
1975
1976 - $enableEnhancedPageBreaksAlgorithm: Enable enhanced page breaks algorithm or not.
1977
1978 Returns:
1979
1980 - Reference to the current object.
1981 =cut
1982 sub setPageBreaksEnhancedAlgorithm($) {
1983 0 ▶ my($self, $enableEnhancedPageBreaksAlgorithm) = @_;
Subroutine setPageBreaksEnhancedAlgorithm: not called CC=1 SCAR=6.9
Pod documented
1984
1985 0 $self->{parameters}{"page_breaks_enhanced_algorithm"} = $self->SUPER::serializeBoolean($enableEnhancedPageBreaksAlgorithm);
1986 0 return $self;
1987 }
1988
1989 =head2 setCookies( $cookies )
1990
1991 Set HTTP cookies for the web page being converted.
1992
1993 Parameters:
1994
1995 - $cookies: Dictionary with HTTP cookies that will be sent to the page being converted.
1996
1997 Returns:
1998
1999 - Reference to the current object.
2000 =cut
2001 sub setCookies($) {
2002 0 ▶ my($self, $cookies) = @_;
Subroutine setCookies: not called CC=1 SCAR=6.9
Pod documented
2003
2004 0 my $url = URI->new('', 'http');
2005 0 $url->query_form(%$cookies);
2006 0 my $cookiesString = $url->query;
2007
2008 0 $self->{parameters}{"cookies_string"} = $cookiesString;
2009 0 return $self;
2010 }
2011
2012 =head2 setCustomParameter( $parameterName, $parameterValue )
2013
2014 Set a custom parameter. Do not use this method unless advised by SelectPdf.
2015
2016 Parameters:
2017
2018 - $parameterName: Parameter name.
2019
2020 - $parameterValue: Parameter value.
2021
2022 Returns:
2023
2024 - Reference to the current object.
2025 =cut
2026 sub setCustomParameter($,$) {
2027 0 ▶ my($self, $parameterName, $parameterValue) = @_;
Subroutine setCustomParameter: not called CC=1 SCAR=6.9
Pod documented
2028
2029 0 $self->{parameters}{$parameterName} = $parameterValue;
2030 0 return $self;
2031 }
2032
2033 =head2 getWebElements
2034
2035 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.
2036
2037 Returns:
2038
2039 - Json with web elements locations.
2040 =cut
2041 sub getWebElements {
2042 0 ▶ my($self) = @_;
Subroutine getWebElements: not called CC=1 SCAR=6.9
Pod documented
2043
2044 0 my $webElementsClient = SelectPdf::WebElementsClient->new($self->{parameters}{"key"}, $self->{jobId});
2045 0 $webElementsClient->setApiEndpoint($self->{apiWebElementsEndpoint});
2046
2047 0 return $webElementsClient->getWebElements();
2048 }
2049
2050
2051
2052 1 1;
↑ Summary SelectPdf/ApiClient.pm »