The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
CHANGES 07
MANIFEST 01
META.json 413
META.yml 912
Makefile.PL 1120
lib/PDF/Create/Outline.pm 14
lib/PDF/Create/Page.pm 14
lib/PDF/Create.pm 611
lib/PDF/Image/GIF.pm 11
lib/PDF/Image/JPEG.pm 11
t/09-cgi-script.pl 22
t/09-cgi.t 22
t/51-memory-leak.t 0104
13 files changed (This is a version diff) 38182
@@ -1,3 +1,10 @@
+1.10 2014.08.22
+    Fix test that used to use CGI.pm
+
+1.09 2014.08.21
+    Eliminate the need for CGI.pm in the test RT #98222
+    Some POD updates.
+    Eliminate memory leak RT #93412 thanks to Chris Jack.
 
 1.08 2013.12.11
 
@@ -22,6 +22,7 @@ t/09-cgi-script.pl
 t/09-cgi.t
 t/11-encode.t
 t/50-versioning.t
+t/51-memory-leak.t
 t/99-wifi-parabola.t
 t/pdf-logo.gif
 t/pdf-logo.jpg
@@ -4,7 +4,7 @@
       "unknown"
    ],
    "dynamic_config" : 1,
-   "generated_by" : "ExtUtils::MakeMaker version 6.78, CPAN::Meta::Converter version 2.132661",
+   "generated_by" : "ExtUtils::MakeMaker version 6.98, CPAN::Meta::Converter version 2.140640",
    "license" : [
       "perl_5"
    ],
@@ -34,15 +34,24 @@
          "requires" : {
             "Carp" : "0",
             "Data::Dumper" : "0",
-            "FileHandle" : "0"
+            "FileHandle" : "0",
+            "Scalar::Util" : "0"
+         }
+      },
+      "test" : {
+         "requires" : {
+            "Test::LeakTrace" : "0.14",
+            "Test::More" : "1.00"
          }
       }
    },
    "release_status" : "stable",
    "resources" : {
       "repository" : {
-         "url" : "http://github.com/szabgab/pdf-create"
+         "type" : "git",
+         "url" : "http://github.com/szabgab/pdf-create.git",
+         "web" : "http://github.com/szabgab/pdf-create"
       }
    },
-   "version" : "1.08"
+   "version" : "1.10"
 }
@@ -3,24 +3,27 @@ abstract: 'create PDF files'
 author:
   - unknown
 build_requires:
-  ExtUtils::MakeMaker: 0
+  ExtUtils::MakeMaker: '0'
+  Test::LeakTrace: '0.14'
+  Test::More: '1.00'
 configure_requires:
-  ExtUtils::MakeMaker: 0
+  ExtUtils::MakeMaker: '0'
 dynamic_config: 1
-generated_by: 'ExtUtils::MakeMaker version 6.78, CPAN::Meta::Converter version 2.132661'
+generated_by: 'ExtUtils::MakeMaker version 6.98, CPAN::Meta::Converter version 2.140640'
 license: perl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
-  version: 1.4
+  version: '1.4'
 name: PDF-Create
 no_index:
   directory:
     - t
     - inc
 requires:
-  Carp: 0
-  Data::Dumper: 0
-  FileHandle: 0
+  Carp: '0'
+  Data::Dumper: '0'
+  FileHandle: '0'
+  Scalar::Util: '0'
 resources:
-  repository: http://github.com/szabgab/pdf-create
-version: 1.08
+  repository: http://github.com/szabgab/pdf-create.git
+version: '1.10'
@@ -8,17 +8,26 @@ WriteMakefile(
 	NAME          => "PDF::Create",
 	VERSION_FROM  => "lib/PDF/Create.pm",
 	ABSTRACT_FROM => "lib/PDF/Create.pm",
-    'PREREQ_PM'   => {
-               'Carp' => 0,
-               'FileHandle' => 0,
-               'Data::Dumper' => 0,
-    },
+	PREREQ_PM   => {
+		'Carp'         => 0,
+		'FileHandle'   => 0,
+		'Data::Dumper' => 0,
+		'Scalar::Util' => 0,
+	},
+	TEST_REQUIRES => {
+		'Test::More'      => '1.00',
+		'Test::LeakTrace' => '0.14',
+	},
 	LICENSE       => "perl",
 	dist          => { COMPRESS => "gzip", SUFFIX => "gz" },
-	clean 		  => { FILES => '*.bak *.old mibs/*.dump *.pdf' . 'lib/*/*~ lib/*/*/*~' },
-    META_MERGE => {
-          resources => {
-               repository => 'http://github.com/szabgab/pdf-create',
-          }
-    },
+	clean         => { FILES => '*.bak *.old mibs/*.dump *.pdf' . 'lib/*/*~ lib/*/*/*~' },
+	META_MERGE => {
+		'meta-spec' => { version => 2 },
+		resources => {
+			repository => {
+				type => 'git',
+				url  => 'http://github.com/szabgab/pdf-create.git',
+				web  => 'http://github.com/szabgab/pdf-create',
+			}
+	}},
 );
