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->open_page($page_number);
22
23 # Set the page size
24 $page->size('Letter'); # or mediabox('Letter')
25
26 # Add a built-in font to the PDF
27 $font = $pdf->font('Helvetica-Bold'); # or corefont('Helvetica-Bold')
28
29 # Add an external TrueType (TTF) font to the PDF
30 $font = $pdf->font('/path/to/font.ttf'); # or ttfont() in this case
31
32 # Add some text to the page
33 $text = $page->text();
34 $text->font($font, 20);
35 $text->position(200, 700); # or translate()
36 $text->text('Hello World!');
37
38 # Save the PDF
39 $pdf->saveas('/path/to/new.pdf');
40
42 See the file README.md (in downloadable package and on CPAN) for a
43 summary 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 (BACKWARDS COMPATIBILITY GOALS)
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.
86
87 Anticipated Support Cutoff Dates
88
89 • 5.24 current minimum supported version, until next PDF::Builder
90 release after 30 May, 2023
91
92 • 5.26 future minimum supported version, until next PDF::Builder
93 release after 23 June, 2024
94
95 • 5.28 future minimum supported version, until next PDF::Builder
96 release after 22 May, 2025
97
98 • 5.30 future minimum supported version, until next PDF::Builder
99 release after 20 June, 2026
100
101 • 5.32 future minimum supported version, until next PDF::Builder
102 release after 20 May, 2027
103
104 • 5.34 future minimum supported version, until next PDF::Builder
105 release after 28 May, 2028
106
107 If you need to use this module on a server with an extremely out-of-
108 date version of Perl, consider using either plenv or Perlbrew to run a
109 newer version of Perl without needing admin privileges.
110
111 On the other hand, any feature in PDF::Builder should continue to work
112 unchanged for the life of most long-term-stable (LTS) server
113 distributions. Their lifetime is usually about six (6) years. Note
114 that this does not constitute a statement of warranty, but that we
115 intend to try to keep any particular release of PDF::Builder working
116 for a period of years. Of course, it helps if you periodically update
117 your Perl installation to something released in the recent past.
118
119 KNOWN ISSUES
120 This module does not work with perl's -l command-line switch.
121
122 There is a file INFO/KNOWN_INCOMP which lists known incompatibilities
123 with PDF::API2, in case you're thinking of porting over something from
124 that world, or have experience there and want to try PDF::Builder.
125 There is also a file INFO/DEPRECATED, which lists things which are
126 planned to be removed at some point.
127
128 HISTORY
129 The history of PDF::Builder is a complex and exciting saga... OK, it
130 may be mildly interesting. Have a look at "History" in
131 PDF::Builder::Docs section.
132
133 AUTHOR
134 PDF::API2 was originally written by Alfred Reibenschuh. See the HISTORY
135 section for more information.
136
137 It was maintained by Steve Simms, who is still contributing new code to
138 it (which often ends up in PDF::Builder).
139
140 PDF::Builder is currently being maintained by Phil M. Perry.
141
142 SUPPORT
143 The full source is on https://github.com/PhilterPaper/Perl-PDF-Builder.
144
145 The release distribution is on CPAN:
146 https://metacpan.org/pod/PDF::Builder.
147
148 Bug reports are on
149 https://github.com/PhilterPaper/Perl-PDF-Builder/issues?q=is%3Aissue+sort%3Aupdated-desc
150 (with "bug" label), feature requests have an "enhancement" label, and
151 general discussions (architecture, roadmap, etc.) have a "general
152 discussion" label.
153
154 Do not under any circumstances open a PR (Pull Request) to report a
155 bug. It is a waste of both your and our time and effort. Open a
156 regular ticket (issue), and attach a Perl (.pl) program illustrating
157 the problem, if possible. If you believe that you have a program
158 patch, and offer to share it as a PR, we may give the go-ahead.
159 Unsolicited PRs may be closed without further action.
160
161 LICENSE
162 This software is Copyright (c) 2017-2022 by Phil M. Perry.
163
164 This is free software, licensed under:
165
166 The GNU Lesser General Public License (LGPL) Version 2.1, February 1999
167
168 (The master copy of this license lives on the GNU website.)
169 (A copy is provided in the INFO/LICENSE file for your convenience.)
170
171 This section of Builder.pm is intended only as a very brief summary of
172 the license; please consider INFO/LICENSE to be the controlling
173 version, if there is any conflict or ambiguity between the two.
174
175 This program is free software; you can redistribute it and/or modify it
176 under the terms of the GNU Lesser General Public License, as published
177 by the Free Software Foundation, either version 2.1 of the License, or
178 (at your option) any later version of this license.
179
180 NOTE: there are several files in this distribution which were
181 incorporated from outside sources and carry different licenses. If a
182 file states that it is under a license different than LGPL 2.1, that
183 license and its terms will apply to that file, and not LGPL 2.1.
184
185 This library is distributed in the hope that it will be useful, but
186 WITHOUT ANY WARRANTY; without even the implied warranty of
187 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
188 General Public License for more details.
189
191 $pdf = PDF::Builder->new(%opts)
192 Creates a new PDF object.
193
194 Options
195
196 file
197 If you will be saving it as a file and already know the
198 filename, you can give the 'file' option to minimize possible
199 memory requirements later on (the file is opened immediately
200 for writing, rather than waiting until the "save"). The "file"
201 may also be a filehandle.
202
203 compress
204 The 'compress' option can be given to specify stream
205 compression: default is 'flate', 'none' (or 0) is no
206 compression. No other compression methods are currently
207 supported.
208
209 outver
210 The 'outver' option defaults to 1.4 as the output PDF version
211 and the highest allowed feature version (attempts to use
212 anything higher will give a warning). If an existing PDF with
213 a higher version is read in, "outver" will be increased to that
214 version, with a warning.
215
216 msgver
217 The 'msgver' option value of 1 (default) gives a warning
218 message if the 'outver' PDF level has to be bumped up due to
219 either a higher PDF level file being read in, or a higher level
220 feature was requested. A value of 0 suppresses the warning
221 message.
222
223 diaglevel
224 The 'diaglevel' option can be given to specify the level of
225 diagnostics given by IntegrityCheck(). The default is level 2
226 (errors and warnings). See "IntegrityCheck" in
227 PDF::Builder::Docs for more information.
228
229 Example:
230
231 $pdf = PDF::Builder->new();
232 ...
233 print $pdf->to_string();
234
235 $pdf = PDF::Builder->new(compress => 'none');
236 # equivalent to $pdf->{'forcecompress'} = 'none'; (or older, 0)
237
238 $pdf = PDF::Builder->new();
239 ...
240 $pdf->saveas('our/new.pdf');
241
242 $pdf = PDF::Builder->new(file => 'our/new.pdf');
243 ...
244 $pdf->save();
245
246 $pdf->default_page_size($size); # Set
247 @rectangle = $pdf->default_page_size() # Get
248 Set the default physical size for pages in the PDF. If called
249 without arguments, return the coordinates of the rectangle
250 describing the default physical page size.
251
252 This is essentially an alternate method of defining the
253 "mediabox()" call, and added for compatibility with PDF::API2.
254
255 See "Page Sizes" in PDF::Builder::Page for possible values.
256
257 $pdf->default_page_boundaries(%boundaries); # Set
258 %boundaries = $pdf->default_page_boundaries(); # Get
259 Set default prepress page boundaries for pages in the PDF. If
260 called without arguments, returns the coordinates of the rectangles
261 describing each of the supported page boundaries.
262
263 See the equivalent "page_boundaries" method in PDF::Builder::Page
264 for details.
265
267 $pdf = PDF::Builder->open($pdf_file, %opts)
268 Opens an existing PDF file. See "new()" for options.
269
270 Example:
271
272 $pdf = PDF::Builder->open('our/old.pdf');
273 ...
274 $pdf->saveas('our/new.pdf');
275
276 $pdf = PDF::Builder->open('our/to/be/updated.pdf');
277 ...
278 $pdf->update();
279
280 $pdf = PDF::Builder->from_string($pdf_string, %opts)
281 Opens a PDF contained in a string. See "new()" for other options.
282
283 diags => 1
284 Display warnings when non-conforming PDF structure is found,
285 and fix up where possible. See PDF::Builder::Basic::PDF::File
286 for more information.
287
288 Example:
289
290 # Read a PDF into a string, for the purpose of demonstration
291 open $fh, 'our/old.pdf' or die $@;
292 undef $/; # Read the whole file at once
293 $pdf_string = <$fh>;
294
295 $pdf = PDF::Builder->from_string($pdf_string);
296 ...
297 $pdf->saveas('our/new.pdf');
298
299 Alternate name: "open_scalar"
300
301 "from_string" was formerly known as "open_scalar" (and even before
302 that, as "openScalar"), and this older name is still valid as an
303 alternative to "from_string". It is possible that "open_scalar"
304 will be deprecated and then removed some time in the future, so it
305 may be advisable to use "from_string" in new work.
306
307 $string = $pdf->to_string()
308 Return the document as a string and remove the object structure
309 from memory.
310
311 Caution: Although the object $pdf will still exist, it is no longer
312 usable for any purpose after invoking this method! You will receive
313 error messages about "can't call method new_obj on an undefined
314 value".
315
316 Example:
317
318 $pdf = PDF::Builder->new();
319 ...
320 print $pdf->to_string();
321
322 Alternate name: "stringify"
323
324 "to_string" was formerly known as "stringify", and this older name
325 is still valid as an alternative to "to_string". It is possible
326 that "stringify" will be deprecated and then removed some time in
327 the future, so it may be advisable to use "to_string" in new work.
328
329 $pdf->finishobjects(@objects)
330 Force objects to be written to file if possible.
331
332 Example:
333
334 $pdf = PDF::Builder->new(file => 'our/new.pdf');
335 ...
336 $pdf->finishobjects($page, $gfx, $txt);
337 ...
338 $pdf->save();
339
340 Note: this method is now considered obsolete, and may be
341 deprecated. It allows for objects to be written to disk in advance
342 of finally saving and closing the file. Otherwise, it's no
343 different than just calling "save()" when all changes have been
344 made. There's no memory advantage since "ship_out" doesn't remove
345 objects from memory.
346
347 $pdf->update()
348 Saves a previously opened document.
349
350 Example:
351
352 $pdf = PDF::Builder->open('our/to/be/updated.pdf');
353 ...
354 $pdf->update();
355
356 Note: it is considered better to simply "save()" the file, rather
357 than calling "update()". They end up doing the same thing, anyway.
358 This method may be deprecated in the future.
359
360 $pdf->saveas($file)
361 Save the document to $file and remove the object structure from
362 memory.
363
364 Caution: Although the object $pdf will still exist, it is no longer
365 usable for any purpose after invoking this method! You will receive
366 error messages about "can't call method new_obj on an undefined
367 value".
368
369 Example:
370
371 $pdf = PDF::Builder->new();
372 ...
373 $pdf->saveas('our/new.pdf');
374
375 $pdf->save()
376 $pdf->save(filename)
377 Save the document to an already-defined file (or filename) and
378 remove the object structure from memory. Optionally, a new
379 filename may be given.
380
381 Caution: Although the object $pdf will still exist, it is no longer
382 usable for any purpose after invoking this method! You will receive
383 error messages about "can't call method new_obj on an undefined
384 value".
385
386 Example:
387
388 $pdf = PDF::Builder->new(file => 'file_to_output');
389 ...
390 $pdf->save();
391
392 Note: now that "save()" can take a filename as an argument, it
393 effectively is interchangeable with "saveas()". This is strictly
394 for compatibility with recent changes to PDF::API2. Unlike
395 PDF::API2, we are not deprecating the "saveas()" method, because in
396 user interfaces, "save" normally means that the current filename is
397 known and is to be used, while "saveas" normally means that
398 (whether or not there is a current filename) a new filename is to
399 be used.
400
401 $pdf->close();
402 Close an open file (if relevant) and remove the object structure
403 from memory.
404
405 PDF::API2 contains circular references, so this call is necessary
406 in long-running processes to keep from running out of memory.
407
408 This will be called automatically when you save or stringify a PDF.
409 You should only need to call it explicitly if you are reading PDF
410 files and not writing them.
411
412 Alternate names: "release" and "end"
413
414 $pdf->end()
415 Remove the object structure from memory. PDF::Builder contains
416 circular references, so this call is necessary in long-running
417 processes to keep from running out of memory.
418
419 This will be called automatically when you save or to_string a PDF.
420 You should only need to call it explicitly if you are reading PDF
421 files and not writing them.
422
423 This (and release) are older and now deprecated names formerly used
424 in PDF::API2 and PDF::Builder. You should try to avoid having to
425 explicitly call them.
426
427 METADATA METHODS
428 $title = $pdf->title();
429 $pdf = $pdf->title($title);
430 Get/set/clear the document's title.
431
432 $author = $pdf->author();
433 $pdf = $pdf->author($author);
434 Get/set/clear the name of the person who created the document.
435
436 $subject = $pdf->subject();
437 $pdf = $pdf->subject($subject);
438 Get/set/clear the subject of the document.
439
440 $keywords = $pdf->keywords();
441 $pdf = $pdf->keywords($keywords);
442 Get/set/clear a space-separated string of keywords associated with
443 the document.
444
445 $creator = $pdf->creator();
446 $pdf = $pdf->creator($creator);
447 Get/set/clear the name of the product that created the document
448 prior to its conversion to PDF.
449
450 $producer = $pdf->producer();
451 $pdf = $pdf->producer($producer);
452 Get/set/clear the name of the product that converted the original
453 document to PDF.
454
455 PDF::Builder fills in this field when creating a PDF.
456
457 $date = $pdf->created();
458 $pdf = $pdf->created($date);
459 Get/set/clear the document's creation date.
460
461 The date format is "D:YYYYMMDDHHmmSSOHH'mm", where "D:" is a static
462 prefix identifying the string as a PDF date. The date may be
463 truncated at any point after the year. "O" is one of "+", "-", or
464 "Z", with the following "HH'mm" representing an offset from UTC.
465
466 When setting the date, "D:" will be prepended automatically if
467 omitted.
468
469 $date = $pdf->modified();
470 $pdf = $pdf->modified($date);
471 Get/set/clear the document's modification date. The date format is
472 as described in "created" above.
473
474 %info = $pdf->info_metadata(); # Get all keys and values
475 $value = $pdf->info_metadata($key); # Get the value of one key
476 $pdf = $pdf->info_metadata($key, $value); # Set the value of one key
477 Get/set/clear a key in the document's information dictionary. The
478 standard keys (title, author, etc.) have their own accessors, so
479 this is primarily intended for interacting with custom metadata.
480
481 Pass "undef" as the value in order to remove the key from the
482 dictionary.
483
484 %infohash = $pdf->info()
485 %infohash = $pdf->info(%infohash)
486 Gets/sets the info structure of the document.
487
488 See "info Example" in PDF::Builder::Docs section for an example of
489 the use of this method.
490
491 Note: this method is still available, for compatibility purposes.
492 It is better to use individual accessors or "info_metadata"
493 instead.
494
495 @metadata_attributes = $pdf->infoMetaAttributes()
496 @metadata_attributes = $pdf->infoMetaAttributes(@metadata_attributes)
497 Gets/sets the supported info-structure tags.
498
499 Example:
500
501 @attributes = $pdf->infoMetaAttributes;
502 print "Supported Attributes: @attr\n";
503
504 @attributes = $pdf->infoMetaAttributes('CustomField1');
505 print "Supported Attributes: @attributes\n";
506
507 Note: this method is still available for compatibility purposes,
508 but the use of "info_metadata" instead is encouraged.
509
510 $xml = $pdf->xml_metadata();
511 $pdf = $pdf->xml_metadata($xml);
512 Gets/sets the document's XML metadata stream.
513
514 $xml = $pdf->xmpMetadata() # Get
515 $xml = $pdf->xmpMetadata($xml) # Set (also returns $xml value)
516 Gets/sets the XMP XML data stream.
517
518 See "XMP XML example" in PDF::Builder::Docs section for an example
519 of the use of this method.
520
521 This method is considered obsolete. Use "xml_metadata" instead.
522
523 $val = $pdf->default($parameter)
524 $pdf->default($parameter, $value)
525 Gets/sets the default value for a behavior of PDF::Builder.
526
527 Supported Parameters:
528
529 nounrotate
530 prohibits Builder from rotating imported/opened page to re-
531 create a default pdf-context.
532
533 pageencaps
534 enables Builder's adding save/restore commands upon
535 importing/opening pages to preserve graphics-state for
536 modification.
537
538 copyannots
539 enables importing of annotations (*EXPERIMENTAL*).
540
541 CAUTION: Perl::Critic (tools/1_pc.pl) has started flagging the name
542 "default" as a reserved keyword in higher Perl versions. Use with
543 caution, and be aware that this name may have to be changed in the
544 future.
545
546 $version = $pdf->version() # Get
547 $version = $pdf->version($version) # Set (also returns newly set
548 version)
549 Gets/sets the PDF version (e.g., 1.5). For compatibility with
550 earlier releases, if no decimal point is given, assume "1."
551 precedes the number given.
552
553 A warning message is given if you attempt to decrease the PDF
554 version, as you might have already read in a higher level file, or
555 used a higher level feature.
556
557 See PDF::Builder::Basic::PDF::File for additional information on
558 the "version" method.
559
560 $bool = $pdf->is_encrypted()
561 Checks if the previously opened PDF is encrypted.
562
563 Alternate name: "isEncrypted"
564
565 This is the older name; it is kept for compatibility with
566 PDF::API2.
567
569 $otls = $pdf->outline()
570 Creates (if needed) and returns the document's 'outline' tree,
571 which is also known as its 'bookmarks' or the 'table of contents',
572 depending on the PDF reader being used.
573
574 To examine or modify the outline tree, see PDF::Builder::Outlines.
575
576 Alternate name: "outlines"
577
578 This is the older name; it is kept for compatibility.
579
580 $pdf = $pdf->open_action($page, $location, @args);
581 Set the destination in the PDF that should be displayed when the
582 document is opened.
583
584 $page may be either a page number or a page object. The other
585 parameters are as described in PDF::Builder::NamedDestination.
586
587 This has been split out from "preferences()" for compatibility with
588 PDF::API2. It also can both set (assign) and get (query) the
589 settings used.
590
591 $layout = $pdf->page_layout();
592 $pdf = $pdf->page_layout($layout);
593 Gets/sets the page layout that should be used when the PDF is
594 opened.
595
596 $layout is one of the following:
597
598 single_page (or undef)
599 Display one page at a time.
600
601 one_column
602 Display the pages in one column (a.k.a. continuous).
603
604 two_column_left
605 Display the pages in two columns, with odd-numbered pages on
606 the left.
607
608 two_column_right
609 Display the pages in two columns, with odd-numbered pages on
610 the right.
611
612 two_page_left
613 Display two pages at a time, with odd-numbered pages on the
614 left.
615
616 two_page_right
617 Display two pages at a time, with odd-numbered pages on the
618 right.
619
620 This has been split out from "preferences()" for compatibility with
621 PDF::API2. It also can both set (assign) and get (query) the
622 settings used.
623
624 $mode = $pdf->page_mode(); # Get
625 $pdf = $pdf->page_mode($mode); # Set
626 Gets/sets the page mode, which describes how the PDF should be
627 displayed when opened.
628
629 $mode is one of the following:
630
631 none (or undef)
632 Neither outlines nor thumbnails should be displayed.
633
634 outlines
635 Show the document outline.
636
637 thumbnails
638 Show the page thumbnails.
639
640 full_screen
641 Open in full-screen mode, with no menu bar, window controls, or
642 any other window visible.
643
644 optional_content
645 Show the optional content group panel.
646
647 attachments
648 Show the attachments panel.
649
650 This has been split out from "preferences()" for compatibility with
651 PDF::API2. It also can both set (assign) and get (query) the
652 settings used.
653
654 %preferences = $pdf->viewer_preferences(); # Get
655 $pdf = $pdf->viewer_preferences(%preferences); # Set
656 Gets/sets PDF viewer preferences, as described in
657 PDF::Builder::ViewerPreferences.
658
659 This has been split out from "preferences()" for compatibility with
660 PDF::API2. It also can both set (assign) and get (query) the
661 settings used.
662
663 $pdf->preferences(%opts)
664 Controls viewing preferences for the PDF, including the Page Mode,
665 Page Layout, Viewer, and Initial Page Options. See "Preferences -
666 set user display preferences" in PDF::Builder::Docs for details on
667 all these option groups, and "Page Fit Options" in
668 PDF::Builder::Docs for page positioning.
669
670 Note: the various preferences have been split out into their own
671 methods. It is preferred that you use these specific methods.
672
674 $page = $pdf->page()
675 $page = $pdf->page($page_number)
676 Returns a new page object. By default, the page is added to the
677 end of the document. If you give an existing page number, the new
678 page will be inserted in that position, pushing existing pages back
679 by 1 (e.g., page(5) would insert an empty page 5, with the old page
680 5 now page 6, etc.
681
682 If $page_number is -1, the new page is inserted as the second-to-
683 last page; if $page_number is 0, the new page is inserted as the
684 last page.
685
686 Example:
687
688 $pdf = PDF::Builder->new();
689
690 # Add a page. This becomes page 1.
691 $page = $pdf->page();
692
693 # Add a new first page. $page becomes page 2.
694 $another_page = $pdf->page(1);
695
696 $page = $pdf->open_page($page_number)
697 Returns the PDF::Builder::Page object of page $page_number. This
698 is similar to "$page = $pdf->page()", except that $page is not a
699 new, empty page; but contains the contents of that existing page.
700
701 If $page_number is 0 or -1, it will return the last page in the
702 document.
703
704 Example:
705
706 $pdf = PDF::Builder->open('our/99page.pdf');
707 $page = $pdf->open_page(1); # returns the first page
708 $page = $pdf->open_page(99); # returns the last page
709 $page = $pdf->open_page(-1); # returns the last page
710 $page = $pdf->open_page(999); # returns undef
711
712 Alternate name: "openpage"
713
714 This is the older name; it is kept for compatibility until after
715 June 2023 (deprecated, as previously announced).
716
717 $page = $pdf->import_page($source_pdf)
718 $page = $pdf->import_page($source_pdf, $source_page_number)
719 $page = $pdf->import_page($source_pdf, $source_page_number,
720 $target_page_number)
721 $page = $pdf->import_page($source_pdf, $source_page_number,
722 $target_page_object)
723 Imports a page from $source_pdf and adds it to the specified
724 position in $pdf.
725
726 If the $source_page_number is omitted, 0, or -1; the last page of
727 the source is imported. If the $target_page_number is omitted, 0,
728 or -1; the imported page will be placed as the new last page of the
729 target ($pdf). Otherwise, as with the "page()" method, the page
730 will be inserted before an existing page of that number.
731
732 Note: If you pass a page object instead of a page number for
733 $target_page_number, the contents of the page will be merged into
734 the existing page.
735
736 Example:
737
738 my $pdf = PDF::Builder->new();
739 my $source = PDF::Builder->open('source.pdf');
740
741 # Add page 2 from the old PDF as page 1 of the new PDF
742 my $page = $pdf->import_page($source, 2);
743
744 $pdf->saveas('sample.pdf');
745
746 Note: You can only import a page from an existing PDF file.
747
748 $xoform = $pdf->embed_page($source_pdf, $source_page_number)
749 Returns a Form XObject created by extracting the specified page
750 from $source_pdf.
751
752 This is useful if you want to transpose the imported page somewhat
753 differently onto a page (e.g. two-up, four-up, etc.).
754
755 If $source_page_number is 0 or -1, it will return the last page in
756 the document.
757
758 Example:
759
760 my $pdf = PDF::Builder->new();
761 my $source = PDF::Builder->open('source.pdf');
762 my $page = $pdf->page();
763
764 # Import Page 2 from the source PDF
765 my $object = $pdf->embed_page($source, 2);
766
767 # Add it to the new PDF's first page at 1/2 scale
768 my ($x, $y) = (0, 0);
769 $page->object($xo, $x, $y, 0.5);
770
771 $pdf->save('sample.pdf');
772
773 Note: You can only import a page from an existing PDF file.
774
775 Alternate name: "importPageIntoForm"
776
777 This is the older name; it is kept for compatibility.
778
779 $count = $pdf->page_count()
780 Returns the number of pages in the document.
781
782 Alternate name: "pages"
783
784 This is the old name; it is kept for compatibility.
785
786 $pdf->page_labels($page_number, $opts)
787 Sets page label numbering format, for the Reader's page-selection
788 slider thumb (not the outline/bookmarks). At this time, there is no
789 method to automatically synchronize a page's label with the
790 outline/bookmarks, or to somewhere on the printed page.
791
792 Note that many PDF Readers ignore these settings, and (at most)
793 simply give you the physical page number 1, 2, 3,... instead of the
794 page label specified here.
795
796 # Generate a 30-page PDF
797 my $pdf = PDF::Builder->new();
798 $pdf->page() for 1..30;
799
800 # Number pages i to v, 1 to 20, and A-1 to A-5, respectively
801 $pdf->page_labels(1, 'style' => 'roman');
802 $pdf->page_labels(6, 'style' => 'decimal');
803 $pdf->page_labels(26, 'style' => 'decimal', 'prefix' => 'A-');
804
805 $pdf->save('sample.pdf');
806
807 Supported Options:
808
809 style
810 Roman (I,II,III,...), roman (i,ii,iii,...), decimal
811 (1,2,3,...), Alpha (A,B,C,...), alpha (a,b,c,...), or
812 nocounter. This is the styling of the counter part of the label
813 (unless "nocounter", in which case there is no counter output).
814
815 start
816 (Re)start numbering the counter at given page number (this is a
817 decimal integer, not the styled counter). By default it starts
818 at 1, and resets to 1 at each call to "page_labels()"! You need
819 to explicitly give "start" if you want to continue counting at
820 the current page number when you call "page_labels()", whether
821 or not you are changing the format.
822
823 Also note that the counter starts at physical page 1, while the
824 page $index number in the "page_labels()" call (as well as the
825 PDF PageLabels dictionary) starts at logical page (index) 0.
826
827 prefix
828 Text prefix for numbering, such as an Appendix letter B-. If
829 "style" is nocounter, just this text is used, otherwise a
830 styled counter will be appended. If "style" is omitted,
831 remember that it will default to a decimal number, which will
832 be appended to the prefix.
833
834 According to the Adobe/ISO PDF specification, a prefix of
835 'Content' has a special meaning, in that any /S counter is
836 ignored and only that text is used. However, this appears to
837 be ignored (use a style of nocounter to suppress the counter).
838
839 Example:
840
841 # Start with lowercase Roman Numerals at the 1st page, starting with i (1)
842 $pdf->page_labels(0,
843 'style' => 'roman',
844 );
845
846 # Switch to Arabic (decimal) at the 5th page, starting with 1
847 $pdf->page_labels(4,
848 'style' => 'decimal',
849 );
850
851 # invalid style at the 25th page, should just continue
852 # with decimal at the current counter
853 $pdf->page_labels(24,
854 'style' => 'raman_noodles', # fail over to decimal
855 # note that PDF::API2 will see the 'r' and treat it as 'roman'
856 'start' => 21, # necessary, otherwise would restart at 1
857 );
858
859 # No page label at the 31st and 32nd pages. Note that this could be
860 # confusing to the person viewing the PDF, but may be appropriate if
861 # the page itself has no numbering.
862 $pdf->page_labels(30,
863 'style' => 'nocounter',
864 );
865
866 # Numbering for Appendix A at the 33rd page, A-1, A-2,...
867 $pdf->page_labels(32,
868 'start' => 1, # unnecessary
869 'prefix' => 'A-'
870 );
871
872 # Numbering for Appendix B at the 37th page, B-1, B-2,...
873 $pdf->page_labels( 36,
874 'prefix' => 'B-'
875 );
876
877 # Numbering for the Index at the 41st page, Index I, Index II,...
878 $pdf->page_labels(40,
879 'style' => 'Roman',
880 'start' => 1, # unnecessary
881 'prefix' => 'Index ' # note trailing space
882 );
883
884 # Unnumbered 'Index' at the 45th page, Index, Index,...
885 $pdf->page_labels(40,
886 'style' => 'nocounter',
887 'prefix' => 'Index '
888 );
889
890 Alternate name: "pageLabel"
891
892 This old method name is retained for compatibility with old user
893 code. Note that with "pageLabel", you need to make the "options"
894 list an anonymous hash by placing { } around the entire list, even
895 if it has only one item in it.
896
897 $pdf->userunit($value)
898 Sets the global UserUnit, defining the scale factor to multiply any
899 size or coordinate by. For example, "userunit(72)" results in a
900 User Unit of 72 points, or 1 inch.
901
902 See "User Units" in PDF::Builder::Docs for more information.
903
904 $pdf->mediabox($name)
905 $pdf->mediabox($name, 'orient' => 'orientation')
906 $pdf->mediabox($w,$h)
907 $pdf->mediabox($llx,$lly, $urx,$ury)
908 ($llx,$lly, $urx,$ury) = $pdf->mediabox()
909 Sets (or gets) the global MediaBox, defining the width and height
910 (or by corner coordinates, or by standard name) of the output page
911 itself, such as the physical paper size.
912
913 See "Media Box" in PDF::Builder::Docs for more information. The
914 method always returns the current bounds (after any set operation).
915
916 $pdf->cropbox($name)
917 $pdf->cropbox($name, 'orient' => 'orientation')
918 $pdf->cropbox($w,$h)
919 $pdf->cropbox($llx,$lly, $urx,$ury)
920 ($llx,$lly, $urx,$ury) = $pdf->cropbox()
921 Sets (or gets) the global CropBox. This will define the media size
922 to which the output will later be clipped.
923
924 See "Crop Box" in PDF::Builder::Docs for more information. The
925 method always returns the current bounds (after any set operation).
926
927 $pdf->bleedbox($name)
928 $pdf->bleedbox($name, 'orient' => 'orientation')
929 $pdf->bleedbox($w,$h)
930 $pdf->bleedbox($llx,$lly, $urx,$ury)
931 ($llx,$lly, $urx,$ury) = $pdf->bleedbox()
932 Sets (or gets) the global BleedBox. This is typically used for hard
933 copy printing where you want ink to go to the edge of the cut
934 paper.
935
936 See "Bleed Box" in PDF::Builder::Docs for more information. The
937 method always returns the current bounds (after any set operation).
938
939 $pdf->trimbox($name)
940 $pdf->trimbox($name, 'orient' => 'orientation')
941 $pdf->trimbox($w,$h)
942 $pdf->trimbox($llx,$lly, $urx,$ury)
943 ($llx,$lly, $urx,$ury) = $pdf->trimbox()
944 Sets (or gets) the global TrimBox. This is supposed to be the
945 actual dimensions of the finished page (after trimming of the
946 paper).
947
948 See "Trim Box" in PDF::Builder::Docs for more information. The
949 method always returns the current bounds (after any set operation).
950
951 $pdf->artbox($name)
952 $pdf->artbox($name, 'orient' => 'orientation')
953 $pdf->artbox($w,$h)
954 $pdf->artbox($llx,$lly, $urx,$ury)
955 ($llx,$lly, $urx,$ury) = $pdf->artbox()
956 Sets (or gets) the global ArtBox. This is supposed to define "the
957 extent of the page's meaningful content".
958
959 See "Art Box" in PDF::Builder::Docs for more information. The
960 method always returns the current bounds (after any set operation).
961
963 $font = $pdf->corefont($fontname, %opts)
964 Returns a new Adobe core font object. For details, see "Core Fonts"
965 in PDF::Builder::Docs. Note that this is an Adobe-standard corefont
966 name, and not a file name.
967
968 See also PDF::Builder::Resource::Font::CoreFont.
969
970 $font = $pdf->psfont($ps_file, %opts)
971 Returns a new Adobe Type1 ("PostScript") font object. For details,
972 see "PS Fonts" in PDF::Builder::Docs.
973
974 See also PDF::Builder::Resource::Font::Postscript.
975
976 $font = $pdf->ttfont($ttf_file, %opts)
977 Returns a new TrueType (or OpenType) font object. For details, see
978 "TrueType Fonts" in PDF::Builder::Docs.
979
980 $font = $pdf->bdfont($bdf_file, @opts)
981 Returns a new BDF (bitmapped distribution format) font object,
982 based on the specified Adobe BDF file.
983
984 See also PDF::Builder::Resource::Font::BdFont
985
986 $font = $pdf->cjkfont($cjkname, %opts)
987 Returns a new CJK font object. These are TrueType-like fonts for
988 East Asian languages (Chinese, Japanese, Korean). For details, see
989 "CJK Fonts" in PDF::Builder::Docs.
990
991 NOTE: "cjkfont" is quite old and is not well supported. We
992 recommend that you try using "ttfont" (or another font routine, if
993 not TTF/OTF) with the appropriate CJK font file. Most appear to be
994 .ttf or .otf format. PDFs created using "cjkfont" may not be fully
995 portable, and support for "cjkfont" may be dropped in a future
996 release. We would appreciate hearing from you if you are
997 successfully using "cjkfont", and are unable to use "ttfont"
998 instead.
999
1000 Among other things, "cjkfont" selections are limited, as they
1001 require CMAP files; they may or may not subset correctly; and they
1002 can not be used as the base for synthetic fonts.
1003
1004 See also PDF::Builder::Resource::CIDFont::CJKFont
1005
1006 $font = $pdf->font($name, %opts)
1007 A convenience function to add a font to the PDF without having to
1008 specify the format. Returns the font object, to be used by
1009 PDF::Builder::Content.
1010
1011 The font $name is either the name of one of the standard 14 fonts
1012 ("STANDARD FONTS" in PDF::Builder::Resource::Font::CoreFont), such
1013 as Helvetica or the path to a font file. There are 15 additional
1014 core fonts on a Windows system. Note that the exact name of a core
1015 font needs to be given. The file extension (if path given)
1016 determines what type of font file it is.
1017
1018 my $pdf = PDF::Builder->new();
1019 my $font1 = $pdf->font('Helvetica-Bold');
1020 my $font2 = $pdf->font('/path/to/ComicSans.ttf');
1021 my $page = $pdf->page();
1022 my $content = $page->text();
1023
1024 $content->position(1 * 72, 9 * 72);
1025 $content->font($font1, 24);
1026 $content->text('Hello, World!');
1027
1028 $content->position(0, -36);
1029 $content->font($font2, 12);
1030 $content->text('This is some sample text.');
1031
1032 $pdf->saveas('sample.pdf');
1033
1034 The path can be omitted if the font file is in the current
1035 directory or one of the directories returned by "font_path".
1036
1037 TrueType (ttf/otf), Adobe PostScript Type 1 (pfa/pfb), and Adobe
1038 Glyph Bitmap Distribution Format (bdf) fonts are supported.
1039
1040 The following options (%opts) are available:
1041
1042 format
1043 The font format is normally detected automatically based on the
1044 file's extension. If you're using a font with an atypical
1045 extension, you can set "format" to one of "truetype" (TrueType
1046 or OpenType), "type1" (PostScript Type 1), or "bitmap" (Adobe
1047 Bitmap).
1048
1049 dokern
1050 Kerning (automatic adjustment of space between pairs of
1051 characters) is enabled by default if the font includes this
1052 information. Set this option to false to disable.
1053
1054 afm_file (PostScript Type 1 fonts only)
1055 Specifies the location of the font metrics file.
1056
1057 pfm_file (PostScript Type 1 fonts only)
1058 Specifies the location of the printer font metrics file. This
1059 option overrides the encode option.
1060
1061 embed (TrueType fonts only)
1062 Fonts are embedded in the PDF by default, which is required to
1063 ensure that they can be viewed properly on a device that
1064 doesn't have the font installed. Set this option to false to
1065 prevent the font from being embedded.
1066
1067 @directories = PDF::Builder->font_path()
1068 Return the list of directories that will be searched (in order) in
1069 addition to the current directory when you add a font to a PDF
1070 without including the full path to the font file.
1071
1072 @directories = PDF::Builder::add_to_font_path('/my/fonts',
1073 '/path/to/fonts', ...)
1074 Adds one or more directories to the list of paths to be searched
1075 for font files.
1076
1077 Returns the font search path.
1078
1079 Alternate name: "addFontDirs"
1080
1081 Prior to recent changes to PDF::API2, this method was
1082 addFontDirs(). This method is still available, but may be
1083 deprecated some time in the future.
1084
1085 @directories = PDF::Builder->set_font_path('/my/fonts',
1086 '/path/to/fonts');
1087 Replace the existing font search path. This should only be
1088 necessary if you need to remove a directory from the path for some
1089 reason, or if you need to reorder the list.
1090
1091 Returns the font search path.
1092
1093 $font = $pdf->synfont($basefont, %opts)
1094 Returns a new synthetic font object. These are modifications to a
1095 core (or PS/T1 or TTF/OTF) font, where the font may be replaced by
1096 a Type1 or Type3 PostScript font. This does not appear to work
1097 with CJK fonts (created with "cjkfont" method). For details, see
1098 "Synthetic Fonts" in PDF::Builder::Docs.
1099
1100 See also PDF::Builder::Resource::Font::SynFont
1101
1102 Alternate name: "synthetic_font"
1103
1104 Prior to recent PDF::API2 changes, the routine to create modified
1105 fonts was "synfont". PDF::API2 has renamed it to "synthetic_font",
1106 which I don't like, but to maintain compatibility, "synthetic_font"
1107 is available as an alias.
1108
1109 There are also some minor option differences (incompatibilities)
1110 discussed in "SynFont", including the value of 'bold' between the
1111 two entry points.
1112
1113 $font = $pdf->unifont(@fontspecs, %opts)
1114 Returns a new uni-font object, based on the specified fonts and
1115 options.
1116
1117 BEWARE: This is not a true PDF-object, but a virtual/abstract font
1118 definition!
1119
1120 See also PDF::Builder::Resource::UniFont.
1121
1122 Valid options (%opts) are:
1123
1124 encode
1125 Changes the encoding of the font from its default.
1126
1128 $object = $pdf->image($file, %opts);
1129 A convenience function to attempt to determine the image type, and
1130 import a file of that type and return an object that can be placed
1131 as part of a page's content:
1132
1133 my $pdf = PDF::Builder->new();
1134 my $page = $pdf->page();
1135
1136 my $image = $pdf->image('/path/to/image.jpg');
1137 $page->object($image, 100, 100);
1138
1139 $pdf->save('sample.pdf');
1140
1141 $file may be either a file name, a filehandle, or a
1142 PDF::Builder::Resource::XObject::Image::GD object.
1143
1144 Caution: Do not confuse this "image" ($pdf->) with the image method
1145 found in the graphics (gfx) class ($gfx->), used to actually place
1146 a read-in or decoded image on the page!
1147
1148 See "image" in PDF::Builder::Content for details about placing
1149 images on a page once they're imported.
1150
1151 The image format is normally detected automatically based on the
1152 file's extension (.gif, .png, .tif/.tiff, .jpg/.jpeg,
1153 .pnm/.pbm/.pgm/.ppm). If passed a filehandle, image formats GIF,
1154 JPEG, PNM, and PNG will be detected based on the file's header.
1155 Unfortunately, at this time, other image formats (TIFF and GD)
1156 cannot be automatically detected. (TIFF could be, except that
1157 "image_tiff()" cannot use a filehandle anyway as input when using
1158 the libtiff library, which is highly recommended.)
1159
1160 If the file has an atypical extension or the filehandle is for a
1161 different kind of image, you can set the "format" option to one of
1162 the supported types: "gif", "jpeg", "png", "pnm", or "tiff".
1163
1164 Note: PNG images that include an alpha (transparency) channel go
1165 through a relatively slow process of splitting the image into
1166 separate RGB and alpha components as is required by images in PDFs.
1167 If you're having performance issues, install Image::PNG::Libpng to
1168 speed this process up by an order of magnitude; either module will
1169 be used automatically if available. See the "image_png" method for
1170 details.
1171
1172 Note: TIFF image processing is very slow if using the pure Perl
1173 decoder. We highly recommend using the Graphics::TIFF library to
1174 improve performance. See the "image_tiff" method for details.
1175
1176 $jpeg = $pdf->image_jpeg($file, %opts)
1177 Imports and returns a new JPEG image object. $file may be either a
1178 filename or a filehandle.
1179
1180 See PDF::Builder::Resource::XObject::Image::JPEG for additional
1181 information and "examples/Content.pl" for some examples of placing
1182 an image on a page.
1183
1184 $tiff = $pdf->image_tiff($file, %opts)
1185 Imports and returns a new TIFF image object. $file may be either a
1186 filename or a filehandle. For details, see "TIFF Images" in
1187 PDF::Builder::Docs.
1188
1189 See PDF::Builder::Resource::XObject::Image::TIFF and
1190 PDF::Builder::Resource::XObject::Image::TIFF_GT for additional
1191 information and "examples/Content.pl" for some examples of placing
1192 an image on a page (JPEG, but the principle is the same). There is
1193 an optional TIFF library (TIFF_GT) described, that gives more
1194 capability than the default one. However, note that $file can only
1195 be a filename when using this library.
1196
1197 $rc = $pdf->LA_GT()
1198 Returns 1 if the library name (package) Graphics::TIFF is
1199 installed, and 0 otherwise. For this optional library, this call
1200 can be used to know if it is safe to use certain functions. For
1201 example:
1202
1203 if ($pdf->LA_GT() {
1204 # is installed and usable
1205 } else {
1206 # not available. you will be running the old, pure PERL code
1207 }
1208
1209 $pnm = $pdf->image_pnm($file, %opts)
1210 Imports and returns a new PNM image object. $file may be either a
1211 filename or a filehandle.
1212
1213 See PDF::Builder::Resource::XObject::Image::PNM for additional
1214 information and "examples/Content.pl" for some examples of placing
1215 an image on a page (JPEG, but the principle is the same).
1216
1217 $png = $pdf->image_png($file, %opts)
1218 Imports and returns a new PNG image object. $file may be either a
1219 filename or a filehandle. For details, see "PNG Images" in
1220 PDF::Builder::Docs.
1221
1222 See PDF::Builder::Resource::XObject::Image::PNG and
1223 PDF::Builder::Resource::XObject::Image::PNG_IPL for additional
1224 information and "examples/Content.pl" for some examples of placing
1225 an image on a page (JPEG, but the principle is the same).
1226
1227 There is an optional PNG library (PNG_IPL) described, that gives
1228 more capability than the default one. However, note that $file can
1229 only be a filename when using this library.
1230
1231 $rc = $pdf->LA_IPL()
1232 Returns 1 if the library name (package) Image::PNG::Libpng is
1233 installed, and 0 otherwise. For this optional library, this call
1234 can be used to know if it is safe to use certain functions. For
1235 example:
1236
1237 if ($pdf->LA_IPL() {
1238 # is installed and usable
1239 } else {
1240 # not available. don't use 16bps or interlaced PNG image files
1241 }
1242
1243 $gif = $pdf->image_gif($file, %opts)
1244 Imports and returns a new GIF image object. $file may be either a
1245 filename or a filehandle.
1246
1247 See PDF::Builder::Resource::XObject::Image::GIF for additional
1248 information and "examples/Content.pl" for some examples of placing
1249 an image on a page (JPEG, but the principle is the same).
1250
1251 $gdf = $pdf->image_gd($gd_object, %opts)
1252 Imports and returns a new image object from Image::GD.
1253
1254 See PDF::Builder::Resource::XObject::Image::GD for additional
1255 information and "examples/Content.pl" for some examples of placing
1256 an image on a page (JPEG, but the principle is the same).
1257
1259 $colorspace = $pdf->colorspace($type, @arguments)
1260 Colorspaces can be added to a PDF to either specifically control
1261 the output color on a particular device (spot colors, device
1262 colors) or to save space by limiting the available colors to a
1263 defined color palette (web-safe palette, ACT file).
1264
1265 Once added to the PDF, they can be used in place of regular hex
1266 codes or named colors:
1267
1268 my $pdf = PDF::Builder->new();
1269 my $page = $pdf->page();
1270 my $content = $page->graphics();
1271
1272 # Add colorspaces for a spot color and the web-safe color palette
1273 my $spot = $pdf->colorspace('spot', 'PANTONE Red 032 C', '#EF3340');
1274 my $web = $pdf->colorspace('web');
1275
1276 # Fill using the spot color with 100% coverage
1277 $content->fill_color($spot, 1.0);
1278
1279 # Stroke using the first color of the web-safe palette
1280 $content->stroke_color($web, 0);
1281
1282 # Add a rectangle to the page
1283 $content->rectangle(100, 100, 200, 200);
1284 $content->paint();
1285
1286 $pdf->save('sample.pdf');
1287
1288 The following types of colorspaces are supported
1289
1290 spot
1291 my $spot = $pdf->colorspace('spot', $tint, $alt_color);
1292
1293 Spot colors are used to instruct a device (usually a printer)
1294 to use or emulate a particular ink color ($tint) for parts of
1295 the document. An $alt_color is provided for devices (e.g. PDF
1296 viewers) that don't know how to produce the named color. It can
1297 either be an approximation of the color in RGB, CMYK, or HSV
1298 formats, or a wildly different color (e.g. 100% magenta, %0F00)
1299 to make it clear if the spot color isn't being used as
1300 expected.
1301
1302 web
1303 my $web = $pdf->colorspace('web');
1304
1305 The web-safe color palette is a historical collection of colors
1306 that was used when many display devices only supported 256
1307 colors.
1308
1309 act
1310 my $act = $pdf->colorspace('act', $filename);
1311
1312 An Adobe Color Table (ACT) file provides a custom palette of
1313 colors that can be referenced by PDF graphics and text drawing
1314 commands.
1315
1316 device
1317 my $devicen = $pdf->colorspace('device', @colorspaces);
1318
1319 A device-specific colorspace allows for precise color output on
1320 a given device (typically a printing press), bypassing the
1321 normal color interpretation performed by raster image
1322 processors (RIPs).
1323
1324 Device colorspaces are also needed if you want to blend spot
1325 colors:
1326
1327 my $pdf = PDF::Builder->new();
1328 my $page = $pdf->page();
1329 my $content = $page->graphics();
1330
1331 # Create a two-color device colorspace
1332 my $yellow = $pdf->colorspace('spot', 'Yellow', '%00F0');
1333 my $spot = $pdf->colorspace('spot', 'PANTONE Red 032 C', '#EF3340');
1334 my $device = $pdf->colorspace('device', $yellow, $spot);
1335
1336 # Fill using a blend of 25% yellow and 75% spot color
1337 $content->fill_color($device, 0.25, 0.75);
1338
1339 # Stroke using 100% spot color
1340 $content->stroke_color($device, 0, 1);
1341
1342 # Add a rectangle to the page
1343 $content->rectangle(100, 100, 200, 200);
1344 $content->paint();
1345
1346 $pdf->save('sample.pdf');
1347
1348 $cs = $pdf->colorspace_act($file)
1349 Returns a new colorspace object based on an Adobe Color Table file.
1350
1351 See PDF::Builder::Resource::ColorSpace::Indexed::ACTFile for a
1352 reference to the file format's specification.
1353
1354 $cs = $pdf->colorspace_web()
1355 Returns a new colorspace-object based on the "web-safe" color
1356 palette.
1357
1358 $cs = $pdf->colorspace_hue()
1359 Returns a new colorspace-object based on the hue color palette.
1360
1361 See PDF::Builder::Resource::ColorSpace::Indexed::Hue for an
1362 explanation.
1363
1364 $cs = $pdf->colorspace_separation($tint, $color)
1365 Returns a new separation colorspace object based on the parameters.
1366
1367 $tint can be any valid ink identifier, including but not limited
1368 to: 'Cyan', 'Magenta', 'Yellow', 'Black', 'Red', 'Green', 'Blue' or
1369 'Orange'.
1370
1371 $color must be a valid color specification limited to: '#rrggbb',
1372 '!hhssvv', '%ccmmyykk' or a "named color" (rgb).
1373
1374 The colorspace model will automatically be chosen based on the
1375 specified color.
1376
1377 $cs = $pdf->colorspace_devicen(\@tintCSx, $samples)
1378 $cs = $pdf->colorspace_devicen(\@tintCSx)
1379 Returns a new DeviceN colorspace object based on the parameters.
1380
1381 Example:
1382
1383 $cy = $pdf->colorspace_separation('Cyan', '%f000');
1384 $ma = $pdf->colorspace_separation('Magenta', '%0f00');
1385 $ye = $pdf->colorspace_separation('Yellow', '%00f0');
1386 $bk = $pdf->colorspace_separation('Black', '%000f');
1387
1388 $pms023 = $pdf->colorspace_separation('PANTONE 032CV', '%0ff0');
1389
1390 $dncs = $pdf->colorspace_devicen( [ $cy,$ma,$ye,$bk, $pms023 ] );
1391
1392 The colorspace model will automatically be chosen based on the
1393 first colorspace specified.
1394
1396 These are glue routines to the actual barcode rendering routines
1397 found elsewhere.
1398
1399 $bc = $pdf->xo_codabar(%opts)
1400 $bc = $pdf->xo_code128(%opts)
1401 $bc = $pdf->xo_2of5int(%opts)
1402 $bc = $pdf->xo_3of9(%opts)
1403 $bc = $pdf->xo_ean13(%opts)
1404 Creates the specified barcode object as a form XObject.
1405
1407 $xo = $pdf->xo_form()
1408 Returns a new form XObject.
1409
1410 $egs = $pdf->egstate()
1411 Returns a new extended graphics state object, as described in
1412 PDF::Builder::Resource::ExtGState.
1413
1414 $obj = $pdf->pattern(%opts)
1415 Returns a new pattern object.
1416
1417 $obj = $pdf->shading(%opts)
1418 Returns a new shading object.
1419
1420 $ndest = $pdf->named_destination()
1421 Returns a new or existing named destination object.
1422
1423
1424
1425perl v5.36.0 2022-09-13 PDF::Builder(3)