Subject: | File not closed when specifying handle instead of name |
Date: | Mon, 14 Nov 2016 18:25:52 +0000 |
To: | bug-PDF-Create [...] rt.cpan.org |
From: | Andrew Beverley <andy [...] andybev.com> |
When specifying a file handle instead of file name:
my $pdf = PDF::Create->new(
fh => $fh,
Author => 'John Doe',
Title => 'Sample PDF',
CreationDate => [ localtime ]
);
the file is not closed properly and is therefore corrupt. This is the fix:
--- a/lib/PDF/Create.pm
+++ b/lib/PDF/Create.pm
@@ -557,7 +557,7 @@ sub close {
$self->add_info;
$self->add_crossrefsection;
$self->add_trailer;
- $self->{'fh'}->close if defined $self->{'fh'} && defined $self->{'filename'};
+ $self->{'fh'}->close if defined $self->{'fh'};
$self->{'data'};
}
Thanks,
Andy