diff options
Diffstat (limited to 'lib/PDF/Builder/Resource')
73 files changed, 1537 insertions, 415 deletions
diff --git a/lib/PDF/Builder/Resource/BaseFont.pm b/lib/PDF/Builder/Resource/BaseFont.pm index c5a57cf..be9e814 100644 --- a/lib/PDF/Builder/Resource/BaseFont.pm +++ b/lib/PDF/Builder/Resource/BaseFont.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use Compress::Zlib; #use Encode qw(:all); @@ -20,12 +20,16 @@ PDF::Builder::Resource::BaseFont - Base class for font resources =head1 METHODS -=over +=head2 new + + $font = PDF::Builder::Resource::BaseFont->new($pdf, $name) -=item $font = PDF::Builder::Resource::BaseFont->new($pdf, $name) +=over Return a font resource object. +=back + =cut sub new { @@ -50,10 +54,16 @@ sub data { return $_[0]->{' data'}; } -=item $descriptor = $font->descrByData() +=head2 descrByData + + $descriptor = $font->descrByData() + +=over Return the font's FontDescriptor key structure based on the font's data. +=back + =cut sub descrByData { @@ -152,82 +162,116 @@ sub tounicodemap { return $self; } -=back - =head1 FONT-MANAGEMENT RELATED METHODS -=over +=head2 fontname + + $name = $font->fontname() -=item $name = $font->fontname() +=over Return the font's name (a.k.a. display name). +=back + =cut sub fontname { return $_[0]->data()->{'fontname'}; } -=item $name = $font->altname() +=head2 altname + + $name = $font->altname() + +=over Return the font's alternative name (a.k.a. Windows name for a PostScript font). +=back + =cut sub altname { return $_[0]->data()->{'altname'}; } -=item $name = $font->subname() +=head2 subname + + $name = $font->subname() + +=over Return the font's subname (a.k.a. font variant). +=back + =cut sub subname { return $_[0]->data()->{'subname'}; } -=item $name = $font->apiname() +=head2 apiname + + $name = $font->apiname() + +=over Return the font's name to be used internally (should be equal to $font->name()). +=back + =cut sub apiname { return $_[0]->data()->{'apiname'}; } -=item $issymbol = $font->issymbol() +=head2 issymbol + + $issymbol = $font->issymbol() + +=over Return the font's symbol flag (i.e., is this a symbol font). +=back + =cut sub issymbol { return $_[0]->data()->{'issymbol'}; } -=item $iscff = $font->iscff() +=head2 iscff + + $iscff = $font->iscff() + +=over Return the font's Compact Font Format flag. +=back + =cut sub iscff { return $_[0]->data()->{'iscff'}; } -=back - =head1 TYPOGRAPHY-RELATED METHODS -=over +=head2 fontbbox -=item ($llx,$lly, $urx,$ury) = $font->fontbbox() + ($llx,$lly, $urx,$ury) = $font->fontbbox() + +=over Return the font's bounding box. +=back + =cut sub fontbbox { @@ -239,50 +283,80 @@ sub fontbbox { return @bbox; } -=item $capheight = $font->capheight() +=head2 capheight + + $capheight = $font->capheight() + +=over Return the font's capheight value. +=back + =cut sub capheight { return $_[0]->data()->{'capheight'}; } -=item $xheight = $font->xheight() +=head2 xheight + + $xheight = $font->xheight() + +=over Return the font's xheight value. +=back + =cut sub xheight { return $_[0]->data()->{'xheight'}; } -=item $missingwidth = $font->missingwidth() +=head2 missingwidth + + $missingwidth = $font->missingwidth() + +=over Return the font's missingwidth value. +=back + =cut sub missingwidth { return $_[0]->data()->{'missingwidth'}; } -=item $maxwidth = $font->maxwidth() +=head2 maxwidth + + $maxwidth = $font->maxwidth() + +=over Return the font's maxwidth value. +=back + =cut sub maxwidth { return $_[0]->data()->{'maxwidth'}; } -=item $avgwidth = $font->avgwidth() +=head2 avgwidth + + $avgwidth = $font->avgwidth() + +=over Return the font's avgwidth (average width) value. +=back + =cut sub avgwidth { @@ -351,39 +425,63 @@ sub avgwidth { return int($aw); } -=item $flags = $font->flags() +=head2 flags + + $flags = $font->flags() + +=over Return the font's flags value. +=back + =cut sub flags { return $_[0]->data()->{'flags'}; } -=item $stemv = $font->stemv() +=head2 stemv + + $stemv = $font->stemv() + +=over Return the font's stemv value. +=back + =cut sub stemv { return $_[0]->data()->{'stemv'}; } -=item $stemh = $font->stemh() +=head2 stemh + + $stemh = $font->stemh() + +=over Return the font's stemh value. +=back + =cut sub stemh { return $_[0]->data()->{'stemh'}; } -=item $italicangle = $font->italicangle() +=head2 italicangle -Return the font's italicangle value. + $italicangle = $font->italicangle() + +=over + +Return the font's italicangle (slant, obliqueness) value. + +=back =cut @@ -391,76 +489,114 @@ sub italicangle { return $_[0]->data()->{'italicangle'}; } -=item $isfixedpitch = $font->isfixedpitch() +=head2 isfixedpitch + + $isfixedpitch = $font->isfixedpitch() + +=over Return the font's isfixedpitch flag. +=back + =cut sub isfixedpitch { return $_[0]->data()->{'isfixedpitch'}; } -=item $underlineposition = $font->underlineposition() +=head2 underlineposition + + $underlineposition = $font->underlineposition() + +=over Return the font's underlineposition value. +=back + =cut sub underlineposition { return $_[0]->data()->{'underlineposition'}; } -=item $underlinethickness = $font->underlinethickness() +=head2 underlinethickness + + $underlinethickness = $font->underlinethickness() + +=over Return the font's underlinethickness value. +=back + =cut sub underlinethickness { return $_[0]->data()->{'underlinethickness'}; } -=item $ascender = $font->ascender() +=head2 ascender + + $ascender = $font->ascender() + +=over Return the font's ascender value. +=back + =cut sub ascender { return $_[0]->data()->{'ascender'}; } -=item $descender = $font->descender() +=head2 descender + + $descender = $font->descender() + +=over Return the font's descender value. +=back + =cut sub descender { return $_[0]->data()->{'descender'}; } -=back - =head1 GLYPH-RELATED METHODS -=over 4 +=head2 glyphNames -=item @names = $font->glyphNames() + @names = $font->glyphNames() + +=over Return the defined glyph names of the font. +=back + =cut sub glyphNames { return keys %{$_[0]->data()->{'wx'}}; } -=item $glNum = $font->glyphNum() +=head2 glyphNum + + $glNum = $font->glyphNum() + +=over Return the number of defined glyph names of the font. +=back + =cut sub glyphNum { @@ -469,10 +605,16 @@ sub glyphNum { return scalar keys %{$_[0]->data()->{'wx'}}; } -=item $uni = $font->uniByGlyph($char) +=head2 uniByGlyph + + $uni = $font->uniByGlyph($char) + +=over Return the unicode by glyph name. +=back + =cut sub uniByGlyph { @@ -481,10 +623,16 @@ sub uniByGlyph { return $_[0]->data()->{'n2u'}->{$_[1]}; } -=item $uni = $font->uniByEnc($char) +=head2 uniByEnc + + $uni = $font->uniByEnc($char) + +=over Return the Unicode by the font's encoding map. +=back + =cut sub uniByEnc { @@ -495,30 +643,48 @@ sub uniByEnc { return $uni; } -=item $uni = $font->uniByMap($char) +=head2 uniByMap + + $uni = $font->uniByMap($char) + +=over Return the Unicode by the font's default map. +=back + =cut sub uniByMap { return $_[0]->data()->{'uni'}->[$_[1]]; } -=item $char = $font->encByGlyph($glyph) +=head2 encByGlyph + + $char = $font->encByGlyph($glyph) + +=over Return the character by the given glyph name of the font's encoding map. +=back + =cut sub encByGlyph { return $_[0]->data()->{'n2e'}->{$_[1]} || 0; } -=item $char = $font->encByUni($uni) +=head2 encByUni + + $char = $font->encByUni($uni) + +=over Return the character by the given Unicode of the font's encoding map. +=back + =cut sub encByUni { @@ -527,65 +693,101 @@ sub encByUni { 0; } -=item $char = $font->mapByGlyph($glyph) +=head2 mapByGlyph + + $char = $font->mapByGlyph($glyph) + +=over Return the character by the given glyph name of the font's default map. +=back + =cut sub mapByGlyph { return $_[0]->data()->{'n2c'}->{$_[1]} || 0; } -=item $char = $font->mapByUni($uni) +=head2 mapByUni + + $char = $font->mapByUni($uni) + +=over Return the character by the given Unicode of the font's default map. +=back + =cut sub mapByUni { return $_[0]->data()->{'u2c'}->{$_[1]} || 0; } -=item $name = $font->glyphByUni($unicode) +=head2 glyphByUni + + $name = $font->glyphByUni($unicode) + +=over Return the glyph's name by the font's Unicode map. B<CAUTION:> non-standard glyph-names are mapped onto the ms-symbol area (0xF000). +=back + =cut sub glyphByUni { return $_[0]->data()->{'u2n'}->{$_[1]} || '.notdef'; } -=item $name = $font->glyphByEnc($char) +=head2 glyphByEnc + + $name = $font->glyphByEnc($char) + +=over Return the glyph's name by the font's encoding map. +=back + =cut sub glyphByEnc { return $_[0]->data()->{'e2n'}->[$_[1]]; } -=item $name = $font->glyphByMap($char) +=head2 glyphByMap + + $name = $font->glyphByMap($char) + +=over Return the glyph's name by the font's default map. +=back + =cut sub glyphByMap { return $_[0]->data()->{'char'}->[$_[1]]; } -=item $width = $font->wxByGlyph($glyph) +=head2 wxByGlyph + + $width = $font->wxByGlyph($glyph) + +=over Return the glyph's width. This is a value, that when divided by 1000 and multiplied by the font size (height in points), gives the advance width to the next character's start. Typically, the width will be under 1000. +=back + =cut sub wxByGlyph { @@ -604,13 +806,19 @@ sub wxByGlyph { return $width; } -=item $width = $font->wxByUni($uni) +=head2 wxByUni + + $width = $font->wxByUni($uni) + +=over Return the Unicode character's width. This is a value, that when divided by 1000 and multiplied by the font size (height in points), gives the advance width to the next character's start. Typically, the width will be under 1000. +=back + =cut sub wxByUni { @@ -625,13 +833,19 @@ sub wxByUni { return $width; } -=item $width = $font->wxByEnc($char) +=head2 wxByEnc + + $width = $font->wxByEnc($char) + +=over Return the character's width based on the current encoding. This is a value, that when divided by 1000 and multiplied by the font size (height in points), gives the advance width to the next character's start. Typically, the width will be under 1000. +=back + =cut sub wxByEnc { @@ -648,11 +862,17 @@ sub wxByEnc { return $width; } -=item $flag = $font->wxMissingByEnc($char) +=head2 wxMissingByEnc + + $flag = $font->wxMissingByEnc($char) + +=over Return true if the character's width (based on the current encoding) is supplied by "missing width" of font. +=back + =cut sub wxMissingByEnc { @@ -664,13 +884,19 @@ sub wxMissingByEnc { return !defined($width); } -=item $width = $font->wxByMap($char) +=head2 wxByMap + + $width = $font->wxByMap($char) + +=over Return the character's width based on the font's default encoding. This is a value, that when divided by 1000 and multiplied by the font size (height in points), gives the advance width to the next character's start. Typically, the width will be under 1000. +=back + =cut sub wxByMap { @@ -686,12 +912,18 @@ sub wxByMap { return $width; } -=item $wd = $font->width($text) +=head2 width + + $wd = $font->width($text) -Return the width of $text as if it were at size 1. +=over + +Return the width of $text as if it were at font size 1 (unscaled). B<CAUTION:> works correctly only if a proper Perl string is used, either in native or UTF-8 format (check utf8-flag). +=back + =cut sub width { @@ -716,10 +948,16 @@ sub width { return $width; } -=item @widths = $font->width_array($text) +=head2 width_array + + @widths = $font->width_array($text) + +=over Return (as an array) the widths of the words in $text as if they were at size 1. +=back + =cut sub width_array { @@ -730,16 +968,16 @@ sub width_array { return @widths; } -=back +=head2 utfByStr -=head1 STRING METHODS + $utf8string = $font->utfByStr($string) =over -=item $utf8string = $font->utfByStr($string) - Return the utf8-string from string based on the font's encoding map. +=back + =cut sub utfByStr { @@ -750,10 +988,16 @@ sub utfByStr { return $string; } -=item $string = $font->strByUtf($utf8_string) +=head2 strByUtf + + $string = $font->strByUtf($utf8_string) + +=over Return the encoded string from utf8-string based on the font's encoding map. +=back + =cut sub strByUtf { @@ -764,10 +1008,16 @@ sub strByUtf { return $utf8_string; } -=item $pdf_string = $font->textByStr($string) +=head2 textByStr + + $pdf_string = $font->textByStr($string) + +=over Return a properly formatted representation of $string for use in the PDF. +=back + =cut sub textByStr { @@ -783,11 +1033,17 @@ sub textByStr { return $text; } -=item $pdf_string = $font->textByStrKern($string) +=head2 textByStrKern + + $pdf_string = $font->textByStrKern($string) + +=over Return a properly formatted representation of $string, with kerning, for use in the PDF. +=back + =cut sub textByStrKern { @@ -844,8 +1100,4 @@ sub isvirtual { return; } -=back - -=cut - 1; diff --git a/lib/PDF/Builder/Resource/CIDFont.pm b/lib/PDF/Builder/Resource/CIDFont.pm index 3857fc8..7ad0c58 100644 --- a/lib/PDF/Builder/Resource/CIDFont.pm +++ b/lib/PDF/Builder/Resource/CIDFont.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::BaseFont'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use Encode qw(:all); @@ -19,12 +19,16 @@ PDF::Builder::Resource::CIDFont - Base class for CID fonts =head1 METHODS -=over +=head2 new + + $font = PDF::Builder::Resource::CIDFont->new($pdf, $name) -=item $font = PDF::Builder::Resource::CIDFont->new($pdf, $name) +=over Returns a cid-font object, base class for all CID-based fonts. +=back + =cut sub new { @@ -129,10 +133,16 @@ sub width_cid { return $width; } -=item $cidstring = $font->cidsByStr($string) +=head2 cidsByStr + + $cidstring = $font->cidsByStr($string) + +=over Returns the cid-string from string based on the font's encoding map. +=back + =cut sub _cidsByStr { @@ -171,10 +181,16 @@ sub cidsByStr { return $text; } -=item $cidstring = $font->cidsByUtf($utf8string) +=head2 cidsByUtf + + $cidstring = $font->cidsByUtf($utf8string) + +=over Returns the CID-encoded string from utf8-string. +=back + =cut sub cidsByUtf { @@ -204,19 +220,50 @@ sub textByStrKern { sub text { my ($self, $text, $size, $indent) = @_; - my $newtext = $self->textByStr($text); - if (defined $size && $self->{'-dokern'}) { - $newtext = $self->textByStrKern($text, $size, $indent); - return $newtext; - } elsif (defined $size) { - if (defined($indent) && $indent!=0) { - return("[ $indent $newtext ] TJ"); - } else { - return "$newtext Tj"; - } - } else { - return $newtext; + # need to break up $text into fragments ending with x20 + # TBD: handle other spaces (espec. xA0) "appropriately" (control by flag) + # 0 = x20 space only + # 1 (default) = x20 and same/longer spaces + # 2 = all spaces + # the problem is, other font types handle only x20 in Reader + my $latest_page = $self->{' apipdf'}->{' outlist'}[0]->{'Pages'}->{'Kids'}->{' val'}[-1]; + my $wordspace = $latest_page->{'Contents'}->{' val'}[0]->{' wordspace'}; + my $fontsize = $latest_page->{'Contents'}->{' val'}[0]->{' fontsize'}; + my @fragments = ( $text ); # default for wordspace = 0 + # TBD: get list of different lengths of spaces found, split on all of them + # could have null fragments where two or more spaces in a row, or + # text ended with a space + if ($wordspace) { + # split appears to drop trailing blanks, so need a guard + @fragments = split / /, $text."|"; + chop($fragments[-1]); } + + my $out_str = ''; + for (my $i = 0; $i <= $#fragments; $i++) { + if ($fragments[$i] ne '') { + my $newtext = $self->textByStr($fragments[$i]); # '<glyphIDsList>' + if (defined $size && $self->{'-dokern'}) { + $newtext = $self->textByStrKern($fragments[$i], $size, $indent); + $out_str .= $newtext; + } elsif (defined $size) { + if (defined($indent) && $indent!=0) { + $out_str .= "[ $indent $newtext ] TJ"; + } else { + $out_str .= "$newtext Tj"; + } + } else { + $out_str .= $newtext; + } + } + # unless this is the last fragment (no space follows), add a "kerned" + # space to out_str (reduce its effective width by moving left). + # TBD: different spaces of different lengths with different "kerns" + if ($i < $#fragments) { + $out_str .= "[ ".$self->textByStrKern(' ')." ".(-$wordspace/$fontsize*1000)." ] TJ"; + } + } + return $out_str; } sub text_cid { @@ -337,8 +384,4 @@ sub glyphNum { # return $self->SUPER::outobjdeep($fh, $pdf, %opts); #} -=back - -=cut - 1; diff --git a/lib/PDF/Builder/Resource/CIDFont/CJKFont.pm b/lib/PDF/Builder/Resource/CIDFont/CJKFont.pm index 822200f..7c3665e 100644 --- a/lib/PDF/Builder/Resource/CIDFont/CJKFont.pm +++ b/lib/PDF/Builder/Resource/CIDFont/CJKFont.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::CIDFont'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use PDF::Builder::Util; use PDF::Builder::Basic::PDF::Utils; @@ -22,29 +22,49 @@ PDF::Builder::Resource::CIDFont::CJKFont - Base class for CJK fonts =head1 METHODS -=over +=head2 new + + $font = PDF::Builder::Resource::CIDFont::CJKFont->new($pdf, $cjkname, %options) -=item $font = PDF::Builder::Resource::CIDFont::CJKFont->new($pdf, $cjkname, %options) +=over Returns a cjk-font object. +=back + =over -* Traditional Chinese: Ming Ming-Bold Ming-Italic Ming-BoldItalic +=item * + +Traditional Chinese: Ming, Ming-Bold, Ming-Italic, Ming-BoldItalic + +=item * + +Simplified Chinese: Song, Song-Bold, Song-Italic, Song-BoldItalic + +=item * + +Korean: MyungJo, MyungJo-Bold, MyungJo-Italic, MyungJo-BoldItalic -* Simplified Chinese: Song Song-Bold Song-Italic Song-BoldItalic +=item * -* Korean: MyungJo MyungJo-Bold MyungJo-Italic MyungJo-BoldItalic +Japanese (Mincho): KozMin, KozMin-Bold, KozMin-Italic, KozMin-BoldItalic -* Japanese (Mincho): KozMin KozMin-Bold KozMin-Italic KozMin-BoldItalic +=item * -* Japanese (Gothic): KozGo KozGo-Bold KozGo-Italic KozGo-BoldItalic +Japanese (Gothic): KozGo, KozGo-Bold, KozGo-Italic, KozGo-BoldItalic =back Defined Options: - encode ... specify fonts encoding for non-utf8 text. +=over + +=item encode + +specify fonts encoding for non-utf8 text. + +=back =cut @@ -319,8 +339,4 @@ BEGIN { } -=back - -=cut - 1; diff --git a/lib/PDF/Builder/Resource/CIDFont/TrueType.pm b/lib/PDF/Builder/Resource/CIDFont/TrueType.pm index 4d2bf0a..89cad31 100644 --- a/lib/PDF/Builder/Resource/CIDFont/TrueType.pm +++ b/lib/PDF/Builder/Resource/CIDFont/TrueType.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::CIDFont'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use PDF::Builder::Basic::PDF::Utils; use PDF::Builder::Resource::CIDFont::TrueType::FontFile; @@ -18,9 +18,11 @@ PDF::Builder::Resource::CIDFont::TrueType - TrueType font support =head1 METHODS -=over +=head2 new + + $font = PDF::Builder::Resource::CIDFont::TrueType->new($pdf, $file, %options) -=item $font = PDF::Builder::Resource::CIDFont::TrueType->new($pdf, $file, %options) +=over Returns a font object. @@ -31,6 +33,8 @@ Defined Options: nosubset ... disables subsetting. Any value causes the full font to be embedded, rather than only the glyphs needed. +=back + =cut sub new { @@ -82,14 +86,50 @@ sub new { return $self; } +=head2 fontfile + + $font->fontfile() + +=over + +Returns font file object (' ff' element), so its methods may be invoked. + +=back + +=cut + sub fontfile { return $_[0]->{' ff'}; } +=head2 fontobj + + $font->fontobj() + +=over + +Returns font object, so its methods and properties may be used. + +=back + +=cut + sub fontobj { return $_[0]->data()->{'obj'}; } +=head2 wxByCId + + $font->wxByCId($gID) + +=over + +Returns unscaled glyph width, given the glyph ID (CID). + +=back + +=cut + sub wxByCId { my ($self, $g) = @_; @@ -105,18 +145,57 @@ sub wxByCId { return $w; } +=head2 haveKernPairs + + $flag = $font->haveKernPairs() + +=over + +Does the font include kerning data? Invokes fontfile's haveKernPairs(). +Not clear what additional optional arguments are. + +=back + +=cut + sub haveKernPairs { my $self = shift; return $self->fontfile()->haveKernPairs(@_); } +=head2 kernPairCid + + $flag = $font->kernPairCid($gID, $n) + +=over + +Returns kerning information for? Not clear what additional arguments are. +Invokes fontfile's kernPairCid() method. + +=back + +=cut + sub kernPairCid { my $self = shift; return $self->fontfile()->kernPairCid(@_); } +=head2 subsetByCid + + $font->subsetByCid($gID) + +=over + +Invokes subsetByCId() method from fontfile() to put the glyph into the embedded +font cache in the PDF. + +=back + +=cut + sub subsetByCId { my $self = shift; @@ -125,6 +204,18 @@ sub subsetByCId { return $self->fontfile()->subsetByCId($g); } +=head2 subvec + + $font->subvec($gID) + +=over + +(No Information) invokes fontfile's subvec() method. + +=back + +=cut + sub subvec { my $self = shift; @@ -133,10 +224,34 @@ sub subvec { return $self->fontfile()->subvec($g); } +=head2 glyphNum + + $count = $font->glyphNum() + +=over + +Number of glyphs in the font. + +=back + +=cut + sub glyphNum { return $_[0]->fontfile()->glyphNum(); } +=head2 outobjdeep + + $font->outobjdeep() + +=over + +(No Information) output to PDF + +=back + +=cut + sub outobjdeep { my ($self, $fh, $pdf) = @_; @@ -176,8 +291,4 @@ sub outobjdeep { return $self->SUPER::outobjdeep($fh, $pdf); } -=back - -=cut - 1; diff --git a/lib/PDF/Builder/Resource/CIDFont/TrueType/FontFile.pm b/lib/PDF/Builder/Resource/CIDFont/TrueType/FontFile.pm index 82c25d7..9b8ba17 100644 --- a/lib/PDF/Builder/Resource/CIDFont/TrueType/FontFile.pm +++ b/lib/PDF/Builder/Resource/CIDFont/TrueType/FontFile.pm @@ -5,7 +5,7 @@ use base 'PDF::Builder::Basic::PDF::Dict'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.025'; # manually update whenever code is changed use Carp; diff --git a/lib/PDF/Builder/Resource/ColorSpace.pm b/lib/PDF/Builder/Resource/ColorSpace.pm index aa22011..d494a51 100644 --- a/lib/PDF/Builder/Resource/ColorSpace.pm +++ b/lib/PDF/Builder/Resource/ColorSpace.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Basic::PDF::Array'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use PDF::Builder::Basic::PDF::Utils; use PDF::Builder::Util; @@ -18,12 +18,16 @@ PDF::Builder::Resource::ColorSpace - Base class for PDF color spaces =head1 METHODS -=over +=head2 new + + $cs = PDF::Builder::Resource::ColorSpace->new($pdf, $key, %opts) -=item $cs = PDF::Builder::Resource::ColorSpace->new($pdf, $key, %opts) +=over Returns a new colorspace object, base class for all colorspaces. +=back + =cut sub new { @@ -39,12 +43,18 @@ sub new { return $self; } -=item $name = $res->name($name) # Set +=head2 name -=item $name = $res->name() # Get + $name = $res->name($name) # Set + + $name = $res->name() # Get + +=over Returns or sets the Name of the resource. +=back + =cut sub name { @@ -65,10 +75,16 @@ sub type { return $self->{' type'}; } -=item @param = $cs->param(@param) +=head2 param + + @param = $cs->param(@param) + +=over Returns properly formatted color-parameters based on the colorspace. +=back + =cut sub param { @@ -87,8 +103,4 @@ sub param { # return $self->SUPER::outobjdeep(@opts); #} -=back - -=cut - 1; diff --git a/lib/PDF/Builder/Resource/ColorSpace/DeviceN.pm b/lib/PDF/Builder/Resource/ColorSpace/DeviceN.pm index adc918e..dc8a547 100644 --- a/lib/PDF/Builder/Resource/ColorSpace/DeviceN.pm +++ b/lib/PDF/Builder/Resource/ColorSpace/DeviceN.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::ColorSpace'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use PDF::Builder::Basic::PDF::Utils; use PDF::Builder::Util; @@ -17,6 +17,16 @@ use Scalar::Util qw(weaken); PDF::Builder::Resource::ColorSpace::DeviceN - colorspace handling for Device CMYK. Inherits from L<PDF::Builder::Resource::ColorSpace> +=head2 new + + PDF::Builder::Resource::ColorSpace:DeviceN->new($pdf, $key, $clrs) + +=over + +Create a new DeviceN ColorSpace object. + +=back + =cut sub new { diff --git a/lib/PDF/Builder/Resource/ColorSpace/Indexed.pm b/lib/PDF/Builder/Resource/ColorSpace/Indexed.pm index 884b6e8..7220af5 100644 --- a/lib/PDF/Builder/Resource/ColorSpace/Indexed.pm +++ b/lib/PDF/Builder/Resource/ColorSpace/Indexed.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::ColorSpace'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use PDF::Builder::Basic::PDF::Utils; use PDF::Builder::Util; @@ -16,6 +16,16 @@ use Scalar::Util qw(weaken); PDF::Builder::Resource::ColorSpace::Indexed - base colorspace support for indexed color models. Inherits from L<PDF::Builder::Resource::ColorSpace> +=head2 new + + PDF::Builder::Resource::ColorSpace::Indexed->new($pdf, $key, %opts) + +=over + +Create a new Indexed ColorSpace object. + +=back + =cut sub new { @@ -33,6 +43,8 @@ sub new { return $self; } +# unknown -- not used anywhere + sub enumColors { my $self = shift; @@ -45,6 +57,8 @@ sub enumColors { return %col; } +# unknown -- not used anywhere + sub nameColor { my ($self, $n) = @_; @@ -54,6 +68,8 @@ sub nameColor { return $k; } +# unknown -- not used anywhere + sub resolveNearestRGB { my $self = shift; my ($r, $g, $b) = @_; # need to be in 0-255 diff --git a/lib/PDF/Builder/Resource/ColorSpace/Indexed/ACTFile.pm b/lib/PDF/Builder/Resource/ColorSpace/Indexed/ACTFile.pm index 4cc3532..1117f4f 100644 --- a/lib/PDF/Builder/Resource/ColorSpace/Indexed/ACTFile.pm +++ b/lib/PDF/Builder/Resource/ColorSpace/Indexed/ACTFile.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::ColorSpace::Indexed'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use PDF::Builder::Basic::PDF::Utils; use PDF::Builder::Util; @@ -18,9 +18,11 @@ PDF::Builder::Resource::ColorSpace::Indexed::ACTFile - Adobe Color Table support =head1 METHODS -=over +=head2 new + + $cs = PDF::Builder::Resource::ColorSpace::Indexed::ACTFile->new($pdf, $actfile) -=item $cs = PDF::Builder::Resource::ColorSpace::Indexed::ACTFile->new($pdf, $actfile) +=over Returns a new colorspace object created from an adobe color table file (ACT/8BCT). See @@ -29,6 +31,8 @@ File Formats Specification Version 6.0 Release 2, November 2000 for details. +=back + =cut sub new { @@ -63,8 +67,4 @@ sub new { return $self; } -=back - -=cut - 1; diff --git a/lib/PDF/Builder/Resource/ColorSpace/Indexed/Hue.pm b/lib/PDF/Builder/Resource/ColorSpace/Indexed/Hue.pm index 4ba76d0..2d2b54f 100644 --- a/lib/PDF/Builder/Resource/ColorSpace/Indexed/Hue.pm +++ b/lib/PDF/Builder/Resource/ColorSpace/Indexed/Hue.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::ColorSpace::Indexed'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use PDF::Builder::Basic::PDF::Utils; use PDF::Builder::Util; @@ -16,6 +16,16 @@ use Scalar::Util qw(weaken); PDF::Builder::Resource::ColorSpace::Indexed::Hue - colorspace support for Device RGB. Inherits from L<PDF::Builder::Resource::ColorSpace::Indexed> +=head1 METHODS + +=head2 new + +=over + +Create a new Indexed Hue colorspace object. + +=back + =cut sub new { diff --git a/lib/PDF/Builder/Resource/ColorSpace/Indexed/WebColor.pm b/lib/PDF/Builder/Resource/ColorSpace/Indexed/WebColor.pm index d7e30d0..d4c21d6 100644 --- a/lib/PDF/Builder/Resource/ColorSpace/Indexed/WebColor.pm +++ b/lib/PDF/Builder/Resource/ColorSpace/Indexed/WebColor.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::ColorSpace::Indexed'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed =head1 NAME @@ -18,6 +18,20 @@ use PDF::Builder::Basic::PDF::Utils; use PDF::Builder::Util; use Scalar::Util qw(weaken); +=head1 METHODS + +=head2 new + + PDF::Builder::Resource::ColorSpace::Indexed::WebColor->new() + +=over + +Create a new "web-safe" indexed colorspace object. + +=back + +=cut + sub new { my ($class, $pdf) = @_; diff --git a/lib/PDF/Builder/Resource/ColorSpace/Separation.pm b/lib/PDF/Builder/Resource/ColorSpace/Separation.pm index 5d63931..dc47a14 100644 --- a/lib/PDF/Builder/Resource/ColorSpace/Separation.pm +++ b/lib/PDF/Builder/Resource/ColorSpace/Separation.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::ColorSpace'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use PDF::Builder::Basic::PDF::Utils; use PDF::Builder::Util; @@ -18,12 +18,16 @@ PDF::Builder::Resource::ColorSpace::Separation - Support for color space separat =head1 METHODS -=over +=head2 new + + $cs = PDF::Builder::Resource::ColorSpace::Separation->new($pdf, $key, @colors) -=item $cs = PDF::Builder::Resource::ColorSpace::Separation->new($pdf, $key, @colors) +=over Returns a new colorspace object. +=back + =cut sub new { @@ -114,10 +118,16 @@ sub new { return $self; } -=item @color = $res->color() +=head2 color + + @color = $res->color() + +=over Returns the base-color of the Separation-Colorspace. +=back + =cut sub color { @@ -129,10 +139,16 @@ sub color { return @{$self->{' color'}}; } -=item $tintname = $res->tintname($tintname) +=head2 tintname + + $tintname = $res->tintname($tintname) + +=over Returns the tint-name of the Separation-Colorspace. +=back + =cut sub tintname { @@ -150,8 +166,4 @@ sub param { return $_[0]; } -=back - -=cut - 1; diff --git a/lib/PDF/Builder/Resource/Colors.pm b/lib/PDF/Builder/Resource/Colors.pm index 0ec5c0b..e942fac 100644 --- a/lib/PDF/Builder/Resource/Colors.pm +++ b/lib/PDF/Builder/Resource/Colors.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Colors; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.024'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/ExtGState.pm b/lib/PDF/Builder/Resource/ExtGState.pm index c1facb4..30e47be 100644 --- a/lib/PDF/Builder/Resource/ExtGState.pm +++ b/lib/PDF/Builder/Resource/ExtGState.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use PDF::Builder::Basic::PDF::Utils; use PDF::Builder::Util; @@ -17,12 +17,16 @@ PDF::Builder::Resource::ExtGState - Graphics state dictionary support =head1 METHODS -=over +=head2 new + + $egs = PDF::Builder::Resource::ExtGState->new(@parameters) -=item $egs = PDF::Builder::Resource::ExtGState->new(@parameters) +=over Returns a new extgstate object (called from $pdf->egstate()). +=back + =cut sub new { @@ -34,7 +38,15 @@ sub new { return $self; } -=item $egs->strokeadjust($boolean) +=head2 strokeadjust + + $egs->strokeadjust($boolean) + +=over + +(No information) + +=back =cut @@ -45,7 +57,15 @@ sub strokeadjust { return $self; } -=item $egs->strokeoverprint($boolean) +=head2 strokeoverprint + + $egs->strokeoverprint($boolean) + +=over + +(No information) + +=back =cut @@ -56,7 +76,15 @@ sub strokeoverprint { return $self; } -=item $egs->filloverprint($boolean) +=head2 filloverprint + + $egs->filloverprint($boolean) + +=over + +(No information) + +=back =cut @@ -67,7 +95,15 @@ sub filloverprint { return $self; } -=item $egs->overprintmode($num) +=head2 overprintmode + + $egs->overprintmode($num) + +=over + +(No information) + +=back =cut @@ -78,7 +114,15 @@ sub overprintmode { return $self; } -=item $egs->blackgeneration($obj) +=head2 blackgeneration + + $egs->blackgeneration($obj) + +=over + +(No information) + +=back =cut @@ -89,7 +133,15 @@ sub blackgeneration { return $self; } -=item $egs->blackgeneration2($obj) +=head2 blackgeneration2 + + $egs->blackgeneration2($obj) + +=over + +(No information) + +=back =cut @@ -100,7 +152,15 @@ sub blackgeneration2 { return $self; } -=item $egs->undercolorremoval($obj) +=head2 undercolorremoval + + $egs->undercolorremoval($obj) + +=over + +(No information) + +=back =cut @@ -111,7 +171,15 @@ sub undercolorremoval { return $self; } -=item $egs->undercolorremoval2($obj) +=head2 undercolorremoval2 + + $egs->undercolorremoval2($obj) + +=over + +(No information) + +=back =cut @@ -122,7 +190,15 @@ sub undercolorremoval2 { return $self; } -=item $egs->transfer($obj) +=head2 transfer + + $egs->transfer($obj) + +=over + +(No information) + +=back =cut @@ -133,7 +209,15 @@ sub transfer { return $self; } -=item $egs->transfer2($obj) +=head2 transfer2 + + $egs->transfer2($obj) + +=over + +(No information) + +=back =cut @@ -144,7 +228,15 @@ sub transfer2 { return $self; } -=item $egs->halftone($obj) +=head2 halftone + + $egs->halftone($obj) + +=over + +(No information) + +=back =cut @@ -155,7 +247,15 @@ sub halftone { return $self; } -=item $egs->halftonephase($obj) +=head2 halftonephase + + $egs->halftonephase($obj) + +=over + +(No information) + +=back =cut @@ -168,7 +268,15 @@ sub halftonephase { return $self; } -=item $egs->smoothness($num) +=head2 smoothness + + $egs->smoothness($num) + +=over + +(No information) + +=back =cut @@ -179,7 +287,15 @@ sub smoothness { return $self; } -=item $egs->font($font, $size) +=head2 font + + $egs->font($font, $size) + +=over + +(No information) + +=back =cut @@ -190,7 +306,15 @@ sub font { return $self; } -=item $egs->linewidth($size) +=head2 linewidth + + $egs->linewidth($size) + +=over + +(No information) + +=back =cut @@ -201,7 +325,15 @@ sub linewidth { return $self; } -=item $egs->linecap($cap) +=head2 linecap + + $egs->linecap($cap) + +=over + +(No information) + +=back =cut @@ -212,7 +344,15 @@ sub linecap { return $self; } -=item $egs->linejoin($join) +=head2 linejoin + + $egs->linejoin($join) + +=over + +(No information) + +=back =cut @@ -223,7 +363,15 @@ sub linejoin { return $self; } -=item $egs->miterlimit($limit) +=head2 miterlimit + + $egs->miterlimit($limit) + +=over + +(No information) + +=back =cut @@ -236,7 +384,15 @@ sub miterlimit { # Note: miterlimit was originally named incorrectly as meterlimit, renamed -=item $egs->dash(@dash) +=head2 dash + + $egs->dash(@dash) + +=over + +(No information) + +=back =cut @@ -247,7 +403,15 @@ sub dash { return $self; } -=item $egs->flatness($flat) +=head2 flatness + + $egs->flatness($flat) + +=over + +(No information) + +=back =cut @@ -258,7 +422,15 @@ sub flatness { return $self; } -=item $egs->renderingintent($intentName) +=head2 renderingintent + + $egs->renderingintent($intentName) + +=over + +(No information) + +=back =cut @@ -269,12 +441,18 @@ sub renderingintent { return $self; } -=item $egs->strokealpha($alpha) +=head2 strokealpha + + $egs->strokealpha($alpha) + +=over The current stroking alpha constant, specifying the constant shape or constant opacity value to be used for stroking operations in the transparent imaging model. +=back + =cut sub strokealpha { @@ -284,10 +462,16 @@ sub strokealpha { return $self; } -=item $egs->fillalpha($alpha) +=head2 fillalpha + + $egs->fillalpha($alpha) + +=over Same as strokealpha, but for nonstroking (fill) operations. +=back + =cut sub fillalpha { @@ -297,12 +481,18 @@ sub fillalpha { return $self; } -=item $egs->blendmode($blendname) +=head2 blendmode + + $egs->blendmode($blendname) -=item $egs->blendmode($blendfunctionobj) + $egs->blendmode($blendfunctionobj) + +=over The current blend mode to be used in the transparent imaging model. +=back + =cut sub blendmode { @@ -316,13 +506,19 @@ sub blendmode { return $self; } -=item $egs->alphaisshape($boolean) +=head2 alphaisshape + + $egs->alphaisshape($boolean) + +=over The alpha source flag (alpha is shape), specifying whether the current soft mask and alpha constant are to be interpreted as shape values (I<true>) or opacity values (I<false>). +=back + =cut sub alphaisshape { @@ -332,12 +528,18 @@ sub alphaisshape { return $self; } -=item $egs->textknockout($boolean) +=head2 textknockout + + $egs->textknockout($boolean) + +=over The text knockout flag, which determines the behavior of overlapping glyphs within a text object in the transparent imaging model. +=back + =cut sub textknockout { @@ -347,12 +549,18 @@ sub textknockout { return $self; } -=item $egs->transparency($t) +=head2 transparency + + $egs->transparency($t) + +=over The graphics transparency, with 0 being fully opaque and 1 being fully transparent. This is a convenience method, setting proper values for C<strokealpha> and C<fillalpha>. +=back + =cut sub transparency { @@ -363,12 +571,18 @@ sub transparency { return $self; } -=item $egs->opacity($op) +=head2 opacity + + $egs->opacity($op) + +=over The graphics opacity, with 1 being fully opaque and 0 being fully transparent. This is a convenience method, setting proper values for C<strokealpha> and C<fillalpha>. +=back + =cut sub opacity { @@ -389,8 +603,4 @@ sub opacity { # return $self->SUPER::outobjdeep(@opts); #} -=back - -=cut - 1; diff --git a/lib/PDF/Builder/Resource/Font.pm b/lib/PDF/Builder/Resource/Font.pm index d493940..fb1b88e 100644 --- a/lib/PDF/Builder/Resource/Font.pm +++ b/lib/PDF/Builder/Resource/Font.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::BaseFont'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use Encode qw(:all); @@ -17,6 +17,18 @@ use PDF::Builder::Basic::PDF::Utils; PDF::Builder::Resource::Font - some common support routines for font files. Inherits from L<PDF::Builder::Resource::BaseFont> +=head1 METHODS + +=head2 encodeByData + + $font->encodeByData($enc) + +=over + +(No Information) + +=back + =cut sub encodeByData { @@ -102,11 +114,11 @@ sub encodeByData { return $self; } -=head1 METHODS +=head2 automap -=over + $font->automap() -=item $font->automap() +=over This applies to core fonts (C<< $pdf->corefont() >>) and PostScript fonts (C<< $pdf->psfont() >>). These cannot use UTF-8 (or other multibyte character) @@ -222,6 +234,18 @@ sub automap { return @fonts; } +=head2 remap + + $font->remap($enc) + +=over + +(No Information) + +=back + +=cut + sub remap { my ($self, $enc) = @_; diff --git a/lib/PDF/Builder/Resource/Font/BdFont.pm b/lib/PDF/Builder/Resource/Font/BdFont.pm index bb4c23e..ffb026f 100644 --- a/lib/PDF/Builder/Resource/Font/BdFont.pm +++ b/lib/PDF/Builder/Resource/Font/BdFont.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::Font'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use PDF::Builder::Util; use PDF::Builder::Basic::PDF::Utils; @@ -40,14 +40,16 @@ for body text! =head1 METHODS -=over 4 +=head2 new -=cut + $font = PDF::Builder::Resource::Font::BdFont->new($pdf, $font, %options) -=item $font = PDF::Builder::Resource::Font::BdFont->new($pdf, $font, %options) +=over Returns a BmpFont object. +=back + =cut #I<encode> @@ -438,8 +440,6 @@ sub filled_circle { __END__ -=back - =head1 AUTHOR Alfred Reibenschuh, extensively rewritten by Phil Perry diff --git a/lib/PDF/Builder/Resource/Font/CoreFont.pm b/lib/PDF/Builder/Resource/Font/CoreFont.pm index f615f9a..4c4da67 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::Font'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use File::Basename; @@ -38,9 +38,11 @@ PDF::Builder::Resource::Font::CoreFont - Module for using the 14 standard PDF bu =head1 METHODS -=over +=head2 new + + $font = PDF::Builder::Resource::Font::CoreFont->new($pdf, $fontname, %options) -=item $font = PDF::Builder::Resource::Font::CoreFont->new($pdf, $fontname, %options) +=over Returns a corefont object. @@ -48,12 +50,15 @@ Valid %options are: =over -I<encode> -... changes the encoding of the font from its default. +=item encode + +Changes the encoding of the font from its default. See I<perl's Encode> for the supported values. B<Warning:> only single byte encodings are permitted. Multibyte encodings such as 'utf8' are forbidden. -I<pdfname> ... changes the reference-name of the font from its default. +=item pdfname + +Changes the reference-name of the font from its default. The reference-name is normally generated automatically and can be retrieved via C<$pdfname=$font->name()>. @@ -67,23 +72,19 @@ B<standard PDF types> =over -=over - -=item * helvetica helveticaoblique helveticabold helvetiaboldoblique +=item * helvetica, helveticaoblique, helveticabold, helvetiaboldoblique May have Arial substituted on some systems (e.g., Windows) -=item * courier courieroblique courierbold courierboldoblique +=item * courier, courieroblique, courierbold, courierboldoblique Fixed pitch, may have Courier New substituted on some systems (e.g., Windows) -=item * timesroman timesitalic timesbold timesbolditalic +=item * timesroman, timesitalic, timesbold, timesbolditalic May have Times New Roman substituted on some systems (e.g., Windows) -=item * symbol zapfdingbats - -=back +=item * symbol, zapfdingbats =back @@ -91,21 +92,17 @@ B<Primarily Windows typefaces> =over -=over - -=item * georgia georgiaitalic georgiabold georgiabolditalic - -=item * verdana verdanaitalic verdanabold verdanabolditalic +=item * georgia, georgiaitalic, georgiabold, georgiabolditalic -=item * trebuchet trebuchetitalic trebuchetbold trebuchetbolditalic +=item * verdana, verdanaitalic, verdanabold, verdanabolditalic -=item * bankgothic bankgothicitalic bankgothicbold bankgothicitalic +=item * trebuchet, trebuchetitalic, trebuchetbold, trebuchetbolditalic -Free versions of Bank Gothic are often only medium weight. +=item * bankgothic, bankgothicitalic, bankgothicbold, bankgothicitalic -=item * webdings wingdings +Free versions of Bank Gothic are often only medium weight Roman (bankgothic). -=back +=item * webdings, wingdings =back @@ -253,13 +250,17 @@ sub new { return $self; } -=over +=head2 is_standard + + $bool = $class->is_standard($name) -=item $bool = $class->is_standard($name) +=over Returns true if C<$name> is an exact, case-sensitive match for one of the standard font names shown above. +=back + =cut sub is_standard { @@ -288,10 +289,16 @@ sub is_standard { return; } -=item PDF::Builder::Resource::Font::CoreFont->loadallfonts() +=head2 loadallfonts + + PDF::Builder::Resource::Font::CoreFont->loadallfonts() + +=over "Requires in" all fonts available as corefonts. +=back + =cut sub loadallfonts { @@ -426,8 +433,6 @@ BEGIN __END__ -=back - =head1 AUTHOR Alfred Reibenschuh diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/bankgothic.pm b/lib/PDF/Builder/Resource/Font/CoreFont/bankgothic.pm index f27f6ee..38c55d0 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/bankgothic.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/bankgothic.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::bankgothic; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.013'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/courier.pm b/lib/PDF/Builder/Resource/Font/CoreFont/courier.pm index fc4131c..1f51b22 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/courier.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/courier.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::courier; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.019'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/courierbold.pm b/lib/PDF/Builder/Resource/Font/CoreFont/courierbold.pm index 4d57b24..0ca600e 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/courierbold.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/courierbold.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::courierbold; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.019'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/courierboldoblique.pm b/lib/PDF/Builder/Resource/Font/CoreFont/courierboldoblique.pm index 1d97ebd..dfd06d9 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/courierboldoblique.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/courierboldoblique.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::courierboldoblique; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.019'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/courieroblique.pm b/lib/PDF/Builder/Resource/Font/CoreFont/courieroblique.pm index 0817c06..30fa9af 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/courieroblique.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/courieroblique.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::courieroblique; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.019'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/georgia.pm b/lib/PDF/Builder/Resource/Font/CoreFont/georgia.pm index 12c16f9..b1993b4 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/georgia.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/georgia.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::georgia; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.018'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/georgiabold.pm b/lib/PDF/Builder/Resource/Font/CoreFont/georgiabold.pm index 034514e..006ebeb 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/georgiabold.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/georgiabold.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::georgiabold; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.018'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/georgiabolditalic.pm b/lib/PDF/Builder/Resource/Font/CoreFont/georgiabolditalic.pm index f55159b..b2d319d 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/georgiabolditalic.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/georgiabolditalic.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::georgiabolditalic; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.018'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/georgiaitalic.pm b/lib/PDF/Builder/Resource/Font/CoreFont/georgiaitalic.pm index 2cef3b3..4cbb3e8 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/georgiaitalic.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/georgiaitalic.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::georgiaitalic; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.018'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/helvetica.pm b/lib/PDF/Builder/Resource/Font/CoreFont/helvetica.pm index 23d4825..dee3ec4 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/helvetica.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/helvetica.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::helvetica; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.019'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/helveticabold.pm b/lib/PDF/Builder/Resource/Font/CoreFont/helveticabold.pm index 6d73bc0..a4479d9 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/helveticabold.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/helveticabold.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::helveticabold; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.019'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/helveticaboldoblique.pm b/lib/PDF/Builder/Resource/Font/CoreFont/helveticaboldoblique.pm index 111137d..3381eed 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/helveticaboldoblique.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/helveticaboldoblique.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::helveticaboldoblique; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.019'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/helveticaoblique.pm b/lib/PDF/Builder/Resource/Font/CoreFont/helveticaoblique.pm index f7fd3ac..5158348 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/helveticaoblique.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/helveticaoblique.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::helveticaoblique; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.019'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/symbol.pm b/lib/PDF/Builder/Resource/Font/CoreFont/symbol.pm index d010f89..baa9a03 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/symbol.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/symbol.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::symbol; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.019'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/timesbold.pm b/lib/PDF/Builder/Resource/Font/CoreFont/timesbold.pm index 88bf02f..138d0ff 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/timesbold.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/timesbold.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::timesbold; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.019'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/timesbolditalic.pm b/lib/PDF/Builder/Resource/Font/CoreFont/timesbolditalic.pm index eba4bca..c14edd9 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/timesbolditalic.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/timesbolditalic.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::timesbolditalic; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.019'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/timesitalic.pm b/lib/PDF/Builder/Resource/Font/CoreFont/timesitalic.pm index ea4a9d9..6c8b9b4 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/timesitalic.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/timesitalic.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::timesitalic; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.019'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/timesroman.pm b/lib/PDF/Builder/Resource/Font/CoreFont/timesroman.pm index 1a162d7..45eacce 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/timesroman.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/timesroman.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::timesroman; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.019'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/trebuchet.pm b/lib/PDF/Builder/Resource/Font/CoreFont/trebuchet.pm index 421c8e5..b0f8c43 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/trebuchet.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/trebuchet.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::trebuchet; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.018'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/trebuchetbold.pm b/lib/PDF/Builder/Resource/Font/CoreFont/trebuchetbold.pm index 9f36303..c0d15f7 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/trebuchetbold.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/trebuchetbold.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::trebuchetbold; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.018'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/trebuchetbolditalic.pm b/lib/PDF/Builder/Resource/Font/CoreFont/trebuchetbolditalic.pm index dbac4e1..7cd6010 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/trebuchetbolditalic.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/trebuchetbolditalic.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::trebuchetbolditalic; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.018'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/trebuchetitalic.pm b/lib/PDF/Builder/Resource/Font/CoreFont/trebuchetitalic.pm index 0898a60..368f921 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/trebuchetitalic.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/trebuchetitalic.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::trebuchetitalic; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.018'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/verdana.pm b/lib/PDF/Builder/Resource/Font/CoreFont/verdana.pm index a89e690..be6a4c0 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/verdana.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/verdana.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::verdana; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.018'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/verdanabold.pm b/lib/PDF/Builder/Resource/Font/CoreFont/verdanabold.pm index 4f941ad..3509f2b 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/verdanabold.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/verdanabold.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::verdanabold; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.018'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/verdanabolditalic.pm b/lib/PDF/Builder/Resource/Font/CoreFont/verdanabolditalic.pm index a55484a..50019f0 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/verdanabolditalic.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/verdanabolditalic.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::verdanabolditalic; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.018'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/verdanaitalic.pm b/lib/PDF/Builder/Resource/Font/CoreFont/verdanaitalic.pm index dc08552..0ac50eb 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/verdanaitalic.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/verdanaitalic.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::verdanaitalic; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.018'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/webdings.pm b/lib/PDF/Builder/Resource/Font/CoreFont/webdings.pm index 58ec60d..df8d45e 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/webdings.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/webdings.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::webdings; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '2.029'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/wingdings.pm b/lib/PDF/Builder/Resource/Font/CoreFont/wingdings.pm index 2aed6b9..5376345 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/wingdings.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/wingdings.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::wingdings; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '2.029'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/CoreFont/zapfdingbats.pm b/lib/PDF/Builder/Resource/Font/CoreFont/zapfdingbats.pm index c39bf82..0547fe9 100644 --- a/lib/PDF/Builder/Resource/Font/CoreFont/zapfdingbats.pm +++ b/lib/PDF/Builder/Resource/Font/CoreFont/zapfdingbats.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Font::CoreFont::zapfdingbats; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.019'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/Font/Postscript.pm b/lib/PDF/Builder/Resource/Font/Postscript.pm index d7d98b8..544d7d5 100644 --- a/lib/PDF/Builder/Resource/Font/Postscript.pm +++ b/lib/PDF/Builder/Resource/Font/Postscript.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::Font'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use Encode qw(:all); use IO::File qw(); @@ -18,6 +18,19 @@ use PDF::Builder::Basic::PDF::Utils; PDF::Builder::Resource::Font::Postscript - support routines for using PostScript fonts. Inherits from L<PDF::Builder::Resource::Font> +=head1 METHODS + +=head2 new + + PDF::Builder::Resource::Font::Postscript->new($pdf, $psfile, %opts) + +=over + +Create an object for a PostScript font. Handles ASCII (.pfa), binary (.pfb), and +T1 (.t1) font files, as well as ASCII (.afm) and binary (.pfm) metrics files. + +=back + =cut sub new { @@ -95,17 +108,29 @@ sub readPFAPFB { die "Cannot find PFA/PFB font file '$file' ..." unless -f $file; my $l = -s $file; + $l1 = $l2 = $l3 = 0; + $head = $body = $tail = ''; + + my $type = 'pfa'; + if ($file =~ m/\.pfb$/i) { + $type = 'pfb'; + } elsif ($file =~ m/\.t1$/i) { + $type = 't1'; + } open(my $inf, "<", $file) or die "$!: $file"; binmode($inf,':raw'); - read($inf, $line, 2); + read($inf, $line, 2); # read 2 bytes to check header @lines = unpack('C*', $line); - if ($lines[0] == 0x80 && $lines[1] == 1) { + + if ($lines[0] == 0x80 && $lines[1] == 1) { # .pfb + # first 6 bytes are 80 01, 4 byte LSB $l1 head length read($inf, $line, 4); - $l1 = unpack('V', $line); + $l1 = unpack('V', $line); # length of head seek($inf, $l1, 1); read($inf, $line, 2); @lines = unpack('C*', $line); + # at start of binary body, 6 bytes 80 01, 4 byte LSB $l2 body length if ($lines[0] == 0x80 && $lines[1] == 2) { read($inf, $line, 4); $l2 = unpack('V', $line); @@ -115,6 +140,7 @@ sub readPFAPFB { seek($inf, $l2, 1); read($inf, $line, 2); @lines = unpack('C*', $line); + # after body, 6 bytes 80 01, 4 byte LSB $l3 tail length if ($lines[0] == 0x80 && $lines[1] == 1) { read($inf, $line, 4); $l3 = unpack('V', $line); @@ -124,33 +150,84 @@ sub readPFAPFB { seek($inf, 0, 0); @lines = <$inf>; $stream = join('', @lines); + # each section, skip over 80 01, length; read in length of section $t1stream = substr($stream, 6, $l1); $t1stream .= substr($stream, 12+$l1, $l2); $t1stream .= substr($stream, 18+$l1+$l2, $l3); - } elsif ($line eq '%!') { + + } elsif ($line eq '%!' && $type eq 'pfa') { seek($inf, 0, 0); while ($line = <$inf>) { - if (!$l1) { - $head .= $line; + if (!$l1) { # $head empty or not complete yet? + $head .= $line; # up through and including currentfile eexec if ($line=~/eexec$/) { chomp($head); $head .= "\x0d"; $l1 = length($head); } - } elsif (!$l2) { - if ($line =~ /^0+$/) { + } elsif (!$l2) { # $body empty or not complete yet? + if ($line =~ /^0+$/) { # at block of 0's, marking end of body $l2 = length($body); $tail = $line; } else { chomp($line); - $body .= pack('H*', $line); + $body .= pack('H*', $line); # binary form of hex codes } - } else { + } else { # rest goes into the $tail $tail .= $line; } } $l3 = length($tail); + # head = individual lines (^M terminated) with settings list + # body = one long string of bytes (binary) + # tail = 8 lines x 64 0's ^M terminated, cleartomark (no ^M) + $t1stream = "$head$body$tail"; + + } elsif ($line eq '%!' && $type eq 't1') { + # .t1 + my $pos; + seek($inf, 0, 0); + while (1) { # head + read($inf, $line, 200); + $head .= $line; + $pos = index($head, "currentfile eexec\x0D"); + if ($pos > 0) { + # found end of head, so split there + $body = substr($head, $pos+18); + $head = substr($head, 0, $pos+18); + $l1 = length($head); + last; + } + } + while (1) { # body + read($inf, $line, 200); + $body .= $line; + # 1111111111222222222233333333334444444444555555555566666 + # 1234567890123456789012345678901234567890123456789012345678901234 + $pos = index($body, "0000000000000000000000000000000000000000000000000000000000000000"); + if ($pos > 0) { + # found end of body, so split there + $tail = substr($body, $pos); + $body = substr($body, 0, $pos); + $l2 = length($body); + last; + } + } + while (1) { # remainder into tail + read($inf, $line, 200); + $tail .= $line; + if (length($line) == 0) { + # found end of tail + $l3 = length($tail); + last; + } + } + + # head = individual lines (^M terminated) with settings list + # body = one long string of bytes (binary) + # tail = 8 lines x 64 0's ^M terminated, cleartomark (no ^M) $t1stream = "$head$body$tail"; + } else { die "Unsupported font-format in file '$file' at marker='1'."; } diff --git a/lib/PDF/Builder/Resource/Font/SynFont.pm b/lib/PDF/Builder/Resource/Font/SynFont.pm index 47a9712..906a7d9 100644 --- a/lib/PDF/Builder/Resource/Font/SynFont.pm +++ b/lib/PDF/Builder/Resource/Font/SynFont.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::Font'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use Math::Trig; # CAUTION: deg2rad(0) = deg2rad(360) = 0! use Unicode::UCD 'charinfo'; @@ -49,9 +49,11 @@ This is for compatibility with recent changes to PDF::API2. =head1 METHODS -=over +=head2 new + + $font = PDF::Builder::Resource::Font::SynFont->new($pdf, $fontobj, %opts) -=item $font = PDF::Builder::Resource::Font::SynFont->new($pdf, $fontobj, %opts) +=over Returns a synfont object. C<$fontobj> is a normal font object read in from a file, and C<$font> is the modified output. diff --git a/lib/PDF/Builder/Resource/Glyphs.pm b/lib/PDF/Builder/Resource/Glyphs.pm index 7a5fe99..8ccfda7 100644 --- a/lib/PDF/Builder/Resource/Glyphs.pm +++ b/lib/PDF/Builder/Resource/Glyphs.pm @@ -3,7 +3,7 @@ package PDF::Builder::Resource::Glyphs; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.024'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/PaperSizes.pm b/lib/PDF/Builder/Resource/PaperSizes.pm index 2ec08e2..73e1bcb 100644 --- a/lib/PDF/Builder/Resource/PaperSizes.pm +++ b/lib/PDF/Builder/Resource/PaperSizes.pm @@ -3,8 +3,8 @@ package PDF::Builder::Resource::PaperSizes; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed =head1 NAME @@ -45,8 +45,6 @@ lot of work! =head3 Metric sizes -=over - 4a0 -- 4760 x 6716 (1679 mm x 2639 mm) 2a0 -- 3368 x 4760 (1188 mm x 1679 mm) @@ -157,24 +155,17 @@ lot of work! p6 -- 303 x 397 (107 mm x 140 mm) -=back - =head3 Mixed sizes -=over - universal -- 595 x 792 (210 mm x 11 in) This is not a standard or official size, but a PDF::Builder size, which should print OK on either A4 or US Letter paper size. It is narrow (like A4) and short -(like letter). - -=back +(like letter). Your content will be in the lower left of the paper, when +printed, with extra top margin on A4 or extra right margin on Letter. =head3 US/British (non-metric) sizes -=over - broadsheet -- 1296 x 1584 (18 in x 22 in) sometimes 1224 x 1584! executive -- 522 x 756 (7.25 in x 10.5 in) @@ -261,8 +252,6 @@ print OK on either A4 or US Letter paper size. It is narrow (like A4) and short imperial -- 540 x 792 (7.5 in x 11 in) -=back - =cut # see sites such as https://www.papersizes.org/ for all the paper size diff --git a/lib/PDF/Builder/Resource/Pattern.pm b/lib/PDF/Builder/Resource/Pattern.pm index 2ef547f..95867d2 100644 --- a/lib/PDF/Builder/Resource/Pattern.pm +++ b/lib/PDF/Builder/Resource/Pattern.pm @@ -5,13 +5,25 @@ use base 'PDF::Builder::Resource'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '2.031'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed =head1 NAME PDF::Builder::Resource::Pattern - support stub for patterns. Inherits from L<PDF::Builder::Resource> +=head1 METHODS + +=head2 new + + PDF::Builder::Resource::Pattern->new() + +=over + +Create a new pattern object. + +=back + =cut sub new { diff --git a/lib/PDF/Builder/Resource/Shading.pm b/lib/PDF/Builder/Resource/Shading.pm index 747477e..ad51f1c 100644 --- a/lib/PDF/Builder/Resource/Shading.pm +++ b/lib/PDF/Builder/Resource/Shading.pm @@ -5,7 +5,7 @@ use base 'PDF::Builder::Resource'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '2.029'; # manually update whenever code is changed =head1 NAME diff --git a/lib/PDF/Builder/Resource/UniFont.pm b/lib/PDF/Builder/Resource/UniFont.pm index 69afdcc..a7a6452 100644 --- a/lib/PDF/Builder/Resource/UniFont.pm +++ b/lib/PDF/Builder/Resource/UniFont.pm @@ -3,8 +3,8 @@ package PDF::Builder::Resource::UniFont; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use Carp; use Encode qw(:all); @@ -15,15 +15,13 @@ PDF::Builder::Resource::UniFont - Unicode Font Support =head1 METHODS -=over - -=item $font = PDF::Builder::Resource::UniFont->new($pdf, @fontspecs, %options) +=head2 new -Returns a uni-font object. + $font = PDF::Builder::Resource::UniFont->new($pdf, @fontspecs, %options) -=cut +=over -=pod +Returns a uni-font object. B<FONTSPECS:> fonts can be registered using the following hash-ref: @@ -55,6 +53,8 @@ Valid %options are: 'encode' ... changes the encoding of the font from its default. (see "perldoc Encode" for a list of valid tags) +=back + =cut sub new { @@ -134,16 +134,52 @@ sub new { return $self; } +=head2 isvirtual + + $flag = $font->isvirtual() + +=over + +(No Information) + +=back + +=cut + sub isvirtual { return 1; } +=head2 fontlist + + $font->fontlist() + +=over + +(No Information) + +=back + +=cut + sub fontlist { my $self = shift; return [@{ $self->{'fonts'} }]; } +=head2 width + + $w = $font->width($string) + +=over + +(No Information) + +=back + +=cut + sub width { my ($self, $text) = @_; @@ -176,6 +212,18 @@ sub width { return $width; } +=head2 text + + $font->text($string, $size, $indent) + +=over + +(No Information) + +=back + +=cut + sub text { my ($self, $text, $size, $indent) = @_; @@ -218,8 +266,4 @@ sub text { return $newtext; } -=back - -=cut - 1; diff --git a/lib/PDF/Builder/Resource/XObject.pm b/lib/PDF/Builder/Resource/XObject.pm index 93355e0..e2b2ee5 100644 --- a/lib/PDF/Builder/Resource/XObject.pm +++ b/lib/PDF/Builder/Resource/XObject.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '2.031'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use PDF::Builder::Basic::PDF::Utils; @@ -16,12 +16,16 @@ PDF::Builder::Resource::XObject - Base class for external objects =head1 METHODS -=over +=head2 new + + $xobject = PDF::Builder::Resource::XObject->new($pdf, $name) -=item $xobject = PDF::Builder::Resource::XObject->new($pdf, $name) +=over Creates an XObject resource. +=back + =cut sub new { @@ -34,10 +38,16 @@ sub new { return $self; } -=item $type = $xobject->subtype($type) +=head2 subtype + + $type = $xobject->subtype($type) + +=over Get or set the Subtype of the XObject resource. +=back + =cut sub subtype { @@ -49,8 +59,4 @@ sub subtype { return $self->{'Subtype'}->val(); } -=back - -=cut - 1; diff --git a/lib/PDF/Builder/Resource/XObject/Form.pm b/lib/PDF/Builder/Resource/XObject/Form.pm index a251b4c..16ab2af 100644 --- a/lib/PDF/Builder/Resource/XObject/Form.pm +++ b/lib/PDF/Builder/Resource/XObject/Form.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::XObject'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '2.031'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use PDF::Builder::Basic::PDF::Utils; @@ -16,12 +16,16 @@ PDF::Builder::Resource::XObject::Form - Base class for external form objects =head1 METHODS -=over +=head2 new + + $form = PDF::Builder::Resource::XObject::Form->new($pdf) -=item $form = PDF::Builder::Resource::XObject::Form->new($pdf) +=over Creates a form resource. +=back + =cut sub new { @@ -35,9 +39,15 @@ sub new { return $self; } -=item ($llx, $lly, $urx, $ury) = $form->bbox($llx, $lly, $urx, $ury) +=head2 bbox -Get or set the coordinates of the form object's bounding box + ($llx, $lly, $urx, $ury) = $form->bbox($llx, $lly, $urx, $ury) + +=over + +Get or set the coordinates of the form object's bounding box. + +=back =cut @@ -51,14 +61,20 @@ sub bbox { return map { $_->val() } $self->{'BBox'}->elements(); } -=item $resource = $form->resource($type, $key) +=head2 resource -=item $form->resource($type, $key, $object, $force) + $resource = $form->resource($type, $key) + + $form->resource($type, $key, $object, $force) + +=over Get or add a resource required by the form's contents, such as a Font, XObject, ColorSpace, etc. By default, an existing C<$key> will not be overwritten. Set C<$force> to override this behavior. +=back + =cut sub resource { @@ -87,8 +103,4 @@ sub resource { return $dict; } -=back - -=cut - 1; diff --git a/lib/PDF/Builder/Resource/XObject/Form/BarCode.pm b/lib/PDF/Builder/Resource/XObject/Form/BarCode.pm index caf94ac..dc410e4 100644 --- a/lib/PDF/Builder/Resource/XObject/Form/BarCode.pm +++ b/lib/PDF/Builder/Resource/XObject/Form/BarCode.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::XObject::Form::Hybrid'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use PDF::Builder::Util; use PDF::Builder::Basic::PDF::Utils; @@ -17,12 +17,16 @@ PDF::Builder::Resource::XObject::Form::BarCode - Base class for one-dimensional =head1 METHODS -=over +=head2 new + + $barcode = PDF::Builder::Resource::XObject::Form::BarCode->new($pdf, %options) -=item $barcode = PDF::Builder::Resource::XObject::Form::BarCode->new($pdf, %options) +=over Creates a barcode form resource. +=back + =cut sub new { @@ -179,7 +183,15 @@ sub drawbar { return; } -=item $width = $barcode->width() +=head2 width + + $width = $barcode->width() + +=over + +Returns the width of the bar code. + +=back =cut @@ -189,18 +201,23 @@ sub width { return $self->{' w'}; } -=item $height = $barcode->height() +=head2 height + + $height = $barcode->height() + +=over + +Returns the height of the bar code. + +=back =cut + sub height { my $self = shift; return $self->{' h'}; } -=back - -=cut - 1; diff --git a/lib/PDF/Builder/Resource/XObject/Form/BarCode/codabar.pm b/lib/PDF/Builder/Resource/XObject/Form/BarCode/codabar.pm index f6276aa..dbc3c7e 100644 --- a/lib/PDF/Builder/Resource/XObject/Form/BarCode/codabar.pm +++ b/lib/PDF/Builder/Resource/XObject/Form/BarCode/codabar.pm @@ -5,13 +5,26 @@ use base 'PDF::Builder::Resource::XObject::Form::BarCode'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed =head1 NAME PDF::Builder::Resource::XObject::Form::BarCode::codabar - specific information for CodaBar bar codes. Inherits from L<PDF::Builder::Resource::XObject::Form::BarCode> +=head1 METHODS + +=head2 new + + PDF::Builder::Resource::XObject::Form::BarCode::codabar->new() + +=over + +Create a Codabar bar code object. Note that it is invoked from the Builder.pm +level method! + +=back + =cut # TBD document code, caption options diff --git a/lib/PDF/Builder/Resource/XObject/Form/BarCode/code128.pm b/lib/PDF/Builder/Resource/XObject/Form/BarCode/code128.pm index 1d582ae..93fc5bc 100644 --- a/lib/PDF/Builder/Resource/XObject/Form/BarCode/code128.pm +++ b/lib/PDF/Builder/Resource/XObject/Form/BarCode/code128.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::XObject::Form::BarCode'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed =head1 NAME @@ -14,11 +14,14 @@ PDF::Builder::Resource::XObject::Form::BarCode::code128 - Code 128 and EAN-128 b =head1 METHODS -=over +=head2 new + + $res = PDF::Builder::Resource::XObject::Form::BarCode::code128->new($pdf, %options) -=item $res = PDF::Builder::Resource::XObject::Form::BarCode::code128->new($pdf, %options) +=over Returns a code128 object. Use 'ean' option to encode using EAN128 mode. +Note that this should be invoked via the Builder.pm method! =back diff --git a/lib/PDF/Builder/Resource/XObject/Form/BarCode/code3of9.pm b/lib/PDF/Builder/Resource/XObject/Form/BarCode/code3of9.pm index eba3c9f..d937786 100644 --- a/lib/PDF/Builder/Resource/XObject/Form/BarCode/code3of9.pm +++ b/lib/PDF/Builder/Resource/XObject/Form/BarCode/code3of9.pm @@ -5,13 +5,26 @@ use base 'PDF::Builder::Resource::XObject::Form::BarCode'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed =head1 NAME PDF::Builder::Resource::XObject::Form::BarCode::code3of9 - specific information for 3-of-9 bar codes. Inherits from L<PDF::Builder::Resource::XObject::Form::BarCode> +=head1 METHODS + +=head2 new + + PDF::Builder::Resource::XObject::Form::BarCode::code3of9->new() + +=over + +Create a Code 3 of 9 bar code object. Note that it is invoked from the +Builder.pm level method! + +=back + =cut sub new { diff --git a/lib/PDF/Builder/Resource/XObject/Form/BarCode/ean13.pm b/lib/PDF/Builder/Resource/XObject/Form/BarCode/ean13.pm index ecdd89e..57bd07c 100644 --- a/lib/PDF/Builder/Resource/XObject/Form/BarCode/ean13.pm +++ b/lib/PDF/Builder/Resource/XObject/Form/BarCode/ean13.pm @@ -5,13 +5,26 @@ use base 'PDF::Builder::Resource::XObject::Form::BarCode'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed =head1 NAME PDF::Builder::Resource::XObject::Form::BarCode::ean13 - specific information for EAN-13 bar codes. Inherits from L<PDF::Builder::Resource::XObject::Form::BarCode> +=head1 METHODS + +=head2 new + + PDF::Builder::Resource::XObject::Form::BarCode::ean13->new() + +=over + +Create an EAN-13 bar code object. Note that it is invoked from the Builder.pm +level method! + +=back + =cut sub new { diff --git a/lib/PDF/Builder/Resource/XObject/Form/BarCode/int2of5.pm b/lib/PDF/Builder/Resource/XObject/Form/BarCode/int2of5.pm index 8294a65..a0a7387 100644 --- a/lib/PDF/Builder/Resource/XObject/Form/BarCode/int2of5.pm +++ b/lib/PDF/Builder/Resource/XObject/Form/BarCode/int2of5.pm @@ -5,12 +5,25 @@ use base 'PDF::Builder::Resource::XObject::Form::BarCode'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed =head1 NAME -PDF::Builder::Resource::XObject::Form::BarCode::int2of5 - specific information for int 2-of-5 bar codes. Inherits from L<PDF::Builder::Resource::XObject::Form::BarCode> +PDF::Builder::Resource::XObject::Form::BarCode::int2of5 - specific information for interleaved 2-of-5 bar codes. Inherits from L<PDF::Builder::Resource::XObject::Form::BarCode> + +=head1 METHODS + +=head2 new + + PDF::Builder::Resource::XObject::Form::BarCode::int2of5->new() + +=over + +Create an Interleaved 2 of 5 bar code object. Note that it is invoked from the +Builder.pm level method! + +=back =cut diff --git a/lib/PDF/Builder/Resource/XObject/Form/Hybrid.pm b/lib/PDF/Builder/Resource/XObject/Form/Hybrid.pm index 182672c..97238bf 100644 --- a/lib/PDF/Builder/Resource/XObject/Form/Hybrid.pm +++ b/lib/PDF/Builder/Resource/XObject/Form/Hybrid.pm @@ -5,8 +5,8 @@ use base qw(PDF::Builder::Content PDF::Builder::Content::Text PDF::Builder::Reso use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.016'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use PDF::Builder::Basic::PDF::Dict; use PDF::Builder::Basic::PDF::Utils; @@ -15,6 +15,18 @@ use PDF::Builder::Resource::XObject::Form; PDF::Builder::Resource::XObject::Form::Hybrid - support routines for Forms. Inherits from L<PDF::Builder::Content>, L<PDF::Builder::Content::Text>, and L<PDF::Builder::Resource::XObject::Form> +=head1 METHODS + +=head2 new + + PDF::Builder::Resource::XObject::Form->new(args) + +=over + +Create a new object for a form. + +=back + =cut sub new { @@ -27,7 +39,7 @@ sub new { $self->{' charspace'} = 0; $self->{' hscale'} = 100; $self->{' wordspace'} = 0; - $self->{' lead'} = 0; + $self->{' leading'} = 0; $self->{' rise'} = 0; $self->{' render'} = 0; $self->{' matrix'} = [1, 0, 0, 1, 0, 0]; @@ -57,7 +69,7 @@ sub outobjdeep { # # missing: stream, poststream, apiistext # # added: api, apipdf, apipage # foreach my $key (qw(api apipdf apipage font fontsize charspace hscale -# wordspace lead rise render matrix fillcolor +# wordspace leading rise render matrix fillcolor # strokecolor translate scale skew rotate)) { # delete $self->{" $key"}; # } diff --git a/lib/PDF/Builder/Resource/XObject/Image.pm b/lib/PDF/Builder/Resource/XObject/Image.pm index fec9b71..5428f08 100644 --- a/lib/PDF/Builder/Resource/XObject/Image.pm +++ b/lib/PDF/Builder/Resource/XObject/Image.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::XObject'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.017'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use PDF::Builder::Basic::PDF::Utils; @@ -16,12 +16,16 @@ PDF::Builder::Resource::XObject::Image - Base class for external raster image ob =head1 METHODS -=over +=head2 new + + $image = PDF::Builder::Resource::XObject::Image->new($pdf, $name) -=item $image = PDF::Builder::Resource::XObject::Image->new($pdf, $name) +=over Returns an image resource object. +=back + =cut sub new { @@ -34,9 +38,22 @@ sub new { return $self; } -=item $width = $image->width($width) +=head2 width + + $width = $image->width() + +=over + +Get the width (in points) of the image object. + +B<Note> that this function also has the ability to I<set> the width, +by giving the new width (in points), but it appears that it never +worked correctly. The I<set> capability has been B<deprecated>, and +is scheduled to be removed some time after October, 2025. If you are +using the C<width()> method in some manner to I<set> the image width, +please let us know, so we can plan to keep it enabled! -Get or set the width value for the image object. +=back =cut @@ -47,9 +64,22 @@ sub width { return $self->{'Width'}->val(); } -=item $height = $image->height($height) +=head2 height + + $height = $image->height() + +=over + +Get the height (in points) of the image object. -Get or set the height value for the image object. +B<Note> that this function also has the ability to I<set> the height, +by giving the new height (in points), but it appears that it never +worked correctly. The I<set> capability has been B<deprecated>, and +is scheduled to be removed some time after October, 2025. If you are +using the C<height()> method in some manner to I<set> the image height, +please let us know, so we can plan to keep it enabled! + +=back =cut @@ -60,10 +90,38 @@ sub height { return $self->{'Height'}->val(); } -=item $image->smask($xobject) +## probably not useful, so do not add, for now +#=head2 bbox +# +# ($x1,$x2, $w,$h) = $image->bbox() +# +#=over +# +#Get the image dimensions similarly to a form's I<bounding box>. +#Note that the C<$x1> and C<$x2> values will always be 0. +# +#This method is offered as an alternative to the C<width> and C<height> methods. +# +#=back +# +#=cut +# +#sub bbox { +# my $self = shift(); +# my @bb = (0,0, $self->width(),$self->height()); +# return @bb; +#} + +=head2 smask + + $image->smask($xobject) + +=over Set the soft-mask image object. +=back + =cut sub smask { @@ -73,13 +131,19 @@ sub smask { return $self; } -=item $image->mask(@color_range) +=head2 mask + + $image->mask(@color_range) -=item $image->mask($xobject) + $image->mask($xobject) + +=over Set the mask to an image mask XObject or an array containing a range of colors to be applied as a color key mask. +=back + =cut sub mask { @@ -96,9 +160,13 @@ sub mask { # imask() functionality rolled into mask() -=item $image->colorspace($name) +=head2 colorspace + + $image->colorspace($name) -=item $image->colorspace($array) + $image->colorspace($array) + +=over Set the color space used by the image. Depending on the color space, this will either be just the name of the color space, or it will be an @@ -108,6 +176,8 @@ If passing an array, parameters must already be encoded as PDF objects. The array itself may also be a PDF object. If not, one will be created. +=back + =cut sub colorspace { @@ -124,10 +194,16 @@ sub colorspace { return $self; } -=item $image->bits_per_component($integer) +=head2 bits_per_component + + $image->bits_per_component($integer) + +=over Set the number of bits used to represent each color component. +=back + =cut sub bits_per_component { @@ -140,8 +216,4 @@ sub bits_per_component { # bpc() renamed to bits_per_component() -=back - -=cut - 1; diff --git a/lib/PDF/Builder/Resource/XObject/Image/GD.pm b/lib/PDF/Builder/Resource/XObject/Image/GD.pm index c3e091a..2514bde 100644 --- a/lib/PDF/Builder/Resource/XObject/Image/GD.pm +++ b/lib/PDF/Builder/Resource/XObject/Image/GD.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::XObject::Image'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use PDF::Builder::Util; use PDF::Builder::Basic::PDF::Utils; @@ -18,9 +18,11 @@ PDF::Builder::Resource::XObject::Image::GD - support routines for Graphics Devel =head1 METHODS -=over +=head2 new -=item $res = PDF::Builder::Resource::XObject::Image::GD->new($pdf, $file, %opts) + $res = PDF::Builder::Resource::XObject::Image::GD->new($pdf, $file, %opts) + +=over Options: @@ -36,6 +38,9 @@ Use lossless compression. =back +An image object is created from GD input. Note that this should be invoked +from Builder.pm's method. + =back =cut diff --git a/lib/PDF/Builder/Resource/XObject/Image/GIF.pm b/lib/PDF/Builder/Resource/XObject/Image/GIF.pm index 6617a48..e8e91b7 100644 --- a/lib/PDF/Builder/Resource/XObject/Image/GIF.pm +++ b/lib/PDF/Builder/Resource/XObject/Image/GIF.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::XObject::Image'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use IO::File; use PDF::Builder::Util; @@ -162,6 +162,21 @@ sub deGIF { return $out; } +=head1 METHODS + +=head2 new + + PDF::Builder::Resource::XObject::Image::GIF->new() + +=over + +Create an image object from a GIF input file. +Remember that this should be invoked via the Builder.pm method! + +=back + +=cut + sub new { my ($class, $pdf, $file, %opts) = @_; # copy dashed option names to preferred undashed names diff --git a/lib/PDF/Builder/Resource/XObject/Image/JPEG.pm b/lib/PDF/Builder/Resource/XObject/Image/JPEG.pm index ed2307e..86b1ef2 100644 --- a/lib/PDF/Builder/Resource/XObject/Image/JPEG.pm +++ b/lib/PDF/Builder/Resource/XObject/Image/JPEG.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::XObject::Image'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use IO::File; use PDF::Builder::Util; @@ -19,9 +19,11 @@ PDF::Builder::Resource::XObject::Image::JPEG - support routines for JPEG image l =head1 METHODS -=over +=head2 new + + $res = PDF::Builder::Resource::XObject::Image::JPEG->new($pdf, $file, %opts) -=item $res = PDF::Builder::Resource::XObject::Image::JPEG->new($pdf, $file, %opts) +=over Options: diff --git a/lib/PDF/Builder/Resource/XObject/Image/PNG.pm b/lib/PDF/Builder/Resource/XObject/Image/PNG.pm index ae04d3a..f44a8f6 100644 --- a/lib/PDF/Builder/Resource/XObject/Image/PNG.pm +++ b/lib/PDF/Builder/Resource/XObject/Image/PNG.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::XObject::Image'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use Compress::Zlib; use POSIX qw(ceil floor); @@ -24,9 +24,11 @@ Inherits from L<PDF::Builder::Resource::XObject::Image> =head1 METHODS -=over +=head2 new + + $res = PDF::Builder::Resource::XObject::Image::PNG->new($pdf, $file, %opts) -=item $res = PDF::Builder::Resource::XObject::Image::PNG->new($pdf, $file, %opts) +=over Returns a PNG-image object. C<$pdf> is the PDF object being added to, C<$file> is the input PNG file, and the optional C<$name> of the new parent image object @@ -51,6 +53,9 @@ This is the name you can give for the PNG image object. The default is Pxnnnn. =back +Remember that you need to invoke the image_png method from Builder.pm in +order to use this functionality. + =back =head2 Supported PNG types @@ -385,9 +390,11 @@ sub new { return($self); } -=over +=head2 usesLib + + $mode = $png->usesLib() -=item $mode = $png->usesLib() +=over Returns 1 if Image::PNG::Libpng installed and used, 0 if not installed, or -1 if installed but not used (nouseIPL option given to C<image_png>). diff --git a/lib/PDF/Builder/Resource/XObject/Image/PNG_IPL.pm b/lib/PDF/Builder/Resource/XObject/Image/PNG_IPL.pm index 0070633..00f20d4 100644 --- a/lib/PDF/Builder/Resource/XObject/Image/PNG_IPL.pm +++ b/lib/PDF/Builder/Resource/XObject/Image/PNG_IPL.pm @@ -5,7 +5,7 @@ use base 'PDF::Builder::Resource::XObject::Image'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION +our $VERSION = '3.026'; # VERSION our $LAST_UPDATE = '3.024'; # manually update whenever code is changed use Compress::Zlib; @@ -26,9 +26,11 @@ Inherits from L<PDF::Builder::Resource::XObject::Image> =head1 METHODS -=over +=head2 new + + $res = PDF::Builder::Resource::XObject::Image::PNG_IPL->new($pdf, $file, %opts) -=item $res = PDF::Builder::Resource::XObject::Image::PNG_IPL->new($pdf, $file, %opts) +=over Returns a PNG-image object. C<$pdf> is the PDF object being added to, C<$file> is the input PNG file, and the optional C<$name> of the new parent image object @@ -58,6 +60,8 @@ This is the name you can give for the PNG image object. The default is Pxnnnn. =back +Remember that you need to use Builder.pm's image_png to process PNG images. + =back =head2 Supported PNG types @@ -578,9 +582,11 @@ sub new { return($self); } -=over +=head2 usesLib + + $mode = $png->usesLib() -=item $mode = $png->usesLib() +=over Returns 1 if Image::PNG::Libpng installed and used, 0 if not installed, or -1 if installed but not used (nouseIPL option given to C<image_png>). diff --git a/lib/PDF/Builder/Resource/XObject/Image/PNM.pm b/lib/PDF/Builder/Resource/XObject/Image/PNM.pm index 87617c3..f36f10a 100644 --- a/lib/PDF/Builder/Resource/XObject/Image/PNM.pm +++ b/lib/PDF/Builder/Resource/XObject/Image/PNM.pm @@ -7,8 +7,8 @@ use base 'PDF::Builder::Resource::XObject::Image'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use IO::File; use PDF::Builder::Util; @@ -24,9 +24,11 @@ PDF::Builder::Resource::XObject::Image::PNM - support routines for PNM (Portable =head2 METHODS -=over +=head2 new + + $res = PDF::Builder::Resource::XObject::Image::PNM->new($pdf, $file, %opts) -=item $res = PDF::Builder::Resource::XObject::Image::PNM->new($pdf, $file, %opts) +=over Options: @@ -59,6 +61,9 @@ color) may be anything from 1 to 65535 (the same maximum for all three colors), with 0 being full black. If the maximum sample value is 255 or smaller, three bytes of raw binary data per pixel, otherwise six bytes. +Remember that you need to use Builder.pm's image_pnm method to use this +functionality. + =cut # ------------------------------------------------------------------- diff --git a/lib/PDF/Builder/Resource/XObject/Image/TIFF.pm b/lib/PDF/Builder/Resource/XObject/Image/TIFF.pm index 3391b69..0e28d26 100644 --- a/lib/PDF/Builder/Resource/XObject/Image/TIFF.pm +++ b/lib/PDF/Builder/Resource/XObject/Image/TIFF.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::XObject::Image'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use Compress::Zlib; @@ -21,9 +21,11 @@ PDF::Builder::Resource::XObject::Image::TIFF - TIFF image support =head1 METHODS -=over +=head2 new + + $res = PDF::Builder::Resource::XObject::Image::TIFF->new($pdf, $file, %opts) -=item $res = PDF::Builder::Resource::XObject::Image::TIFF->new($pdf, $file, %opts) +=over Returns a TIFF-image object. @@ -41,6 +43,11 @@ This is the name you can give for the TIFF image object. The default is Ixnnnn. =back +Remember that you need to use the Builder.pm method image_tiff in order to +display a TIFF file. + +=back + =cut sub new { @@ -89,7 +96,11 @@ sub new { return $self; } -=item $mode = $tif->usesLib() +=head2 usesLib + + $mode = $tif->usesLib() + +=over Returns 1 if Graphics::TIFF installed and used, 0 if not installed, or -1 if installed but not used (nouseGT option given to C<image_tiff>). @@ -100,6 +111,8 @@ advance of actually using it, in case you want to use some functionality available only in TIFF_GT. See the <PDF::Builder> LA_GT() call if you need to know in advance. +=back + =cut sub usesLib { @@ -313,7 +326,11 @@ sub read_tiff { return $self; } -=item $value = $tif->tiffTag($tag) +=head2 tiffTag + + $value = $tif->tiffTag($tag) + +=over returns the value of the internal tiff-tag. @@ -323,6 +340,8 @@ B<Useful Tags:> xRes, yRes (dpi; pixel/cm if resUnit==3) resUnit +=back + =cut sub tiffTag { @@ -330,8 +349,4 @@ sub tiffTag { return $self->{' tiff'}->{$tag}; } -=back - -=cut - 1; diff --git a/lib/PDF/Builder/Resource/XObject/Image/TIFF/File.pm b/lib/PDF/Builder/Resource/XObject/Image/TIFF/File.pm index c94aaab..37f960e 100644 --- a/lib/PDF/Builder/Resource/XObject/Image/TIFF/File.pm +++ b/lib/PDF/Builder/Resource/XObject/Image/TIFF/File.pm @@ -3,8 +3,8 @@ package PDF::Builder::Resource::XObject::Image::TIFF::File; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.023'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use IO::File; @@ -12,6 +12,19 @@ use IO::File; PDF::Builder::Resource::XObject::Image::TIFF::File - support routines for TIFF image library +=head1 METHODS + +=head2 new + + PDF::Builder::Resource::XObject::Image::TIFF::File->new() + +=over + +Create a TIFF image object, I<not> using the Graphics::TIFF library. +Remember to use the Builder.pm method image_tiff. + +=back + =cut sub new { diff --git a/lib/PDF/Builder/Resource/XObject/Image/TIFF/File_GT.pm b/lib/PDF/Builder/Resource/XObject/Image/TIFF/File_GT.pm index 8c15d8d..985c384 100644 --- a/lib/PDF/Builder/Resource/XObject/Image/TIFF/File_GT.pm +++ b/lib/PDF/Builder/Resource/XObject/Image/TIFF/File_GT.pm @@ -3,8 +3,8 @@ package PDF::Builder::Resource::XObject::Image::TIFF::File_GT; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.023'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use IO::File; use Graphics::TIFF ':all'; # already confirmed to be installed @@ -13,6 +13,19 @@ use Graphics::TIFF ':all'; # already confirmed to be installed PDF::Builder::Resource::XObject::Image::TIFF::File_GT - support routines for TIFF image library (Graphics::TIFF enabled) +=head1 METHODS + +=head2 new + + PDF::Builder::Resource::XObject::Image::TIFF::File_GT->new() + +=over + +Create an image object from TIFF input, using the Graphics::TIFF library. +Remember to use the Builder.pm method image_tiff for this functionality. + +=back + =cut sub new { diff --git a/lib/PDF/Builder/Resource/XObject/Image/TIFF_GT.pm b/lib/PDF/Builder/Resource/XObject/Image/TIFF_GT.pm index b3b8e46..c2c91e7 100644 --- a/lib/PDF/Builder/Resource/XObject/Image/TIFF_GT.pm +++ b/lib/PDF/Builder/Resource/XObject/Image/TIFF_GT.pm @@ -5,8 +5,8 @@ use base 'PDF::Builder::Resource::XObject::Image'; use strict; use warnings; -our $VERSION = '3.025'; # VERSION -our $LAST_UPDATE = '3.024'; # manually update whenever code is changed +our $VERSION = '3.026'; # VERSION +our $LAST_UPDATE = '3.026'; # manually update whenever code is changed use Compress::Zlib; @@ -23,9 +23,11 @@ PDF::Builder::Resource::XObject::Image::TIFF_GT - TIFF image support =head1 METHODS -=over +=head2 new + + $res = PDF::Builder::Resource::XObject::Image::TIFF_GT->new($pdf, $file, %opts) -=item $res = PDF::Builder::Resource::XObject::Image::TIFF_GT->new($pdf, $file, %opts) +=over Returns a TIFF-image object. C<$pdf> is the PDF object being added to, C<$file> is the input TIFF file, and the optional C<$name> of the new parent image object @@ -69,6 +71,8 @@ look into adding it as an option. According to Graphic::TIFF's owner (ticket RT 133955), this is coming directly from libtiff (as write to STDERR), so he can't do anything about it! +=back + =cut sub new { @@ -137,7 +141,11 @@ sub new { return $self; } # end of new() -=item $mode = $tif->usesLib() +=head2 usesLib + + $mode = $tif->usesLib() + +=over Returns 1 if Graphics::TIFF installed and used, 0 if not installed, or -1 if installed but not used (nouseGT option given to C<image_tiff>). |