PDF::Builder(3pm) | User Contributed Perl Documentation | PDF::Builder(3pm) |
PDF::Builder - Facilitates the creation and modification of PDF files
use PDF::Builder; # Create a blank PDF file $pdf = PDF::Builder->new(); # Open an existing PDF file $pdf = PDF::Builder->open('some.pdf'); # Add a blank page $page = $pdf->page(); # Retrieve an existing page $page = $pdf->open_page($page_number); # Set the page size $page->size('Letter'); # or mediabox('Letter') # Add a built-in font to the PDF $font = $pdf->font('Helvetica-Bold'); # or corefont('Helvetica-Bold') # Add an external TrueType (TTF) font to the PDF $font = $pdf->font('/path/to/font.ttf'); # or ttfont() in this case # Add some text to the page $text = $page->text(); $text->font($font, 20); $text->position(200, 700); # or translate() $text->text('Hello World!'); # Save the PDF $pdf->saveas('/path/to/new.pdf');
See the file README.md (in downloadable package and on CPAN) for a summary of prerequisites and tools needed to install PDF::Builder, both mandatory and optional.
There are four levels of involvement with PDF::Builder. Depending on what you want to do, different kinds of installs are recommended. See "Software Development Kit" in PDF::Builder::Docs for suggestions.
PDF::Builder can make use of some optional libraries, which are not required for a successful installation, but improve speed and capabilities. See "Optional Libraries" in PDF::Builder::Docs for more information.
There are some things you should know about character encoding (for text), before you dive in to coding. Please go to "Strings (Character Text)" in PDF::Builder::Docs and have a read.
Invoking "text" and "graphics" methods can lead to unexpected results (a different ordering of output than intended). See "Rendering Order" in PDF::Builder::Docs for more information.
PDF::Builder is mostly PDF 1.4-compliant, but there are complications you should be aware of. Please read "PDF Versions Supported" in PDF::Builder::Docs for details.
PDF::Builder intends to support all major Perl versions that were released in the past six years, plus one, in order to continue working for the life of most long-term-stable (LTS) server distributions. See the <https://www.cpan.org/src/> table First release in each branch of Perl x.xxxx0 "Major" release dates.
For example, a version of PDF::Builder released on 2018-06-05 would support the last major version of Perl released on or after 2012-06-05 (5.18), and then one before that, which would be 5.16. Alternatively, the last major version of Perl released before 2012-06-05 is 5.16.
The intent is to avoid expending unnecessary effort in supporting very old (obsolete) versions of Perl.
Anticipated Support Cutoff Dates
Note that these are not hard and fast dates. In particular, we develop on Strawberry Perl, which is currently stuck at release 5.32! We'll have to see whether we can get around this problem in the summer of 2023, if Strawberry hasn't yet gotten up to at least 5.36 by then.
If you need to use this module on a server with an extremely out-of-date version of Perl, consider using either plenv or Perlbrew to run a newer version of Perl without needing admin privileges.
On the other hand, any feature in PDF::Builder should continue to work unchanged for the life of most long-term-stable (LTS) server distributions. Their lifetime is usually about six (6) years. Note that this does not constitute a statement of warranty, but that we intend to try to keep any particular release of PDF::Builder working for a period of years. Of course, it helps if you periodically update your Perl installation to something released in the recent past.
This module does not work with perl's -l command-line switch.
There is a file INFO/KNOWN_INCOMP which lists known incompatibilities with PDF::API2, in case you're thinking of porting over something from that world, or have experience there and want to try PDF::Builder. There is also a file INFO/DEPRECATED, which lists things which are planned to be removed at some point.
The history of PDF::Builder is a complex and exciting saga... OK, it may be mildly interesting. Have a look at "History" in PDF::Builder::Docs section.
PDF::API2 was originally written by Alfred Reibenschuh. See the HISTORY section for more information.
It was maintained by Steve Simms, who is still contributing new code to it (which often ends up in PDF::Builder).
PDF::Builder is currently being maintained by Phil M. Perry.
The full source is on https://github.com/PhilterPaper/Perl-PDF-Builder.
The release distribution is on CPAN: https://metacpan.org/pod/PDF::Builder.
Bug reports are on https://github.com/PhilterPaper/Perl-PDF-Builder/issues?q=is%3Aissue+sort%3Aupdated-desc (with "bug" label), feature requests have an "enhancement" label, and general discussions (architecture, roadmap, etc.) have a "general discussion" label.
Do not under any circumstances open a PR (Pull Request) to report a bug. It is a waste of both your and our time and effort. Open a regular ticket (issue), and attach a Perl (.pl) program illustrating the problem, if possible. If you believe that you have a program patch, and offer to share it as a PR, we may give the go-ahead. Unsolicited PRs may be closed without further action.
This software is Copyright (c) 2017-2023 by Phil M. Perry.
This is free software, licensed under:
The GNU Lesser General Public License (LGPL) Version 2.1, February 1999
(The master copy of this license lives on the GNU website.) (A copy is provided in the INFO/LICENSE file for your convenience.)
This section of Builder.pm is intended only as a very brief summary of the license; please consider INFO/LICENSE to be the controlling version, if there is any conflict or ambiguity between the two.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version of this license.
NOTE: there are several files in this distribution which were incorporated from outside sources and carry different licenses. If a file states that it is under a license different than LGPL 2.1, that license and its terms will apply to that file, and not LGPL 2.1.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
Options
Example:
$pdf = PDF::Builder->new(); ... print $pdf->to_string(); $pdf = PDF::Builder->new(compress => 'none'); # equivalent to $pdf->{'forcecompress'} = 'none'; (or older, 0) $pdf = PDF::Builder->new(); ... $pdf->saveas('our/new.pdf'); $pdf = PDF::Builder->new(file => 'our/new.pdf'); ... $pdf->save();
This is essentially an alternate method of defining the "mediabox()" call, and added for compatibility with PDF::API2.
See "Page Sizes" in PDF::Builder::Page for possible values.
See the equivalent "page_boundaries" method in PDF::Builder::Page for details.
Example:
$pdf = PDF::Builder->open('our/old.pdf'); ... $pdf->saveas('our/new.pdf'); $pdf = PDF::Builder->open('our/to/be/updated.pdf'); ... $pdf->update();
Example:
# Read a PDF into a string, for the purpose of demonstration open $fh, 'our/old.pdf' or croak $@; undef $/; # Read the whole file at once $pdf_string = <$fh>; $pdf = PDF::Builder->from_string($pdf_string); ... $pdf->saveas('our/new.pdf');
Alternate name: "open_scalar"
"from_string" was formerly known as "open_scalar" (and even before that, as "openScalar"), and this older name is still valid as an alternative to "from_string". It is possible that "open_scalar" will be deprecated and then removed some time in the future, so it may be advisable to use "from_string" in new work.
Caution: Although the object $pdf will still exist, it is no longer usable for any purpose after invoking this method! You will receive error messages about "can't call method new_obj on an undefined value".
Example:
$pdf = PDF::Builder->new(); ... print $pdf->to_string();
Alternate name: "stringify"
"to_string" was formerly known as "stringify", and this older name is still valid as an alternative to "to_string". It is possible that "stringify" will be deprecated and then removed some time in the future, so it may be advisable to use "to_string" in new work.
Example:
$pdf = PDF::Builder->new(file => 'our/new.pdf'); ... $pdf->finishobjects($page, $gfx, $txt); ... $pdf->save();
Note: this method is now considered obsolete, and may be deprecated. It allows for objects to be written to disk in advance of finally saving and closing the file. Otherwise, it's no different than just calling "save()" when all changes have been made. There's no memory advantage since "ship_out" doesn't remove objects from memory.
Example:
$pdf = PDF::Builder->open('our/to/be/updated.pdf'); ... $pdf->update();
Note: it is considered better to simply "save()" the file, rather than calling "update()". They end up doing the same thing, anyway. This method may be deprecated in the future.
Caution: Although the object $pdf will still exist, it is no longer usable for any purpose after invoking this method! You will receive error messages about "can't call method new_obj on an undefined value".
Example:
$pdf = PDF::Builder->new(); ... $pdf->saveas('our/new.pdf');
Caution: Although the object $pdf will still exist, it is no longer usable for any purpose after invoking this method! You will receive error messages about "can't call method new_obj on an undefined value".
Example:
$pdf = PDF::Builder->new(file => 'file_to_output'); ... $pdf->save();
Note: now that "save()" can take a filename as an argument, it effectively is interchangeable with "saveas()". This is strictly for compatibility with recent changes to PDF::API2. Unlike PDF::API2, we are not deprecating the "saveas()" method, because in user interfaces, "save" normally means that the current filename is known and is to be used, while "saveas" normally means that (whether or not there is a current filename) a new filename is to be used.
PDF::API2 contains circular references, so this call is necessary in long-running processes to keep from running out of memory.
This will be called automatically when you save or stringify a PDF. You should only need to call it explicitly if you are reading PDF files and not writing them.
Alternate names: "release" and "end"
This will be called automatically when you save or to_string a PDF. You should only need to call it explicitly if you are reading PDF files and not writing them.
This (and release) are older and now deprecated names formerly used in PDF::API2 and PDF::Builder. You should try to avoid having to explicitly call them.
PDF::Builder fills in this field when creating a PDF.
The date format is "D:YYYYMMDDHHmmSSOHH'mm", where "D:" is a static prefix identifying the string as a PDF date. The date may be truncated at any point after the year. "O" is one of "+", "-", or "Z", with the following "HH'mm" representing an offset from UTC.
When setting the date, "D:" will be prepended automatically if omitted.
Pass "undef" as the value in order to remove the key from the dictionary.
See "info Example" in PDF::Builder::Docs section for an example of the use of this method.
Note: this method is still available, for compatibility purposes. It is better to use individual accessors or "info_metadata" instead.
Example:
@attributes = $pdf->infoMetaAttributes; print "Supported Attributes: @attr\n"; @attributes = $pdf->infoMetaAttributes('CustomField1'); print "Supported Attributes: @attributes\n";
Note: this method is still available for compatibility purposes, but the use of "info_metadata" instead is encouraged.
See "XMP XML example" in PDF::Builder::Docs section for an example of the use of this method.
This method is considered obsolete. Use "xml_metadata" instead.
Supported Parameters:
CAUTION: Perl::Critic (tools/1_pc.pl) has started flagging the name "default" as a reserved keyword in higher Perl versions. Use with caution, and be aware that this name may have to be changed in the future.
A warning message is given if you attempt to decrease the PDF version, as you might have already read in a higher level file, or used a higher level feature.
See PDF::Builder::Basic::PDF::File for additional information on the "version" method.
Alternate name: "isEncrypted"
This is the older name; it is kept for compatibility with PDF::API2.
To examine or modify the outline tree, see PDF::Builder::Outlines.
Alternate name: "outlines"
This is the older name; it is kept for compatibility.
$layout is one of the following:
This has been split out from "preferences()" for compatibility with PDF::API2. It also can both set (assign) and get (query) the settings used.
$mode is one of the following:
This has been split out from "preferences()" for compatibility with PDF::API2. It also can both set (assign) and get (query) the settings used.
This has been split out from "preferences()" for compatibility with PDF::API2. It also can both set (assign) and get (query) the settings used.
Note: the various preferences have been split out into their own methods. It is preferred that you use these specific methods.
If $page_number is -1, the new page is inserted as the second-to-last page; if $page_number is 0, the new page is inserted as the last page.
Example:
$pdf = PDF::Builder->new(); # Add a page. This becomes page 1. $page = $pdf->page(); # Add a new first page. $page becomes page 2. $another_page = $pdf->page(1);
If $page_number is 0, -1, or unspecified, it will return the last page in the document. If the requested page is out of range, the $page returned will be undefined.
Example:
$pdf = PDF::Builder->open('our/99page.pdf'); $page = $pdf->open_page(1); # returns the first page $page = $pdf->open_page(99); # returns the last page $page = $pdf->open_page(-1); # returns the last page $page = $pdf->open_page(999); # returns undef $page = $pdf->open_page(0); # returns the last page $page = $pdf->open_page(); # returns the last page
Alternate name: "openpage"
This is the older name; it is kept for compatibility until after June 2023 (deprecated, as previously announced).
If the $source_page_number is omitted, 0, or -1; the last page of the source is imported. If the $target_page_number is omitted, 0, or -1; the imported page will be placed as the new last page of the target ($pdf). Otherwise, as with the "page()" method, the page will be inserted before an existing page of that number.
Note: If you pass a page object instead of a page number for $target_page_number, the contents of the page will be merged into the existing page.
Example:
my $pdf = PDF::Builder->new(); my $source = PDF::Builder->open('source.pdf'); # Add page 2 from the old PDF as page 1 of the new PDF my $page = $pdf->import_page($source, 2); $pdf->saveas('sample.pdf');
Note: You can only import a page from an existing PDF file.
This is useful if you want to transpose the imported page somewhat differently onto a page (e.g. two-up, four-up, etc.).
If $source_page_number is 0 or -1, it will return the last page in the document.
Example:
my $pdf = PDF::Builder->new(); my $source = PDF::Builder->open('source.pdf'); my $page = $pdf->page(); # Import Page 2 from the source PDF my $object = $pdf->embed_page($source, 2); # Add it to the new PDF's first page at 1/2 scale my ($x, $y) = (0, 0); $page->object($xo, $x, $y, 0.5); $pdf->save('sample.pdf');
Note: You can only import a page from an existing PDF file.
Alternate name: "importPageIntoForm"
This is the older name; it is kept for compatibility.
Alternate name: "pages"
This is the old name; it is kept for compatibility.
Note that many PDF Readers ignore these settings, and (at most) simply give you the physical page number 1, 2, 3,... instead of the page label specified here.
# Generate a 30-page PDF my $pdf = PDF::Builder->new(); $pdf->page() for 1..30; # Number pages i to v, 1 to 20, and A-1 to A-5, respectively $pdf->page_labels(1, 'style' => 'roman'); $pdf->page_labels(6, 'style' => 'decimal'); $pdf->page_labels(26, 'style' => 'decimal', 'prefix' => 'A-'); $pdf->save('sample.pdf');
Supported Options:
Also note that the counter starts at physical page 1, while the page $index number in the "page_labels()" call (as well as the PDF PageLabels dictionary) starts at logical page (index) 0.
According to the Adobe/ISO PDF specification, a prefix of 'Content' has a special meaning, in that any /S counter is ignored and only that text is used. However, this appears to be ignored (use a style of nocounter to suppress the counter).
Example:
# Start with lowercase Roman Numerals at the 1st page, starting with i (1) $pdf->page_labels(0, 'style' => 'roman', ); # Switch to Arabic (decimal) at the 5th page, starting with 1 $pdf->page_labels(4, 'style' => 'decimal', ); # invalid style at the 25th page, should just continue # with decimal at the current counter $pdf->page_labels(24, 'style' => 'raman_noodles', # fail over to decimal # note that PDF::API2 will see the 'r' and treat it as 'roman' 'start' => 21, # necessary, otherwise would restart at 1 ); # No page label at the 31st and 32nd pages. Note that this could be # confusing to the person viewing the PDF, but may be appropriate if # the page itself has no numbering. $pdf->page_labels(30, 'style' => 'nocounter', ); # Numbering for Appendix A at the 33rd page, A-1, A-2,... $pdf->page_labels(32, 'start' => 1, # unnecessary 'prefix' => 'A-' ); # Numbering for Appendix B at the 37th page, B-1, B-2,... $pdf->page_labels( 36, 'prefix' => 'B-' ); # Numbering for the Index at the 41st page, Index I, Index II,... $pdf->page_labels(40, 'style' => 'Roman', 'start' => 1, # unnecessary 'prefix' => 'Index ' # note trailing space ); # Unnumbered 'Index' at the 45th page, Index, Index,... $pdf->page_labels(40, 'style' => 'nocounter', 'prefix' => 'Index ' );
Alternate name: "pageLabel"
This old method name is retained for compatibility with old user code. Note that with "pageLabel", you need to make the "options" list an anonymous hash by placing { } around the entire list, even if it has only one item in it.
See "User Units" in PDF::Builder::Docs for more information.
See "Media Box" in PDF::Builder::Docs for more information. The method always returns the current bounds (after any set operation).
See "Crop Box" in PDF::Builder::Docs for more information. The method always returns the current bounds (after any set operation).
See "Bleed Box" in PDF::Builder::Docs for more information. The method always returns the current bounds (after any set operation).
See "Trim Box" in PDF::Builder::Docs for more information. The method always returns the current bounds (after any set operation).
See "Art Box" in PDF::Builder::Docs for more information. The method always returns the current bounds (after any set operation).
See also PDF::Builder::Resource::Font::CoreFont.
See also PDF::Builder::Resource::Font::Postscript.
See also PDF::Builder::Resource::Font::BdFont
NOTE: "cjkfont" is quite old and is not well supported. We recommend that you try using "ttfont" (or another font routine, if not TTF/OTF) with the appropriate CJK font file. Most appear to be .ttf or .otf format. PDFs created using "cjkfont" may not be fully portable, and support for "cjkfont" may be dropped in a future release. We would appreciate hearing from you if you are successfully using "cjkfont", and are unable to use "ttfont" instead.
Among other things, "cjkfont" selections are limited, as they require CMAP files; they may or may not subset correctly; and they can not be used as the base for synthetic fonts.
See also PDF::Builder::Resource::CIDFont::CJKFont
The font $name is either the name of one of the standard 14 fonts ("STANDARD FONTS" in PDF::Builder::Resource::Font::CoreFont), such as Helvetica or the path to a font file. There are 15 additional core fonts on a Windows system. Note that the exact name of a core font needs to be given. The file extension (if path given) determines what type of font file it is.
my $pdf = PDF::Builder->new(); my $font1 = $pdf->font('Helvetica-Bold'); my $font2 = $pdf->font('/path/to/ComicSans.ttf'); my $page = $pdf->page(); my $content = $page->text(); $content->position(1 * 72, 9 * 72); $content->font($font1, 24); $content->text('Hello, World!'); $content->position(0, -36); $content->font($font2, 12); $content->text('This is some sample text.'); $pdf->saveas('sample.pdf');
The path can be omitted if the font file is in the current directory or one of the directories returned by "font_path".
TrueType (ttf/otf), Adobe PostScript Type 1 (pfa/pfb), and Adobe Glyph Bitmap Distribution Format (bdf) fonts are supported.
The following options (%opts) are available:
Returns the font search path.
Alternate name: "addFontDirs"
Prior to recent changes to PDF::API2, this method was addFontDirs(). This method is still available, but may be deprecated some time in the future.
Returns the font search path.
See also PDF::Builder::Resource::Font::SynFont
Alternate name: "synthetic_font"
Prior to recent PDF::API2 changes, the routine to create modified fonts was "synfont". PDF::API2 has renamed it to "synthetic_font", which I don't like, but to maintain compatibility, "synthetic_font" is available as an alias.
There are also some minor option differences (incompatibilities) discussed in "SynFont", including the value of 'bold' between the two entry points.
BEWARE: This is not a true PDF-object, but a virtual/abstract font definition!
See also PDF::Builder::Resource::UniFont.
Valid options (%opts) are:
The Font Manager is automatically initialized.
my $pdf = PDF::Builder->new(); my $page = $pdf->page(); my $image = $pdf->image('/path/to/image.jpg'); $page->object($image, 100, 100); $pdf->save('sample.pdf');
$file may be either a file name, a filehandle, or a PDF::Builder::Resource::XObject::Image::GD object.
Caution: Do not confuse this "image" ($pdf->) with the image method found in the graphics (gfx) class ($gfx->), used to actually place a read-in or decoded image on the page!
See "image" in PDF::Builder::Content for details about placing images on a page once they're imported.
The image format is normally detected automatically based on the file's extension (.gif, .png, .tif/.tiff, .jpg/.jpeg, .pnm/.pbm/.pgm/.ppm). If passed a filehandle, image formats GIF, JPEG, PNM, and PNG will be detected based on the file's header. Unfortunately, at this time, other image formats (TIFF and GD) cannot be automatically detected. (TIFF could be, except that "image_tiff()" cannot use a filehandle anyway as input when using the libtiff library, which is highly recommended.)
If the file has an atypical extension or the filehandle is for a different kind of image, you can set the "format" option to one of the supported types: "gif", "jpeg", "png", "pnm", or "tiff".
Note: PNG images that include an alpha (transparency) channel go through a relatively slow process of splitting the image into separate RGB and alpha components as is required by images in PDFs. If you're having performance issues, install Image::PNG::Libpng to speed this process up by an order of magnitude; either module will be used automatically if available. See the "image_png" method for details.
Note: TIFF image processing is very slow if using the pure Perl decoder. We highly recommend using the Graphics::TIFF library to improve performance. See the "image_tiff" method for details.
See PDF::Builder::Resource::XObject::Image::JPEG for additional information and "examples/Content.pl" for some examples of placing an image on a page.
See PDF::Builder::Resource::XObject::Image::TIFF and PDF::Builder::Resource::XObject::Image::TIFF_GT for additional information and "examples/Content.pl" for some examples of placing an image on a page (JPEG, but the principle is the same). There is an optional TIFF library (TIFF_GT) described, that gives more capability than the default one. However, note that $file can only be a filename when using this library.
if ($pdf->LA_GT() { # is installed and usable } else { # not available. you will be running the old, pure PERL code }
See PDF::Builder::Resource::XObject::Image::PNM for additional information and "examples/Content.pl" for some examples of placing an image on a page (JPEG, but the principle is the same).
See PDF::Builder::Resource::XObject::Image::PNG and PDF::Builder::Resource::XObject::Image::PNG_IPL for additional information and "examples/Content.pl" for some examples of placing an image on a page (JPEG, but the principle is the same).
There is an optional PNG library (PNG_IPL) described, that gives more capability than the default one. However, note that $file can only be a filename when using this library.
if ($pdf->LA_IPL() { # is installed and usable } else { # not available. don't use 16bps or interlaced PNG image files }
See PDF::Builder::Resource::XObject::Image::GIF for additional information and "examples/Content.pl" for some examples of placing an image on a page (JPEG, but the principle is the same).
See PDF::Builder::Resource::XObject::Image::GD for additional information and "examples/Content.pl" for some examples of placing an image on a page (JPEG, but the principle is the same).
Once added to the PDF, they can be used in place of regular hex codes or named colors:
my $pdf = PDF::Builder->new(); my $page = $pdf->page(); my $content = $page->graphics(); # Add colorspaces for a spot color and the web-safe color palette my $spot = $pdf->colorspace('spot', 'PANTONE Red 032 C', '#EF3340'); my $web = $pdf->colorspace('web'); # Fill using the spot color with 100% coverage $content->fill_color($spot, 1.0); # Stroke using the first color of the web-safe palette $content->stroke_color($web, 0); # Add a rectangle to the page $content->rectangle(100, 100, 200, 200); $content->paint(); $pdf->save('sample.pdf');
The following types of colorspaces are supported
my $spot = $pdf->colorspace('spot', $tint, $alt_color);
Spot colors are used to instruct a device (usually a printer) to use or emulate a particular ink color ($tint) for parts of the document. An $alt_color is provided for devices (e.g. PDF viewers) that don't know how to produce the named color. It can either be an approximation of the color in RGB, CMYK, or HSV formats, or a wildly different color (e.g. 100% magenta, %0F00) to make it clear if the spot color isn't being used as expected.
my $web = $pdf->colorspace('web');
The web-safe color palette is a historical collection of colors that was used when many display devices only supported 256 colors.
my $act = $pdf->colorspace('act', $filename);
An Adobe Color Table (ACT) file provides a custom palette of colors that can be referenced by PDF graphics and text drawing commands.
my $devicen = $pdf->colorspace('device', @colorspaces);
A device-specific colorspace allows for precise color output on a given device (typically a printing press), bypassing the normal color interpretation performed by raster image processors (RIPs).
Device colorspaces are also needed if you want to blend spot colors:
my $pdf = PDF::Builder->new(); my $page = $pdf->page(); my $content = $page->graphics(); # Create a two-color device colorspace my $yellow = $pdf->colorspace('spot', 'Yellow', '%00F0'); my $spot = $pdf->colorspace('spot', 'PANTONE Red 032 C', '#EF3340'); my $device = $pdf->colorspace('device', $yellow, $spot); # Fill using a blend of 25% yellow and 75% spot color $content->fill_color($device, 0.25, 0.75); # Stroke using 100% spot color $content->stroke_color($device, 0, 1); # Add a rectangle to the page $content->rectangle(100, 100, 200, 200); $content->paint(); $pdf->save('sample.pdf');
See PDF::Builder::Resource::ColorSpace::Indexed::ACTFile for a reference to the file format's specification.
See PDF::Builder::Resource::ColorSpace::Indexed::Hue for an explanation.
$tint can be any valid ink identifier, including but not limited to: 'Cyan', 'Magenta', 'Yellow', 'Black', 'Red', 'Green', 'Blue' or 'Orange'.
$color must be a valid color specification limited to: '#rrggbb', '!hhssvv', '%ccmmyykk' or a "named color" (rgb).
The colorspace model will automatically be chosen based on the specified color.
Example:
$cy = $pdf->colorspace_separation('Cyan', '%f000'); $ma = $pdf->colorspace_separation('Magenta', '%0f00'); $ye = $pdf->colorspace_separation('Yellow', '%00f0'); $bk = $pdf->colorspace_separation('Black', '%000f'); $pms023 = $pdf->colorspace_separation('PANTONE 032CV', '%0ff0'); $dncs = $pdf->colorspace_devicen( [ $cy,$ma,$ye,$bk, $pms023 ] );
The colorspace model will automatically be chosen based on the first colorspace specified.
2023-01-24 | perl v5.36.0 |