@@ -20,8 +20,9 @@ use warnings;
 use Carp;
 use FileHandle;
 use Data::Dumper;
+use Scalar::Util qw(weaken);
 
-our $VERSION = '1.08';
+our $VERSION = '1.10';
 our $DEBUG   = 0;
 
 sub new
@@ -41,7 +42,9 @@ sub add
 	$outline->{'id'}     = shift;
 	$outline->{'name'}   = shift;
 	$outline->{'Parent'} = $self;
+	weaken $outline->{Parent};
 	$outline->{'pdf'}    = $self->{'pdf'};
+	weaken $outline->{pdf};
 	my %params = @_;
 	$outline->{'Title'}  = $params{'Title'}  if defined $params{'Title'};
 	$outline->{'Action'} = $params{'Action'} if defined $params{'Action'};
@@ -21,8 +21,9 @@ use Carp;
 use FileHandle;
 use Data::Dumper;
 use POSIX qw(setlocale LC_NUMERIC);
+use Scalar::Util qw(weaken);
 
-our $VERSION = '1.08';
+our $VERSION = '1.10';
 our $DEBUG   = 0;
 
 my $font_widths = &init_widths;
@@ -45,7 +46,9 @@ sub add
 	my $self = shift;
 	my $page = PDF::Create::Page->new();
 	$page->{'pdf'}    = $self->{'pdf'};
+	weaken $page->{pdf};
 	$page->{'Parent'} = $self;
+	weaken $page->{Parent};
 	$page->{'id'}     = shift;
 	$page->{'name'}   = shift;
 	push @{ $self->{'Kids'} }, $page;
@@ -17,12 +17,13 @@ use warnings;
 
 use Carp qw(confess croak cluck carp);
 use FileHandle;
+use Scalar::Util qw(weaken);
 use PDF::Create::Page;
 use PDF::Create::Outline;
 use PDF::Image::GIF;
 use PDF::Image::JPEG;
 
-our $VERSION = '1.08';
+our $VERSION = '1.10';
 my $DEBUG = 0;
 
 
@@ -44,6 +45,7 @@ sub new
 	$self->{'pages'}          = PDF::Create::Page->new();
 	$self->{'current_page'}   = $self->{'pages'};
 	$self->{'pages'}->{'pdf'} = $self;                     # circular reference
+	weaken $self->{pages}{pdf};
 	$self->{'page_count'}     = 0;
 
 	$self->{'outline_count'} = 0;
@@ -528,6 +530,7 @@ sub new_outline
 	unless ( defined $self->{'outlines'} ) {
 		$self->{'outlines'}             = PDF::Create::Outline->new();
 		$self->{'outlines'}->{'pdf'}    = $self;                        # circular reference
+		weaken $self->{'outlines'}->{'pdf'};
 		$self->{'outlines'}->{'Status'} = 'opened';
 	}
 	my $parent = $params{'Parent'} || $self->{'outlines'};
@@ -1527,6 +1530,8 @@ Set the width of subsequent lines to C<w> points.
 
 Set the color of the subsequent drawing operations.
 
