Skip Menu |

This queue is for tickets about the PDF-Report CPAN distribution.

Report information
The Basics
Id: 47019
Status: resolved
Priority: 0/
Queue: PDF-Report

People
Owner: Nobody in particular
Requestors: sean.robinson [...] sccmail.maricopa.edu
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: [Fwd: Re: PDF::Report patch]
Date: Tue, 16 Jun 2009 11:32:26 -0700
To: bug-PDF-Report [...] rt.cpan.org
From: Sean Robinson <sean.robinson [...] sccmail.maricopa.edu>
Show quoted text
-------- Original Message -------- Subject: Re: PDF::Report patch Date: Tue, 16 Jun 2009 13:53:45 -0400 From: Andy Orr <aorr76@gmail.com> To: Sean Robinson <sean.robinson@sccmail.maricopa.edu> References: <4A37CF23.80400@sccmail.maricopa.edu> In the future, the best way to submit a patch, bugfix, or request is through rt.cpan.org <http://rt.cpan.org>. Nothing against your patch, but unfortunately I did not go though old email to find patches or bug reports. For this last release I applied all the patches and fixes from RT. Thanks On Tue, Jun 16, 2009 at 12:58 PM, Sean Robinson <sean.robinson@sccmail.maricopa.edu <mailto:sean.robinson@sccmail.maricopa.edu>> wrote: I see you have updated PDF::Report recently. I am resubmitting the patch to make meta-info an instance variable and retrievable. This patch is against PDF::Report 1.32. Can I make any changes that would make you more likely to accept the patch into the next release?
-------- Original Message -------- Subject: Re: PDF::Report patch Date: Mon, 1 Dec 2008 20:01:07 -0500 From: Andy Orr <aorr76@gmail.com <mailto:aorr76@gmail.com>> To: Sean Robinson <sean.robinson@sccmail.maricopa.edu <mailto:sean.robinson@sccmail.maricopa.edu>> References: <493456A7.5020409@sccmail.maricopa.edu <mailto:493456A7.5020409@sccmail.maricopa.edu>> Sean, I'm glad you like PDF::Report. And thanks for the patch. This is actually good timing as I am close to releasing an update. The new version is mostly minor bugfixes. One of these days I'm going to do a full re-write. The code is pretty old and needs cleaned up... -Andy On Mon, Dec 1, 2008 at 4:27 PM, Sean Robinson <sean.robinson@sccmail.maricopa.edu <mailto:sean.robinson@sccmail.maricopa.edu> <mailto:sean.robinson@sccmail.maricopa.edu <mailto:sean.robinson@sccmail.maricopa.edu>>> wrote: Attached is a patch against PDF::Report 1.30 to handle PDF meta-info slightly differently. I will assign the copyright to you on this if you include it in PDF::Report. Mainly, so that I don't have to maintain a separate patch set. 8-) First, the patch makes %INFO into an instance variable from the class variable that it is currently. Most if the patch concerns this change, as the way of calling the variable needed to change, also. I needed this since I had two instances of a PDF::Report sub-class open at once and setting the meta-info on the second was tramping on the already set meta-info on the first instance. Second, it adds a ->getInfo() method to match ->setInfo(). This method gets the info from the PDF file using the PDF::API2 instance embedded in each PDF::Report instance. Lastly, thank you for releasing PDF::Report. It made PDF::API2 approachable and I use PDF::Report in several different projects, from custom reports to on-the-fly small poster generation. -- Sean Robinson Laboratory Technician Physics Astronomy Geology sean.robinson@sccmail.maricopa.edu <mailto:sean.robinson@sccmail.maricopa.edu> diff --git a/lib/PDF/Report.pm b/lib/PDF/Report.pm index 7b735ea..5440895 100755 --- a/lib/PDF/Report.pm +++ b/lib/PDF/Report.pm @@ -43,16 +43,6 @@ my ( $day, $month, $year )= ( localtime( time ) )[3..5]; my $DATE=sprintf "%02d/%02d/%04d", ++$month, $day, 1900 + $year; # Document info -my %INFO = - ( - Creator => "None", - Producer => "None", - CreationDate => $DATE, - Title => "Untitled", - Subject => "None", - Author => "Auto-generated", - ); - my @parameterlist=qw( PageSize PageWidth @@ -151,6 +141,15 @@ sub new { FtrFontSize => 11, MARGIN_DEBUG => 0, PDF_API2_VERSION => $PDF::API2::VERSION, + INFO => { + Creator => "None", + Producer => "None", + CreationDate => $DATE, + Title => "Untitled", + Subject => "None", + Author => "Auto-generated", + }, + ######################################################## # Cache for font object caching -- used by setFont() ### @@ -1004,19 +1003,34 @@ sub setInfo { my ($self, %info) = @_; # Over-ride or define %INFO values - foreach my $key (keys %INFO) { - if (length($info{$key}) and ($info{$key} ne $INFO{$key})) { - $INFO{$key} = $info{$key}; + foreach my $key (keys %{$self->{INFO}}) { + if (length($info{$key}) and ($info{$key} ne ${$self->{INFO}}{$key})) { + ${$self->{INFO}}{$key} = $info{$key}; } } - my @orig_keys = keys(%INFO); + my @orig_keys = keys(%{$self->{INFO}}); foreach my $key (keys %info) { if (! grep /$key/, @orig_keys) { - $INFO{$key} = $info{$key}; + ${$self->{INFO}}{$key} = $info{$key}; } } } +=item %infohash = $pdf->getInfo(); + +Gets meta-data from the info structure of the document. +Valid keys for %infohash: Creator, Producer, CreationDate, +Title, Subject, Author, etc. + +=cut + +sub getInfo { + my $self = shift; + + my %info = $self->{pdf}->info(); + return %info; +} + =item $pdf->saveAs($fileName); Saves the document to a file. @@ -1035,7 +1049,7 @@ sub saveAs { my $self = shift; my $fileName = shift; - $self->{pdf}->info(%INFO); + $self->{pdf}->info(%{$self->{INFO}}); $self->{pdf}->saveas($fileName); $self->{pdf}->end(); } @@ -1070,7 +1084,7 @@ sub Finish { &gen_page_footer($self, $total, $callback); } - $self->{pdf}->info(%INFO); + $self->{pdf}->info(%{$self->{INFO}}); my $out = $self->{pdf}->stringify; return $out; -- Sean Robinson Laboratory Technician Physics Astronomy Geology sean.robinson@sccmail.maricopa.edu
Patch applied in version 1.33