Skip Menu |

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

Report information
The Basics
Id: 53698
Status: open
Priority: 0/
Queue: CAM-PDF

People
Owner: Nobody in particular
Requestors: Hans.Reichenecker [...] woehr.de
Cc:
AdminCc:

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



Subject: Error Bad request for object HASH(0xe927170) at position 0 in the file
CAM-PDF does a good Job. But when I create a pdf with OpenOffice it does't work. The new Form is generated but the fields are not filled: Command: fillpdffields.pl Form4BugReport.pdf test.pdf AuftragNr 0901234 Datum 15 Result: Bad request for object HASH(0x1e35a810) at position 0 in the file Bad request for object HASH(0x1e35a810) at position 0 in the file What went wrong? Regards hr perl -v This is perl, v5.8.8 built for x86_64-linux-thread-multi uname -a Linux bls-1.woehr.de 2.6.18-92.1.13.el5 #1 SMP Thu Sep 4 03:51:21 EDT 2008 x86_64
Subject: Form4BugReport.pdf
Download Form4BugReport.pdf
application/force-download 12.2k

Message body not shown because it is not plain text.

Subject: Form4BugReport.odt
Download Form4BugReport.odt
application/vnd.oasis.opendocument.text 9.8k

Message body not shown because it is not plain text.

Well it's a start - this patch for 1.52 works with the given test case. No guarantees on what else might break though. --- /usr/local/share/perl/5.10.0/CAM/PDF.pm 2010-01-15 01:31:25.000000000 -0600 +++ CAM/PDF.pm 2010-01-15 01:43:07.270502531 -0600 @@ -2825,9 +2825,7 @@ sub getFormField { my $root = $self->getRootDict()->{AcroForm}; return if (!$root); - $parent = $self->dereference($root->{value}); - return if (!$parent); - my $dict = $self->getValue($parent); + my $dict = $self->getValue($root); return if (!exists $dict->{Fields}); $kidlist = $self->getValue($dict->{Fields}); } @@ -4576,15 +4574,16 @@ sub fillFormFields ## no critic(Subrout # Search out font resources. This is a total kluge. # TODO: the right way to do this is to look for the DR # attribute in the form element or it's ancestors. - for my $font (@rsrcs) - { - my $fobj = $self->dereference("/$font", 'All'); - if (!$fobj) - { - die "Could not find resource /$font while preparing form field $key\n"; - } - $fdict->{$font} = CAM::PDF::Node->new('reference', $fobj->{objnum}, $formonum, $formgnum); - } +# RAL 20100115 this code doesn't work for the test case in bug #53698 +# for my $font (@rsrcs) +# { +# my $fobj = $self->dereference("/$font", 'All'); +# if (!$fobj) +# { +# die "Could not find resource /$font while preparing form field $key\n"; +# } +# $fdict->{$font} = CAM::PDF::Node->new('reference', $fobj->{objnum}, $formonum, $formgnum); +# } } } $filled++;
RT-Send-CC: cdolan [...] cpan.org
The patch passes all tests distributed with version 1.52, and also passes the new test case attached. The requestor's PDF input file is renamed in this attachment for the new test case. The first part of the patch fixes the object HASH error. The font search code near the end of fillFormFields() is commented for the routine to complete successfully. Instead of this, it might be better fail softly, by doing the search but not dying if the font isn't found. I tried looking for the font in $propdict because it includes the field's inherited attributes, however I didn't find a suitable object. Chris, can you run this patch against the full battery of tests and confirm that this patch resolves the ticket? Robert
Subject: rt53698.t
#!/usr/bin/perl -w use warnings; use strict; use Test::More tests => 1; use CAM::PDF; # tests the patch for bug report 53698 my $doc = CAM::PDF->new('t/rt53698.pdf') || die $CAM::PDF::errstr; ok($doc->fillFormFields(qw( AuftragNr 0901234 Datum 15 )), 'fields filled');
Subject: 53698.patch
--- /usr/local/share/perl/5.10.0/CAM/PDF.pm 2010-01-15 01:31:25.000000000 -0600 +++ CAM/PDF.pm 2010-01-15 01:54:56.126502736 -0600 @@ -2825,9 +2825,7 @@ sub getFormField { my $root = $self->getRootDict()->{AcroForm}; return if (!$root); - $parent = $self->dereference($root->{value}); - return if (!$parent); - my $dict = $self->getValue($parent); + my $dict = $self->getValue($root); return if (!exists $dict->{Fields}); $kidlist = $self->getValue($dict->{Fields}); } @@ -4576,15 +4574,16 @@ sub fillFormFields ## no critic(Subrout # Search out font resources. This is a total kluge. # TODO: the right way to do this is to look for the DR # attribute in the form element or it's ancestors. - for my $font (@rsrcs) - { - my $fobj = $self->dereference("/$font", 'All'); - if (!$fobj) - { - die "Could not find resource /$font while preparing form field $key\n"; - } - $fdict->{$font} = CAM::PDF::Node->new('reference', $fobj->{objnum}, $formonum, $formgnum); - } +# this code doesn't work with the fix for bug #53698 +# for my $font (@rsrcs) +# { +# my $fobj = $self->dereference("/$font", 'All'); +# if (!$fobj) +# { +# die "Could not find resource /$font while preparing form field $key\n"; +# } +# $fdict->{$font} = CAM::PDF::Node->new('reference', $fobj->{objnum}, $formonum, $formgnum); +# } } } $filled++;
Subject: rt53698.pdf
Download rt53698.pdf
application/pdf 12.2k

Message body not shown because it is not plain text.