1PDF::Builder(3) User Contributed Perl Documentation PDF::Builder(3)
2
3
4
6 PDF::Builder - Facilitates the creation and modification of PDF files
7
9 use PDF::Builder;
10
11 # Create a blank PDF file
12 $pdf = PDF::Builder->new();
13
14 # Open an existing PDF file
15 $pdf = PDF::Builder->open('some.pdf');
16
17 # Add a blank page
18 $page = $pdf->page();
19
20 # Retrieve an existing page
21 $page = $pdf->openpage($page_number);
22
23 # Set the page size
24 $page->mediabox('Letter');
25
26 # Add a built-in font to the PDF
27 $font = $pdf->corefont('Helvetica-Bold');
28
29 # Add an external TTF font to the PDF
30 $font = $pdf->ttfont('/path/to/font.ttf');
31
32 # Add some text to the page
33 $text = $page->text();
34 $text->font($font, 20);
35 $text->translate(200, 700);
36 $text->text('Hello World!');
37
38 # Save the PDF
39 $pdf->saveas('/path/to/new.pdf');
40
42 See the file README (in downloadable package and on CPAN) for a summary
43 of prerequisites and tools needed to install PDF::Builder, both
44 mandatory and optional.
45
46 SOFTWARE DEVELOPMENT KIT
47 There are four levels of involvement with PDF::Builder. Depending on
48 what you want to do, different kinds of installs are recommended. See
49 "Software Development Kit" in PDF::Builder::Docs for suggestions.
50
51 OPTIONAL LIBRARIES
52 PDF::Builder can make use of some optional libraries, which are not
53 required for a successful installation, but improve speed and
54 capabilities. See "Optional Libraries" in PDF::Builder::Docs for more
55 information.
56
57 STRINGS (CHARACTER TEXT)
58 There are some things you should know about character encoding (for
59 text), before you dive in to coding. Please go to "Strings (Character
60 Text)" in PDF::Builder::Docs and have a read.
61
62 RENDERING ORDER
63 Invoking "text" and "graphics" methods can lead to unexpected results
64 (a different ordering of output than intended). See "Rendering Order"
65 in PDF::Builder::Docs for more information.
66
67 PDF VERSIONS SUPPORTED
68 PDF::Builder is mostly PDF 1.4-compliant, but there are complications
69 you should be aware of. Please read "PDF Versions Supported" in
70 PDF::Builder::Docs for details.
71
72 SUPPORTED PERL VERSIONS
73 PDF::Builder intends to support all major Perl versions that were
74 released in the past six years, plus one, in order to continue working
75 for the life of most long-term-stable (LTS) server distributions. See
76 the <https://www.cpan.org/src/> table First release in each branch of
77 Perl x.xxxx0 "Major" release dates.
78
79 For example, a version of PDF::Builder released on 2018-06-05 would
80 support the last major version of Perl released on or after 2012-06-05
81 (5.18), and then one before that, which would be 5.16. Alternatively,
82 the last major version of Perl released before 2012-06-05 is 5.16.
83
84 The intent is to avoid expending unnecessary effort in supporting very
85 old (obsolete) versions of Perl. If you need to use this module on a
86 server with an extremely out-of-date version of Perl, consider using
87 either plenv or Perlbrew to run a newer version of Perl without needing
88 admin privileges.
89
90 KNOWN ISSUES
91 This module does not work with perl's -l command-line switch.
92
93 There is a file INFO/KNOWN_INCOMP which lists known incompatibilities
94 with PDF::API2, in case you're thinking of porting over something from
95 that world, or have experience there and want to try PDF::Builder.
96 There is also a file INFO/DEPRECATED, which lists things which are
97 planned to be removed at some point.
98
99 HISTORY
100 The history of PDF::Builder is a complex and exciting saga... OK, it
101 may be mildly interesting. Have a look at "History" in
102 PDF::Builder::Docs section.
103
105 PDF::API2 was originally written by Alfred Reibenschuh. See the HISTORY
106 section for more information.
107
108 It was maintained by Steve Simms.
109
110 PDF::Builder is currently being maintained by Phil M. Perry.
111
112 SUPPORT
113 The full source is on https://github.com/PhilterPaper/Perl-PDF-Builder.
114
115 The release distribution is on CPAN:
116 https://metacpan.org/pod/PDF::Builder.
117
118 Bug reports are on
119 https://github.com/PhilterPaper/Perl-PDF-Builder/issues?q=is%3Aissue+sort%3Aupdated-desc
120 (with "bug" label), feature requests have an "enhancement" label, and
121 general discussions (architecture, roadmap, etc.) have a "general
122 discussion" label.
123
124 Do not under any circumstances open a PR (Pull Request) to report a
125 bug. It is a waste of both your and our time and effort. Open a regular
126 ticket (issue), and attach a Perl (.pl) program illustrating the
127 problem, if possible. If you believe that you have a program patch, and
128 offer to share it as a PR, we may give the go-ahead. Unsolicited PRs
129 may be closed without further action.
130
132 This software is Copyright (c) 2017-2021 by Phil M. Perry.
133
134 This is free software, licensed under:
135
136 The GNU Lesser General Public License (LGPL) Version 2.1, February 1999
137
138 (The master copy of this license lives on the GNU website.)
139 (A copy is provided in the INFO/LICENSE file for your convenience.)
140
141 This section of Builder.pm is intended only as a very brief summary of
142 the license; please consider INFO/LICENSE to be the controlling
143 version, if there is any conflict or ambiguity between the two.
144
145 This program is free software; you can redistribute it and/or modify it
146 under the terms of the GNU Lesser General Public License, as published
147 by the Free Software Foundation, either version 2.1 of the License, or
148 (at your option) any later version of this license.
149
150 NOTE: there are several files in this distribution which were
151 incorporated from outside sources and carry different licenses. If a
152 file states that it is under a license different than LGPL 2.1, that
153 license and its terms will apply to that file, and not LGPL 2.1.
154
155 This library is distributed in the hope that it will be useful, but
156 WITHOUT ANY WARRANTY; without even the implied warranty of
157 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
158 General Public License for more details.
159
161 $pdf = PDF::Builder->new(%options)
162 $pdf = PDF::Builder->new()
163 Creates a new PDF object.
164
165 Options
166
167 -file
168 If you will be saving it as a file and already know the
169 filename, you can give the '-file' option to minimize possible
170 memory requirements later on.
171
172 -compress
173 The '-compress' option can be given to specify stream
174 compression: default is 'flate', 'none' is no compression. No
175 other compression methods are currently supported.
176
177 -outver
178 The '-outver' option defaults to 1.4 as the output PDF version
179 and the highest allowed feature version (attempts to use
180 anything higher will give a warning). If an existing PDF with
181 a higher version is read in, -outver will be increased to that
182 version, with a warning.
183
184 -msgver
185 The '-msgver' option value of 1 (default) gives a warning
186 message if the '-outver' PDF level has to be bumped up due to
187 either a higher PDF level file being read in, or a higher level
188 feature was requested. A value of 0 suppresses the warning
189 message.
190
191 -diaglevel
192 The '-diaglevel' option can be given to specify the level of
193 diagnostics given by IntegrityCheck(). The default is level 2
194 (errors and warnings). See "IntegrityCheck" in
195 PDF::Builder::Docs for more information.
196
197 Example:
198
199 $pdf = PDF::Builder->new();
200 ...
201 print $pdf->stringify();
202
203 $pdf = PDF::Builder->new(-compress => 'none');
204 # equivalent to $pdf->{'forcecompress'} = 'none'; (or older, 0)
205
206 $pdf = PDF::Builder->new();
207 ...
208 $pdf->saveas('our/new.pdf');
209
210 $pdf = PDF::Builder->new(-file => 'our/new.pdf');
211 ...
212 $pdf->save();
213
214 $pdf = PDF::Builder->open($pdf_file, %options)
215 $pdf = PDF::Builder->open($pdf_file)
216 Opens an existing PDF file. See "new()" for options.
217
218 Example:
219
220 $pdf = PDF::Builder->open('our/old.pdf');
221 ...
222 $pdf->saveas('our/new.pdf');
223
224 $pdf = PDF::Builder->open('our/to/be/updated.pdf');
225 ...
226 $pdf->update();
227
228 $pdf = PDF::Builder->open_scalar($pdf_string, %options)
229 $pdf = PDF::Builder->open_scalar($pdf_string)
230 Opens a PDF contained in a string. See "new()" for other options.
231
232 -diags => 1
233 Display warnings when non-conforming PDF structure is found,
234 and fix up where possible. See PDF::Builder::Basic::PDF::File
235 for more information.
236
237 Example:
238
239 # Read a PDF into a string, for the purpose of demonstration
240 open $fh, 'our/old.pdf' or die $@;
241 undef $/; # Read the whole file at once
242 $pdf_string = <$fh>;
243
244 $pdf = PDF::Builder->open_scalar($pdf_string);
245 ...
246 $pdf->saveas('our/new.pdf');
247
248 $pdf->preferences(%options)
249 Controls viewing preferences for the PDF, including the Page Mode,
250 Page Layout, Viewer, and Initial Page Options. See "Preferences -
251 set user display preferences" in PDF::Builder::Docs for details on
252 all these option groups.
253
254 $val = $pdf->default($parameter)
255 $pdf->default($parameter, $value)
256 Gets/sets the default value for a behavior of PDF::Builder.
257
258 Supported Parameters:
259
260 nounrotate
261 prohibits Builder from rotating imported/opened page to re-
262 create a default pdf-context.
263
264 pageencaps
265 enables Builder's adding save/restore commands upon
266 importing/opening pages to preserve graphics-state for
267 modification.
268
269 copyannots
270 enables importing of annotations (*EXPERIMENTAL*).
271
272 $version = $pdf->version($new_version)
273 $version = $pdf->version()
274 Get/set the PDF version (e.g. 1.4).
275
276 For compatibility with earlier releases, if no decimal point is
277 given, assume "1." precedes the number given.
278
279 A warning message is given if you attempt to decrease the PDF
280 version, as you might have already read in a higher level file, or
281 used a higher level feature.
282
283 $bool = $pdf->isEncrypted()
284 Checks if the previously opened PDF is encrypted.
285
286 %infohash = $pdf->info(%infohash)
287 Gets/sets the info structure of the document.
288
289 See "info Example" in PDF::Builder::Docs section for an example of
290 the use of this method.
291
292 @metadata_attributes = $pdf->infoMetaAttributes(@metadata_attributes)
293 Gets/sets the supported info-structure tags.
294
295 Example:
296
297 @attributes = $pdf->infoMetaAttributes;
298 print "Supported Attributes: @attr\n";
299
300 @attributes = $pdf->infoMetaAttributes('CustomField1');
301 print "Supported Attributes: @attributes\n";
302
303 $xml = $pdf->xmpMetadata($xml)
304 Gets/sets the XMP XML data stream.
305
306 See "XMP XML example" in PDF::Builder::Docs section for an example
307 of the use of this method.
308
309 $pdf->pageLabel($index, $options)
310 Sets page label options.
311
312 Supported Options:
313
314 -style
315 Roman, roman, decimal, Alpha or alpha.
316
317 -start
318 Restart numbering at given number.
319
320 -prefix
321 Text prefix for numbering.
322
323 Example:
324
325 # Start with Roman Numerals
326 $pdf->pageLabel(0, {
327 -style => 'roman',
328 });
329
330 # Switch to Arabic
331 $pdf->pageLabel(4, {
332 -style => 'decimal',
333 });
334
335 # Numbering for Appendix A
336 $pdf->pageLabel(32, {
337 -start => 1,
338 -prefix => 'A-'
339 });
340
341 # Numbering for Appendix B
342 $pdf->pageLabel( 36, {
343 -start => 1,
344 -prefix => 'B-'
345 });
346
347 # Numbering for the Index
348 $pdf->pageLabel(40, {
349 -style => 'Roman'
350 -start => 1,
351 -prefix => 'Index '
352 });
353
354 $pdf->finishobjects(@objects)
355 Force objects to be written to file if possible.
356
357 Example:
358
359 $pdf = PDF::Builder->new(-file => 'our/new.pdf');
360 ...
361 $pdf->finishobjects($page, $gfx, $txt);
362 ...
363 $pdf->save();
364
365 $pdf->update()
366 Saves a previously opened document.
367
368 Example:
369
370 $pdf = PDF::Builder->open('our/to/be/updated.pdf');
371 ...
372 $pdf->update();
373
374 $pdf->saveas($file)
375 Save the document to $file and remove the object structure from
376 memory.
377
378 Caution: Although the object $pdf will still exist, it is no longer
379 usable for any purpose after invoking this method! You will receive
380 error messages about "can't call method new_obj on an undefined
381 value".
382
383 Example:
384
385 $pdf = PDF::Builder->new();
386 ...
387 $pdf->saveas('our/new.pdf');
388
389 $pdf->save()
390 Save the document to an already-defined file (or filename) and
391 remove the object structure from memory.
392
393 Caution: Although the object $pdf will still exist, it is no longer
394 usable for any purpose after invoking this method! You will receive
395 error messages about "can't call method new_obj on an undefined
396 value".
397
398 Example:
399
400 $pdf = PDF::Builder->new(-file => 'file_to_output');
401 ...
402 $pdf->save();
403
404 $string = $pdf->stringify()
405 Return the document as a string and remove the object structure
406 from memory.
407
408 Caution: Although the object $pdf will still exist, it is no longer
409 usable for any purpose after invoking this method! You will receive
410 error messages about "can't call method new_obj on an undefined
411 value".
412
413 Example:
414
415 $pdf = PDF::Builder->new();
416 ...
417 print $pdf->stringify();
418
419 $pdf->end()
420 Remove the object structure from memory. PDF::Builder contains
421 circular references, so this call is necessary in long-running
422 processes to keep from running out of memory.
423
424 This will be called automatically when you save or stringify a PDF.
425 You should only need to call it explicitly if you are reading PDF
426 files and not writing them.
427
429 $page = $pdf->page()
430 $page = $pdf->page($page_number)
431 Returns a new page object. By default, the page is added to the
432 end of the document. If you give an existing page number, the new
433 page will be inserted in that position, pushing existing pages back
434 by 1 (e.g., page(5) would insert an empty page 5, with the old page
435 5 now page 6, etc.
436
437 If $page_number is -1, the new page is inserted as the second-last
438 page; if $page_number is 0, the new page is inserted as the last
439 page.
440
441 Example:
442
443 $pdf = PDF::Builder->new();
444
445 # Add a page. This becomes page 1.
446 $page = $pdf->page();
447
448 # Add a new first page. $page becomes page 2.
449 $another_page = $pdf->page(1);
450
451 $page = $pdf->openpage($page_number)
452 Returns the PDF::Builder::Page object of page $page_number. This
453 is similar to "$page = $pdf->page()", except that $page is not a
454 new, empty page; but contains the contents of that existing page.
455
456 If $page_number is 0 or -1, it will return the last page in the
457 document.
458
459 Example:
460
461 $pdf = PDF::Builder->open('our/99page.pdf');
462 $page = $pdf->openpage(1); # returns the first page
463 $page = $pdf->openpage(99); # returns the last page
464 $page = $pdf->openpage(-1); # returns the last page
465 $page = $pdf->openpage(999); # returns undef
466
467 $xoform = $pdf->importPageIntoForm($source_pdf, $source_page_number)
468 Returns a Form XObject created by extracting the specified page
469 from $source_pdf.
470
471 This is useful if you want to transpose the imported page somewhat
472 differently onto a page (e.g. two-up, four-up, etc.).
473
474 If $source_page_number is 0 or -1, it will return the last page in
475 the document.
476
477 Example:
478
479 $pdf = PDF::Builder->new();
480 $old = PDF::Builder->open('our/old.pdf');
481 $page = $pdf->page();
482 $gfx = $page->gfx();
483
484 # Import Page 2 from the old PDF
485 $xo = $pdf->importPageIntoForm($old, 2);
486
487 # Add it to the new PDF's first page at 1/2 scale
488 $gfx->formimage($xo, 0, 0, 0.5);
489
490 $pdf->saveas('our/new.pdf');
491
492 Note: You can only import a page from an existing PDF file.
493
494 $page = $pdf->import_page($source_pdf)
495 $page = $pdf->import_page($source_pdf, $source_page_number)
496 $page = $pdf->import_page($source_pdf, $source_page_number,
497 $target_page_number)
498 $page = $pdf->import_page($source_pdf, $source_page_number,
499 $target_page_object)
500 Imports a page from $source_pdf and adds it to the specified
501 position in $pdf.
502
503 If the $source_page_number is omitted, 0, or -1; the last page of
504 the source is imported. If the $target_page_number is omitted, 0,
505 or -1; the imported page will be placed as the new last page of the
506 target ($pdf). Otherwise, as with the "page()" method, the page
507 will be inserted before an existing page of that number.
508
509 Note: If you pass a page object instead of a page number for
510 $target_page_number, the contents of the page will be merged into
511 the existing page.
512
513 Example:
514
515 $pdf = PDF::Builder->new();
516 $old = PDF::Builder->open('our/old.pdf');
517
518 # Add page 2 from the old PDF as page 1 of the new PDF
519 $page = $pdf->import_page($old, 2);
520
521 $pdf->saveas('our/new.pdf');
522
523 Note: You can only import a page from an existing PDF file.
524
525 $count = $pdf->pages()
526 Returns the number of pages in the document.
527
528 $pdf->userunit($value)
529 Sets the global UserUnit, defining the scale factor to multiply any
530 size or coordinate by. For example, "userunit(72)" results in a
531 User Unit of 72 points, or 1 inch.
532
533 See "User Units" in PDF::Builder::Docs for more information.
534
535 $pdf->mediabox($name)
536 $pdf->mediabox($name, -orient => 'orientation')
537 $pdf->mediabox($w,$h)
538 $pdf->mediabox($llx,$lly, $urx,$ury)
539 ($llx,$lly, $urx,$ury) = $pdf->mediabox()
540 Sets (or gets) the global MediaBox, defining the width and height
541 (or by corner coordinates, or by standard name) of the output page
542 itself, such as the physical paper size.
543
544 See "Media Box" in PDF::Builder::Docs for more information. The
545 method always returns the current bounds (after any set operation).
546
547 $pdf->cropbox($name)
548 $pdf->cropbox($name, -orient => 'orientation')
549 $pdf->cropbox($w,$h)
550 $pdf->cropbox($llx,$lly, $urx,$ury)
551 ($llx,$lly, $urx,$ury) = $pdf->cropbox()
552 Sets (or gets) the global CropBox. This will define the media size
553 to which the output will later be clipped.
554
555 See "Crop Box" in PDF::Builder::Docs for more information. The
556 method always returns the current bounds (after any set operation).
557
558 $pdf->bleedbox($name)
559 $pdf->bleedbox($name, -orient => 'orientation')
560 $pdf->bleedbox($w,$h)
561 $pdf->bleedbox($llx,$lly, $urx,$ury)
562 ($llx,$lly, $urx,$ury) = $pdf->bleedbox()
563 Sets (or gets) the global BleedBox. This is typically used for hard
564 copy printing where you want ink to go to the edge of the cut
565 paper.
566
567 See "Bleed Box" in PDF::Builder::Docs for more information. The
568 method always returns the current bounds (after any set operation).
569
570 $pdf->trimbox($name)
571 $pdf->trimbox($name, -orient => 'orientation')
572 $pdf->trimbox($w,$h)
573 $pdf->trimbox($llx,$lly, $urx,$ury)
574 ($llx,$lly, $urx,$ury) = $pdf->trimbox()
575 Sets (or gets) the global TrimBox. This is supposed to be the
576 actual dimensions of the finished page (after trimming of the
577 paper).
578
579 See "Trim Box" in PDF::Builder::Docs for more information. The
580 method always returns the current bounds (after any set operation).
581
582 $pdf->artbox($name)
583 $pdf->artbox($name, -orient => 'orientation')
584 $pdf->artbox($w,$h)
585 $pdf->artbox($llx,$lly, $urx,$ury)
586 ($llx,$lly, $urx,$ury) = $pdf->artbox()
587 Sets (or gets) the global ArtBox. This is supposed to define "the
588 extent of the page's meaningful content".
589
590 See "Art Box" in PDF::Builder::Docs for more information. The
591 method always returns the current bounds (after any set operation).
592
594 @directories = PDF::Builder::addFontDirs($dir1, $dir2, ...)
595 Adds one or more directories to the search path for finding font
596 files.
597
598 Returns the list of searched directories.
599
600 $font = $pdf->corefont($fontname, %options)
601 $font = $pdf->corefont($fontname)
602 Returns a new Adobe core font object. For details, see "Core Fonts"
603 in PDF::Builder::Docs.
604
605 See also PDF::Builder::Resource::Font::CoreFont.
606
607 $font = $pdf->psfont($ps_file, %options)
608 $font = $pdf->psfont($ps_file)
609 Returns a new Adobe Type1 ("PostScript") font object. For details,
610 see "PS Fonts" in PDF::Builder::Docs.
611
612 See also PDF::Builder::Resource::Font::Postscript.
613
614 $font = $pdf->ttfont($ttf_file, %options)
615 $font = $pdf->ttfont($ttf_file)
616 Returns a new TrueType (or OpenType) font object. For details, see
617 "TrueType Fonts" in PDF::Builder::Docs.
618
619 $font = $pdf->cjkfont($cjkname, %options)
620 $font = $pdf->cjkfont($cjkname)
621 Returns a new CJK font object. These are TrueType-like fonts for
622 East Asian languages (Chinese, Japanese, Korean). For details, see
623 "CJK Fonts" in PDF::Builder::Docs.
624
625 See also PDF::Builder::Resource::CIDFont::CJKFont
626
627 $font = $pdf->synfont($basefont, %options)
628 $font = $pdf->synfont($basefont)
629 Returns a new synthetic font object. These are modifications to a
630 core (or PS/T1 or TTF/OTF) font, where the font may be replaced by
631 a Type1 or Type3 PostScript font. This does not appear to work
632 with CJK fonts (created with "cjkfont" method). For details, see
633 "Synthetic Fonts" in PDF::Builder::Docs.
634
635 See also PDF::Builder::Resource::Font::SynFont
636
637 $font = $pdf->bdfont($bdf_file, @options)
638 $font = $pdf->bdfont($bdf_file)
639 Returns a new BDF (bitmapped distribution format) font object,
640 based on the specified Adobe BDF file.
641
642 See also PDF::Builder::Resource::Font::BdFont
643
644 $font = $pdf->unifont(@fontspecs, %options)
645 $font = $pdf->unifont(@fontspecs)
646 Returns a new uni-font object, based on the specified fonts and
647 options.
648
649 BEWARE: This is not a true PDF-object, but a virtual/abstract font
650 definition!
651
652 See also PDF::Builder::Resource::UniFont.
653
654 Valid %options are:
655
656 -encode
657 Changes the encoding of the font from its default.
658
660 $jpeg = $pdf->image_jpeg($file)
661 Imports and returns a new JPEG image object. $file may be either a
662 filename or a filehandle.
663
664 See PDF::Builder::Resource::XObject::Image::JPEG for additional
665 information and "examples/Content.pl" for some examples of placing
666 an image on a page.
667
668 $tiff = $pdf->image_tiff($file, %opts)
669 $tiff = $pdf->image_tiff($file)
670 Imports and returns a new TIFF image object. $file may be either a
671 filename or a filehandle. For details, see "TIFF Images" in
672 PDF::Builder::Docs.
673
674 See PDF::Builder::Resource::XObject::Image::TIFF and
675 PDF::Builder::Resource::XObject::Image::TIFF_GT for additional
676 information and "examples/Content.pl" for some examples of placing
677 an image on a page (JPEG, but the principle is the same). There is
678 an optional TIFF library described, that gives more capability than
679 the default one.
680
681 $rc = $pdf->LA_GT()
682 Returns 1 if the library name (package) Graphics::TIFF is
683 installed, and 0 otherwise. For this optional library, this call
684 can be used to know if it is safe to use certain functions. For
685 example:
686
687 if ($pdf->LA_GT() {
688 # is installed and usable
689 } else {
690 # not available. you will be running the old, pure PERL code
691 }
692
693 $pnm = $pdf->image_pnm($file)
694 Imports and returns a new PNM image object. $file may be either a
695 filename or a filehandle.
696
697 See "examples/Content.pl" for some examples of placing an image on
698 a page (JPEG, but the principle is the same).
699
700 $png = $pdf->image_png($file, %options)
701 $png = $pdf->image_png($file)
702 Imports and returns a new PNG image object. $file may be either a
703 filename or a filehandle. For details, see "PNG Images" in
704 PDF::Builder::Docs.
705
706 See PDF::Builder::Resource::XObject::Image::PNG and
707 PDF::Builder::Resource::XObject::Image::PNG_IPL for additional
708 information and "examples/Content.pl" for some examples of placing
709 an image on a page (JPEG, but the principle is the same). There is
710 an optional PNG library (PNG_IPL) described, that gives more
711 capability than the default one.
712
713 $rc = $pdf->LA_IPL()
714 Returns 1 if the library name (package) Image::PNG::Libpng is
715 installed, and 0 otherwise. For this optional library, this call
716 can be used to know if it is safe to use certain functions. For
717 example:
718
719 if ($pdf->LA_IPL() {
720 # is installed and usable
721 } else {
722 # not available. don't use 16bps or interlaced PNG image files
723 }
724
725 $gif = $pdf->image_gif($file)
726 Imports and returns a new GIF image object. $file may be either a
727 filename or a filehandle.
728
729 See PDF::Builder::Resource::XObject::Image::GIF for additional
730 information and "examples/Content.pl" for some examples of placing
731 an image on a page (JPEG, but the principle is the same).
732
733 $gdf = $pdf->image_gd($gd_object, %options)
734 $gdf = $pdf->image_gd($gd_object)
735 Imports and returns a new image object from Image::GD.
736
737 Valid %options are:
738
739 -lossless => 1
740 Use lossless compression.
741
742 See PDF::Builder::Resource::XObject::Image::GD for additional
743 information and "examples/Content.pl" for some examples of placing
744 an image on a page (JPEG, but the principle is the same).
745
747 $cs = $pdf->colorspace_act($file)
748 Returns a new colorspace object based on an Adobe Color Table file.
749
750 See PDF::Builder::Resource::ColorSpace::Indexed::ACTFile for a
751 reference to the file format's specification.
752
753 $cs = $pdf->colorspace_web()
754 Returns a new colorspace-object based on the "web-safe" color
755 palette.
756
757 $cs = $pdf->colorspace_hue()
758 Returns a new colorspace-object based on the hue color palette.
759
760 See PDF::Builder::Resource::ColorSpace::Indexed::Hue for an
761 explanation.
762
763 $cs = $pdf->colorspace_separation($tint, $color)
764 Returns a new separation colorspace object based on the parameters.
765
766 $tint can be any valid ink identifier, including but not limited
767 to: 'Cyan', 'Magenta', 'Yellow', 'Black', 'Red', 'Green', 'Blue' or
768 'Orange'.
769
770 $color must be a valid color specification limited to: '#rrggbb',
771 '!hhssvv', '%ccmmyykk' or a "named color" (rgb).
772
773 The colorspace model will automatically be chosen based on the
774 specified color.
775
776 $cs = $pdf->colorspace_devicen(\@tintCSx, $samples)
777 $cs = $pdf->colorspace_devicen(\@tintCSx)
778 Returns a new DeviceN colorspace object based on the parameters.
779
780 Example:
781
782 $cy = $pdf->colorspace_separation('Cyan', '%f000');
783 $ma = $pdf->colorspace_separation('Magenta', '%0f00');
784 $ye = $pdf->colorspace_separation('Yellow', '%00f0');
785 $bk = $pdf->colorspace_separation('Black', '%000f');
786
787 $pms023 = $pdf->colorspace_separation('PANTONE 032CV', '%0ff0');
788
789 $dncs = $pdf->colorspace_devicen( [ $cy,$ma,$ye,$bk, $pms023 ] );
790
791 The colorspace model will automatically be chosen based on the
792 first colorspace specified.
793
795 These are glue routines to the actual barcode rendering routines found
796 elsewhere.
797
798 $bc = $pdf->xo_codabar(%options)
799 $bc = $pdf->xo_code128(%options)
800 $bc = $pdf->xo_2of5int(%options)
801 $bc = $pdf->xo_3of9(%options)
802 $bc = $pdf->xo_ean13(%options)
803 Creates the specified barcode object as a form XObject.
804
806 $xo = $pdf->xo_form()
807 Returns a new form XObject.
808
809 $egs = $pdf->egstate()
810 Returns a new extended graphics state object.
811
812 $obj = $pdf->pattern(%options)
813 $obj = $pdf->pattern()
814 Returns a new pattern object.
815
816 $obj = $pdf->shading(%options)
817 $obj = $pdf->shading()
818 Returns a new shading object.
819
820 $otls = $pdf->outlines()
821 Returns a new or existing outlines object.
822
823 $ndest = $pdf->named_destination()
824 Returns a new or existing named destination object.
825
826
827
828perl v5.32.1 2021-03-29 PDF::Builder(3)