Codebase list libpdf-api2-perl / 041cad5
Import upstream version 2.030001+git20210413.1.a10b770 Debian Janitor 2 years ago
112 changed file(s) with 262 addition(s) and 152 deletion(s). Raw diff Collapse all Expand all
0 0.001 2021-06-09
1
2 - Renamed openpage to open_page in PDF::API2. The old name is deprecated.
3
4
5 2.040 2021-04-13
6
7 - Fix open() followed by stringify() resulting in a corrupt (mostly-empty)
8 PDF, which was broken by changes in 2.039 (reported by Gareth Tunley).
9
10 - [RT #134993] Calling open($filename) followed by saveas($same_filename)
11 instead of update() resulted in a corrupt PDF in 2.039, which no longer
12 reads the entire file into memory on open (reported by Marco Pessotto).
13
14 - [RT #134957] Fix encoding of \n in a PDF string containing non-printable
15 characters (reported by Stuart Henderson).
16
17 - [RT #133131] Fix endianness of 64-bit numbers in cross-reference stream
18 widths array (reported by Christopher Papademetrious, fix by Vadim Repin).
19
20
021 2.039 2021-03-04
122
223 - PDF::API2->open($filename) no longer reads the entire file into memory
4646 "web" : "https://github.com/ssimms/pdfapi2"
4747 }
4848 },
49 "version" : "2.039",
50 "x_generated_by_perl" : "v5.28.1",
51 "x_serialization_backend" : "Cpanel::JSON::XS version 4.09",
49 "version" : "0.001",
50 "x_generated_by_perl" : "v5.32.1",
51 "x_serialization_backend" : "Cpanel::JSON::XS version 4.25",
5252 "x_spdx_expression" : "LGPL-2.1"
5353 }
5454
1919 perl: v5.10.0
2020 resources:
2121 repository: git://github.com/ssimms/pdfapi2.git
22 version: '2.039'
23 x_generated_by_perl: v5.28.1
22 version: '0.001'
23 x_generated_by_perl: v5.32.1
2424 x_serialization_backend: 'YAML::Tiny version 1.73'
2525 x_spdx_expression: LGPL-2.1
2323 "Test::Exception" => 0,
2424 "Test::Memory::Cycle" => 0
2525 },
26 "VERSION" => "2.039",
26 "VERSION" => "0.001",
2727 "test" => {
2828 "TESTS" => "t/*.t"
2929 }
00 This archive contains the distribution PDF-API2,
1 version 2.039:
1 version 0.001:
22
33 Facilitates the creation and modification of PDF files
44
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use PDF::API2::Basic::PDF::Utils;
1010
1212 use strict;
1313 use warnings;
1414
15 our $VERSION = '2.039'; # VERSION
15 our $VERSION = '0.001'; # VERSION
1616
1717 =head1 NAME
1818
1111
1212 use strict;
1313
14 our $VERSION = '2.039'; # VERSION
14 our $VERSION = '0.001'; # VERSION
1515
1616 =head1 NAME
1717
1212 use strict;
1313 no warnings qw[ deprecated recursion uninitialized ];
1414
15 our $VERSION = '2.039'; # VERSION
15 our $VERSION = '0.001'; # VERSION
1616
1717 our $mincache = 16 * 1024 * 1024;
1818
99
1010 use strict;
1111
12 our $VERSION = '2.039'; # VERSION
12 our $VERSION = '0.001'; # VERSION
1313
1414 =head1 NAME
1515
11671167 return unpack('n', $data) if $width == 2;
11681168 return unpack('N', "\x00$data") if $width == 3;
11691169 return unpack('N', $data) if $width == 4;
1170 return unpack('Q', $data) if $width == 8;
1171
1172 die "Invalid column width: $width";
1170 return unpack('Q>', $data) if $width == 8;
1171
1172 die "Unsupported xref stream entry width: $width";
11731173 }
11741174
11751175 sub readxrtr {
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 sub outfilt {
1010 my ($self, $str, $isend) = @_;
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 # Maintainer's Note: ASCIIHexDecode is described in the PDF 1.7 spec
1010 # in section 7.4.2.
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use POSIX qw(ceil floor);
1010
44 use strict;
55 no warnings qw[ deprecated recursion uninitialized ];
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 sub new {
1010 my ($class, $decode_parms) = @_;
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 # Maintainer's Note: RunLengthDecode is described in the PDF 1.7 spec
1010 # in section 7.4.5.
1010 use strict;
1111 use warnings;
1212
13 our $VERSION = '2.039'; # VERSION
13 our $VERSION = '0.001'; # VERSION
1414
1515 use PDF::API2::Basic::PDF::Filter::ASCII85Decode;
1616 use PDF::API2::Basic::PDF::Filter::ASCIIHexDecode;
44
55 use strict;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use PDF::API2::Basic::PDF::Filter;
1010 use PDF::API2::Basic::PDF::Name;
1111
1212 use strict;
1313
14 our $VERSION = '2.039'; # VERSION
14 our $VERSION = '0.001'; # VERSION
1515
1616 =head1 NAME
1717
1111
1212 use strict;
1313
14 our $VERSION = '2.039'; # VERSION
14 our $VERSION = '0.001'; # VERSION
1515
1616 =head1 NAME
1717
1111
1212 use strict;
1313
14 our $VERSION = '2.039'; # VERSION
14 our $VERSION = '0.001'; # VERSION
1515
1616 =head1 NAME
1717
1010 use strict;
1111 use warnings;
1212
13 our $VERSION = '2.039'; # VERSION
13 our $VERSION = '0.001'; # VERSION
1414
1515 =head1 NAME
1616
1212 use strict;
1313 use warnings;
1414
15 our $VERSION = '2.039'; # VERSION
15 our $VERSION = '0.001'; # VERSION
1616
1717 use PDF::API2::Basic::PDF::Dict;
1818 use PDF::API2::Basic::PDF::Utils;
1212
1313 use base 'PDF::API2::Basic::PDF::Dict';
1414
15 our $VERSION = '2.039'; # VERSION
15 our $VERSION = '0.001'; # VERSION
1616
1717 use PDF::API2::Basic::PDF::Array;
1818 use PDF::API2::Basic::PDF::Dict;
1111
1212 use strict;
1313
14 our $VERSION = '2.039'; # VERSION
14 our $VERSION = '0.001'; # VERSION
1515
1616 =head1 NAME
1717
190190 return "<FEFF$str>";
191191 }
192192 else {
193 if ($str =~ m/[^\n\r\t\b\f\040-\176\200-\377]/oi) {
194 $str =~ s/(.)/sprintf('%02X', ord($1))/oge;
193 if ($str =~ m/[^\n\r\t\b\f\040-\176\200-\377]/) {
194 $str =~ s/(.)/sprintf('%02X', ord($1))/sge;
195195 return "<$str>";
196196 }
197197 else {
198 $str =~ s/([\n\r\t\b\f\\()])/\\$out_trans{$1}/ogi;
198 $str =~ s/([\n\r\t\b\f\\()])/\\$out_trans{$1}/g;
199199 return "($str)";
200200 }
201201 }
99
1010 use strict;
1111
12 our $VERSION = '2.039'; # VERSION
12 our $VERSION = '0.001'; # VERSION
1313
1414 =head1 NAME
1515
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 sub new {
1010 my ($class) = @_;
44 use strict;
55 no warnings qw( deprecated recursion uninitialized );
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use Carp;
1010 use Compress::Zlib ();
22 use strict;
33 no warnings qw[ deprecated recursion uninitialized ];
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 BEGIN {
88
33
44 use Carp;
55
6 our $VERSION = '2.039'; # VERSION
6 our $VERSION = '0.001'; # VERSION
77
88 sub new {
99 my $type = shift();
44 use strict;
55 no warnings qw[ recursion uninitialized ];
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use Encode qw(:all);
1010
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use Carp qw(croak);
1010 use PDF::API2::Basic::PDF::Utils;
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use PDF::API2::Basic::PDF::Utils;
1010
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use POSIX qw(floor);
1010 use Scalar::Util qw(weaken);
4444
4545 =item $page = PDF::API2::Page->coerce $pdf, $pdfpage
4646
47 Returns a page object converted from $pdfpage (called from $pdf->openpage).
47 Returns a page object converted from $pdfpage (called from $pdf->open_page).
4848
4949 =cut
5050
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use Compress::Zlib;
1010 use Encode qw(:all);
44 use strict;
55 no warnings qw[ deprecated recursion uninitialized ];
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use PDF::API2::Util;
1010 use PDF::API2::Basic::PDF::Utils;
44 use strict;
55 no warnings qw[ recursion uninitialized ];
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use Carp;
1010 use Encode qw(:all);
44 use strict;
55 no warnings qw[ deprecated recursion uninitialized ];
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use PDF::API2::Basic::PDF::Utils;
1010 use PDF::API2::Resource::CIDFont::TrueType::FontFile;
44 use strict;
55 no warnings qw[ deprecated recursion uninitialized ];
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use Encode qw(:all);
1010
44 use strict;
55 no warnings qw[ deprecated recursion uninitialized ];
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use PDF::API2::Basic::PDF::Utils;
1010 use PDF::API2::Util;
44 use strict;
55 no warnings qw[ deprecated recursion uninitialized ];
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use PDF::API2::Basic::PDF::Utils;
1010 use PDF::API2::Util;
44 use strict;
55 no warnings qw[ deprecated recursion uninitialized ];
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use PDF::API2::Basic::PDF::Utils;
1010 use PDF::API2::Util;
44 use strict;
55 no warnings qw[ deprecated recursion uninitialized ];
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use PDF::API2::Basic::PDF::Utils;
1010 use PDF::API2::Util;
44 use strict;
55 no warnings qw[ deprecated recursion uninitialized ];
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use PDF::API2::Basic::PDF::Utils;
1010 use PDF::API2::Util;
44 use strict;
55 no warnings qw[ deprecated recursion uninitialized ];
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use PDF::API2::Basic::PDF::Utils;
1010 use PDF::API2::Util;
44 use strict;
55 no warnings qw[ deprecated recursion uninitialized ];
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use PDF::API2::Basic::PDF::Utils;
1010 use PDF::API2::Util;
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub get_colors {
88 return (
44 use strict;
55 no warnings qw[ deprecated recursion uninitialized ];
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use PDF::API2::Basic::PDF::Utils;
1010 use PDF::API2::Util;
44 use strict;
55 no warnings qw[ deprecated recursion uninitialized ];
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use PDF::API2::Util;
1010 use PDF::API2::Basic::PDF::Utils;
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'BankGothicMediumBT',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'Courier',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'Courier-Bold',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'Courier-BoldOblique',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'Courier-Oblique',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'Georgia',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'Georgia,Bold',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'Georgia,BoldItalic',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'Georgia,Italic',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'Helvetica',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'Helvetica-Bold',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'Helvetica-BoldOblique',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'Helvetica-Oblique',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'Symbol',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'Times-Bold',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'Times-BoldItalic',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'Times-Italic',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'Times-Roman',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'TrebuchetMS',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'TrebuchetMS,Bold',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'TrebuchetMS,BoldItalic',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'TrebuchetMS,Italic',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'Verdana',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'Verdana,Bold',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'Verdana,BoldItalic',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'Verdana,Italic',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'Webdings',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'Wingdings',
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub data { return {
88 'fontname' => 'ZapfDingbats',
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use File::Basename;
1010
44 use strict;
55 no warnings qw[ deprecated recursion uninitialized ];
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use Encode qw(:all);
1010 use IO::File qw();
44 use strict;
55 no warnings qw[ deprecated recursion uninitialized ];
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use Math::Trig;
1010 use Unicode::UCD 'charinfo';
44 use strict;
55 no warnings qw[ deprecated recursion uninitialized ];
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use Encode qw(:all);
1010
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 # The data in this file is generated from uniglyph.txt. In earlier
88 # versions of PDF::API2, this file was parsed and sorted every time
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 sub get_paper_sizes {
88 return (
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 sub new {
1010 my ($class, $pdf, $name) = @_;
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 1;
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 use Carp;
88 use Encode qw(:all);
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 sub new {
1010 my ($class, $pdf, %options) = @_;
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 =head1 NAME
1010
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 sub new {
1010 my ($class, $pdf, %options) = @_;
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 sub new {
1010 my ($class, $pdf, %options) = @_;
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 # Interleaved 2 of 5 Barcodes
1010
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use PDF::API2::Util;
1010 use PDF::API2::Basic::PDF::Utils;
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use PDF::API2::Basic::PDF::Dict;
1010 use PDF::API2::Basic::PDF::Utils;
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use PDF::API2::Basic::PDF::Utils;
1010
44 use strict;
55 no warnings qw[ deprecated recursion uninitialized ];
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use PDF::API2::Util;
1010 use PDF::API2::Basic::PDF::Utils;
44 use strict;
55 no warnings qw[ deprecated recursion uninitialized ];
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use IO::File;
1010 use PDF::API2::Util;
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use IO::File;
1010 use PDF::API2::Util;
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use Compress::Zlib;
1010 use POSIX qw(ceil floor);
88 use strict;
99 no warnings qw[ deprecated recursion uninitialized ];
1010
11 our $VERSION = '2.039'; # VERSION
11 our $VERSION = '0.001'; # VERSION
1212
1313 use IO::File;
1414 use PDF::API2::Util;
22 use strict;
33 use warnings;
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 use IO::File;
88
66
77 no warnings 'uninitialized';
88
9 our $VERSION = '2.039'; # VERSION
9 our $VERSION = '0.001'; # VERSION
1010
1111 use Compress::Zlib;
1212
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use PDF::API2::Basic::PDF::Utils;
1010
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use PDF::API2::Basic::PDF::Utils;
1010
44 use strict;
55 use warnings;
66
7 our $VERSION = '2.039'; # VERSION
7 our $VERSION = '0.001'; # VERSION
88
99 use PDF::API2::Util qw(pdfkey);
1010 use PDF::API2::Basic::PDF::Utils; # PDFName
22 use strict;
33 no warnings qw[ deprecated recursion uninitialized ];
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 # Implements UAX#14: Line Breaking Properties
88 # David Nesting <david@fastolfe.net>
22 use strict;
33 no warnings qw[ recursion uninitialized ];
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 BEGIN {
88 use Encode qw(:all);
22 use strict;
33 no warnings qw[ deprecated recursion uninitialized ];
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 package PDF::API2;
88
22 use strict;
33 no warnings qw[ deprecated recursion uninitialized ];
44
5 our $VERSION = '2.039'; # VERSION
5 our $VERSION = '0.001'; # VERSION
66
77 use Carp;
88 use Encode qw(:all);
4646 $page = $pdf->page();
4747
4848 # Retrieve an existing page
49 $page = $pdf->openpage($page_number);
49 $page = $pdf->open_page($page_number);
5050
5151 # Set the page size
5252 $page->mediabox('Letter');
184184 $self->{'catalog'} = $self->{'pdf'}->{'Root'};
185185 weaken $self->{'catalog'};
186186
187 $self->{'opened'} = 1;
187188 if (exists $options{'-compress'}) {
188189 $self->{'forcecompress'} = $options{'-compress'} ? 1 : 0;
189190 }
993994 unless ($self->{'pdf'}->{' fname'}) {
994995 $self->{'pdf'}->out_file($file);
995996 }
997 elsif ($self->{'pdf'}->{' fname'} eq $file) {
998 $self->update();
999 }
9961000 else {
9971001 $self->{'pdf'}->clone_file($file);
9981002 $self->{'pdf'}->close_file();
10501054 $self->{'pdf'}->append_file();
10511055 $str = ${$self->{'content_ref'}};
10521056 }
1057 elsif ($self->{'opened'}) {
1058 my $fh = FileHandle->new();
1059 CORE::open($fh, '>', \$str) || die "Can't begin scalar IO";
1060 $self->{'pdf'}->clone_file($fh);
1061 $self->{'pdf'}->close_file();
1062 $fh->close();
1063 }
10531064 else {
10541065 my $fh = FileHandle->new();
10551066 CORE::open($fh, '>', \$str) || die "Can't begin scalar IO";
11521163 return $page;
11531164 }
11541165
1155 =item $page = $pdf->openpage($page_number)
1166 =item $page = $pdf->open_page($page_number)
11561167
11571168 Returns the L<PDF::API2::Page> object of page $page_number.
11581169
11621173 B<Example:>
11631174
11641175 $pdf = PDF::API2->open('our/99page.pdf');
1165 $page = $pdf->openpage(1); # returns the first page
1166 $page = $pdf->openpage(99); # returns the last page
1167 $page = $pdf->openpage(-1); # returns the last page
1168 $page = $pdf->openpage(999); # returns undef
1169
1170 =cut
1171
1172 sub openpage {
1176 $page = $pdf->open_page(1); # returns the first page
1177 $page = $pdf->open_page(99); # returns the last page
1178 $page = $pdf->open_page(-1); # returns the last page
1179 $page = $pdf->open_page(999); # returns undef
1180
1181 =cut
1182
1183 # Deprecated (renamed)
1184 sub openpage { return open_page(@_); } ## no critic
1185
1186 sub open_page {
11731187 my $self = shift();
11741188 my $index = shift() || 0;
11751189 my ($page, $rotate, $media, $trans);
11921206 weaken $page->{' apipdf'};
11931207 weaken $page->{' api'};
11941208 $self->{'pdf'}->out_obj($page);
1195 if (($rotate = $page->find_prop('Rotate')) and (not defined($page->{' fixed'}) or $page->{' fixed'} < 1)) {
1209 if (($rotate = $page->find_prop('Rotate')) and not $page->{' opened'}) {
11961210 $rotate = ($rotate->val() + 360) % 360;
11971211
11981212 if ($rotate != 0 and not $self->default('nounrotate')) {
12271241 $trans = '';
12281242 }
12291243
1230 if (defined $page->{'Contents'} and (not defined($page->{' fixed'}) or $page->{' fixed'} < 1)) {
1244 if (defined $page->{'Contents'} and not $page->{' opened'}) {
12311245 $page->fixcontents();
12321246 my $uncontent = delete $page->{'Contents'};
12331247 my $content = $page->gfx();
12441258 $content->{' stream'} .= ' Q ';
12451259 }
12461260
1247 ## $content->{'Length'} = PDFNum(length($content->{' stream'}));
1248 # this will be fixed by the following code or content or filters
1249
1250 ## if we like compress we will do it now to do quicker saves
1261 # if we like compress we will do it now to do quicker saves
12511262 if ($self->{'forcecompress'}) {
1252 # $content->compressFlate();
12531263 $content->{' stream'} = dofilter($content->{'Filter'}, $content->{' stream'});
12541264 $content->{' nofilt'} = 1;
12551265 delete $content->{'-docompress'};
12561266 $content->{'Length'} = PDFNum(length($content->{' stream'}));
12571267 }
12581268 }
1259 $page->{' fixed'} = 1;
1269 $page->{' opened'} = 1;
12601270 }
12611271
12621272 $self->{'pdf'}->out_obj($page);
13621372 $s_page = $s_idx;
13631373 }
13641374 else {
1365 $s_page = $s_pdf->openpage($s_idx);
1375 $s_page = $s_pdf->open_page($s_idx);
13661376 }
13671377
13681378 $self->{'apiimportcache'} ||= {};
13961406
13971407 # create a whole content stream
13981408 ## technically it is possible to submit an unfinished
1399 ## (eg. newly created) source-page, but thats nonsense,
1400 ## so we expect a page fixed by openpage and die otherwise
1401 die "page not processed via openpage ..." unless $s_page->{' fixed'} == 1;
1402
1403 # since the source page comes from openpage it may already
1404 # contain the required starting 'q' without the final 'Q'
1405 # if forcecompress is in effect
1409 ## (eg. newly created) source-page, but that's nonsense,
1410 ## so we expect a page fixed by open_page and die otherwise
1411 unless ($s_page->{' opened'}) {
1412 croak join(' ',
1413 "Pages may only be imported from a complete PDF.",
1414 "Save and reopen the source PDF object first");
1415 }
1416
14061417 if (defined $s_page->{'Contents'}) {
14071418 $s_page->fixcontents();
14081419
14091420 $xo->{' stream'} = '';
1410 # openpage pages only contain one stream
1421 # open_page pages only contain one stream
14111422 my ($k) = $s_page->{'Contents'}->elements();
14121423 $k->realise();
14131424 if ($k->{' nofilt'}) {
1414 # we have a finished stream here
1415 # so we unfilter
1425 # we have a finished stream here so we unfilter
14161426 $xo->add('q', unfilter($k->{'Filter'}, $k->{' stream'}), 'Q');
14171427 }
14181428 else {
14691479 $s_page = $s_idx;
14701480 }
14711481 else {
1472 $s_page = $s_pdf->openpage($s_idx);
1482 $s_page = $s_pdf->open_page($s_idx);
14731483 }
14741484
14751485 if (ref($t_idx) eq 'PDF::API2::Page') {
8585 $string = $pdf->stringify();
8686
8787 $pdf = PDF::API2->open_scalar($string);
88 $page = $pdf->openpage(1);
88 $page = $pdf->open_page(1);
8989 $annotation = $page->annotation();
9090
9191 $annotation->text('This is an annotation', -rect => [ 72, 144, 172, 244 ]);
0 use Test::More tests => 1;
0 use Test::More tests => 4;
11
22 use strict;
33 use warnings;
1111 my $image = PDF::API2::Resource::XObject::Image::JPEG->new_api($pdf, 't/resources/1x1.jpg');
1212
1313 ok($image, q{new_api still works});
14
15
16 ##
17 ## PDF::API2
18 ##
19
20 $pdf = PDF::API2->new();
21 $pdf->page->gfx->fillcolor('blue');
22 my $pdf_string = $pdf->stringify();
23
24 # openScalar
25 $pdf = PDF::API2->openScalar($pdf_string);
26 is(ref($pdf), 'PDF::API2',
27 q{openScalar still works});
28
29 # importpage
30 my $pdf2 = PDF::API2->new();
31 my $page = $pdf2->importpage($pdf, 1);
32 is(ref($page), 'PDF::API2::Page',
33 q{importpage still works});
34
35 # openpage
36 $pdf2 = PDF::API2->open_scalar($pdf_string);
37 $page = $pdf->openpage(1);
38 is(ref($page), 'PDF::API2::Page',
39 q{openpage still works});
0 use Test::More tests => 12;
0 use Test::More tests => 16;
11
22 use warnings;
33 use strict;
44
5 use File::Temp qw(tempfile);
56 use PDF::API2;
67
78 my $pdf = PDF::API2->new();
1314 my $gfx = $pdf->page->gfx();
1415 $gfx->fillcolor('blue');
1516
16 my $new = PDF::API2->open_scalar($pdf->stringify(), );
17 my $new = PDF::API2->open_scalar($pdf->stringify());
1718 %info = $new->info();
1819 is($info{'Producer'}, 'PDF::API2 Test Suite', 'Check info string after save and reload');
1920
8990 like($pdf->stringify(), qr{/PageLabels << /Nums \[ 0 << /P \(Test\) /S /D >> \] >>},
9091 q{Page Numbering: Decimal Characters (implicit), with prefix});
9192
93
94 ##
95 ## stringify
96 ##
97
98 $pdf = PDF::API2->new(-compress => 0);
99 $gfx = $pdf->page->gfx();
100 $gfx->fillcolor('blue');
101
102 $string = $pdf->stringify();
103 like($string, qr/0 0 1 rg/,
104 q{Stringify of newly-created PDF contains expected content});
105
106 my ($fh, $filename) = tempfile();
107 print $fh $string;
108 close $fh;
109
110 $pdf = PDF::API2->open($filename);
111 $string = $pdf->stringify();
112 like($string, qr/0 0 1 rg/,
113 q{Stringify of newly-opened PDF contains expected content});
114
115 ##
116 ## saveas with same filename
117 ##
118
119 $pdf = PDF::API2->new(-compress => 0);
120 $gfx = $pdf->page->gfx();
121 $gfx->fillcolor('blue');
122
123 ($fh, $filename) = tempfile();
124 print $fh $pdf->stringify();
125 close $fh;
126
127 $pdf = PDF::API2->open($filename, -compress => 0);
128 $gfx = $pdf->page->gfx();
129 $gfx->fillcolor('red');
130 $pdf->saveas($filename);
131
132 $pdf = PDF::API2->open($filename, -compress => 0);
133 $string = $pdf->stringify();
134 like($string, qr/0 0 1 rg/,
135 q{saveas($opened_filename) contains original content});
136 like($string, qr/1 0 0 rg/,
137 q{saveas($opened_filename) contains new content});
0 use Test::More tests => 41;
0 use Test::More tests => 42;
11
22 use strict;
33 use warnings;
208208 is($string->as_pdf(),
209209 '<0000005C00000000>',
210210 q{[RT #63918] Incorrect handling of literal backslashes 2/2});
211
212
213 # RT 134957
214 $string = PDFStr("\x00\n\x00");
215 is($string->as_pdf(),
216 '<000A00>',
217 q{\n in a string containing non-printable characters is hex-encoded});