Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

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

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

People
Owner: jbazik [...] cpan.org
Requestors: haa [...] iki.fi
MANWAR [...] cpan.org
Cc:
AdminCc:

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



Subject: Fix for PDF generation causing error messages with paid Acrobat versions
PDF::Table generates PDF which causes paid Adobe Acrobat sometimes to loudly claim that the PDF file is broken even if it works with the free Acrobat Reader and other PDF viewers. The changes needed to fix this are very small, just ordering PDF commands around a bit: 1) drawing line segments with no matching stroke operation at the end. Acrobat complains about the next command happening within unfinished path construction. FIX: Only draw the line segments if we're going to stroke later, not just always draw everything and then stroke conditionally. 2) setting color after building drawing path before fill command. Acrobat claims this is a syntax error. FIX: First set color, then draw path rectangle/line segments, then stroke/fill. These changes are pretty minor and should not break anything. See attached DIFF for out solution. I tried to code using the existing style. Background: We had trouble with PDF::Table generated output and users of paid Acrobat 7. We used Acrobat Pro 9 (free 30 day trial ;-) to debug the issue, the PreFlight PDF Syntax check showed the above issues quite clearly. Info: PDF::Table 0.9.3, Perl 5.8.8, OSX and Linux. Thanks for a great Perl module!
Subject: PDF-Table-0.9.3-acrobat-syntax-error-fix.diff
--- PDF-Table-0.9.3.original/lib/PDF/Table.pm 2006-12-27 16:44:26.000000000 +0200 +++ PDF-Table-0.9.3/lib/PDF/Table.pm 2008-11-05 16:45:40.000000000 +0200 @@ -462,9 +455,11 @@ # Draw the top line $cur_y = $table_top_y; + # Only create path when we will stroke later -- avoid Acrobat 9.0.0 PreFlight Syntax errors + if($line_w) { $gfx->move( $xbase , $cur_y ); $gfx->hline($xbase + $width ); - + } # Each iteration adds a row to the current page until the page is full # or there are no more rows to add while(scalar(@{$data}) and $cur_y-$row_h > $bot_marg) @@ -598,7 +593,7 @@ $col_props->[$j]->{'background_color'} || $background_color ) { - $gfx_bg->rect( $cur_x, $cur_y-$row_h, $calc_column_widths->[$j], $row_h); + # Set color before drawing -- avoid Acrobat 9.0.0 PreFlight Syntax errors if ( $cell_props->[$row_cnt][$j]->{'background_color'} && !$first_row ) { $gfx_bg->fillcolor($cell_props->[$row_cnt][$j]->{'background_color'}); @@ -611,6 +606,7 @@ { $gfx_bg->fillcolor($background_color); } + $gfx_bg->rect( $cur_x, $cur_y-$row_h, $calc_column_widths->[$j], $row_h); $gfx_bg->fill(); } $cur_x += $calc_column_widths->[$j]; @@ -618,14 +614,21 @@ $cur_y -= $row_h; $row_h = $min_row_h; + # Only create path when we will stroke later -- avoid Acrobat 9.0.0 PreFlight Syntax errors + if ($line_w) { $gfx->move( $xbase , $cur_y ); $gfx->hline( $xbase + $width ); + } $rows_counter++; $row_cnt++ unless ( $first_row ); $first_row = 0; }# End of while(scalar(@{$data}) and $cur_y-$row_h > $bot_marg) # Draw vertical lines + + if($line_w) { # Only create path when we will stroke later -- avoid Acrobat 9.0.0 PreFlight Syntax errors + # Set color before lines -- avoid Acrobat 9.0.0 PreFlight Syntax errors + $gfx->fillcolor( $border_color); $gfx->move( $xbase, $table_top_y); $gfx->vline( $cur_y ); my $cur_x = $xbase; @@ -637,8 +640,9 @@ } # ACTUALLY draw all the lines - $gfx->fillcolor( $border_color); - $gfx->stroke if $line_w; + $gfx->stroke; + }# End of if($line_w) + $pg_cnt++; }# End of while(scalar(@{$data})) }# End of if(ref $data eq 'ARRAY')
Subject: Patched PDF::Table 0.9.3
Please find attached the patched PDF::Table.pm as mentioned in the Bug Id: 40705
Subject: PDF-Table.pm

Message body is not shown because it is too large.

I don't have any way to test this, but I understand the problem. I changed it so that no gfx calls are made if the stroke width is zero. It's essentially what you suggested. Let me know if that doesn't fix it. The new version is 0.9.4, just uploaded to cpan. John
Fixed in 0.9.4, thanks. John