+Valid r, g, and b values are each between 0.0 and 1.0, inclusive.
+
 Each color ranges from 0.0 to 1.0, that is, darkest red (0.0) to
 brightest red (1.0).  The same holds for green and blue.  These three
 colors mix additively to produce the colors between black (0.0, 0.0,
@@ -1679,15 +1684,15 @@ My git repository for C<PDF::Create> L<http://github.com/markusb/pdf-create>
 
 =head2 Other PDF procesing CPAN modules
 
-L<http://search.cpan.org/perldoc?PDF::Labels> Routines to produce formatted pages of mailing labels in PDF, uses PDF::Create internally
+L<PDF::Labels> Routines to produce formatted pages of mailing labels in PDF, uses PDF::Create internally
 
-L<http://search.cpan.org/perldoc?PDF::Haru> Perl interface to Haru Free PDF Library
+L<PDF::Haru> Perl interface to Haru Free PDF Library
 
-L<http://search.cpan.org/perldoc?PDF::EasyPDF> PDF creation from a one-file module, similar to PDF::Create
+L<PDF::EasyPDF> PDF creation from a one-file module, similar to PDF::Create
 
-L<http://search.cpan.org/perldoc?PDF::CreateSimple> Yet another PDF creation module
+L<PDF::CreateSimple> Yet another PDF creation module
 
-L<http://search.cpan.org/perldoc?PDF::Report> A wrapper written for PDF::API2
+L<PDF::Report> A wrapper written for PDF::API2
 
 =head1 AUTHORS
 
@@ -17,7 +17,7 @@ use strict;
 use warnings;
 use FileHandle;
 
-our $VERSION = '1.08';
+our $VERSION = '1.10';
 our $DEBUG   = 0;
 
 sub new
@@ -17,7 +17,7 @@ use strict;
 use warnings;
 use FileHandle;
 
-our $VERSION = '1.08';
+our $VERSION = '1.10';
 our $DEBUG   = 0;
 
 sub new
@@ -8,7 +8,7 @@
 BEGIN { unshift @INC, "lib", "../lib" }
 use strict;
 use PDF::Create;
-use CGI;
+#use CGI;
 
 #
 # Write HTTP header with application/pdf as doc type
@@ -17,7 +17,7 @@ use CGI;
 # You should change this to
 #   -type => 'application/x-pdf', -attachment => $pdfname
 #
-print CGI::header( -type => 'application/pdf' );
+#print CGI::header( -type => 'application/pdf' );
 
 #
 # Start the pdf with '-' (stdout) as filename
@@ -23,8 +23,8 @@ my $cginame = File::Spec->catfile(dirname($0) . "/09-cgi-script.pl");
 # run the cgi
 #
 my @out = `$Config{"perlpath"} $cginame`;
-shift @out;
-shift @out;
+#shift @out;
+#shift @out;
 #diag $out;
 diag $pdfname;
 if (open my $fh, '>', $pdfname) {
@@ -0,0 +1,104 @@
+use strict;
+use warnings;
+
+use File::Temp qw(tempdir);
+use PDF::Create;
+use Test::More;
+use Test::LeakTrace;
+
+plan tests => 4;
+
+my $dir = tempdir( CLEANUP => 1 );
+
+no_leaks_ok {
+    my $pdf = PDF::Create->new('filename' => "$dir/mypdf.pdf",
+                              'Version'  => 1.2,
+                              'PageMode' => 'UseOutlines',
+                              'Author'   => 'Fabien Tassin',
+                              'Title'    => 'My title',
+                         );
+};
+
+no_leaks_ok {
+    my $pdf = PDF::Create->new('filename' => "$dir/mypdf.pdf",
+                              'Version'  => 1.2,
+                              'PageMode' => 'UseOutlines',
+                              'Author'   => 'Fabien Tassin',
+                              'Title'    => 'My title',
+                         );
+    my $root = $pdf->new_page('MediaBox' => [ 0, 0, 612, 792 ]);
+};
+
+no_leaks_ok {
+    my $pdf = PDF::Create->new('filename' => "$dir/mypdf.pdf",
+                              'Version'  => 1.2,
+                              'PageMode' => 'UseOutlines',
+                              'Author'   => 'Fabien Tassin',
+                              'Title'    => 'My title',
+                         );
+    my $root = $pdf->new_page('MediaBox' => [ 0, 0, 612, 792 ]);
+
+    # Add a page which inherits its attributes from $root
+    my $page = $root->new_page;
+
+    # Prepare 2 fonts
+    my $f1 = $pdf->font('Subtype'  => 'Type1',
+                        'Encoding' => 'WinAnsiEncoding',
+                        'BaseFont' => 'Helvetica');
+    my $f2 = $pdf->font('Subtype'  => 'Type1',
+                        'Encoding' => 'WinAnsiEncoding',
+                        'BaseFont' => 'Helvetica-Bold');
+
+	#$DB::signal = 1;
+    # Prepare a Table of Content
+    my $toc = $pdf->new_outline('Title' => 'Document',
+                                'Destination' => $page);
+};
+
+ 
+no_leaks_ok {
+    my $pdf = PDF::Create->new('filename' => "$dir/mypdf.pdf",
+                              'Version'  => 1.2,
+                              'PageMode' => 'UseOutlines',
+                              'Author'   => 'Fabien Tassin',
+                              'Title'    => 'My title',
+                         );
+    my $root = $pdf->new_page('MediaBox' => [ 0, 0, 612, 792 ]);
+
+    # Add a page which inherits its attributes from $root
+    my $page = $root->new_page;
+
+    # Prepare 2 fonts
+    my $f1 = $pdf->font('Subtype'  => 'Type1',
+                        'Encoding' => 'WinAnsiEncoding',
+                        'BaseFont' => 'Helvetica');
+    my $f2 = $pdf->font('Subtype'  => 'Type1',
+                        'Encoding' => 'WinAnsiEncoding',
+                        'BaseFont' => 'Helvetica-Bold');
+
+    # Prepare a Table of Content
+    my $toc = $pdf->new_outline('Title' => 'Document',
+                                'Destination' => $page);
+    $toc->new_outline('Title' => 'Section 1');
+    my $s2 = $toc->new_outline('Title' => 'Section 2',
+                               'Status' => 'closed');
+    $s2->new_outline('Title' => 'Subsection 1');
+
+    $page->stringc($f2, 40, 306, 426, "PDF::Create");
+    $page->stringc($f1, 20, 306, 396, "version $PDF::Create::VERSION");
+
+    # Add another page
+    my $page2 = $root->new_page;
+    $page2->line(0, 0, 612, 792);
+    $page2->line(0, 792, 612, 0);
+
+    $toc->new_outline('Title' => 'Section 3');
+    $pdf->new_outline('Title' => 'Summary');
+
+    # Add something to the first page
+    $page->stringc($f1, 20, 306, 300,
+                   'by Fabien Tassin <fta@oleane.net>');
+
+    # Add the missing PDF objects and a the footer then close the file
+    $pdf->close;
+};