1--- PDFJ.pm.orig 2006-10-22 19:27:42.000000000 +0900 2+++ PDFJ.pm 2010-01-08 14:10:29.259440247 +0900 3@@ -21,6 +21,24 @@ 4 bytes->import unless $@; 5 } 6 7+# use hash in place of phash for Perl 5.9 or later 8+BEGIN { 9+ my $body; 10+ unless ($] > 5.008) { 11+ $body = sub { [ @_ ] }; 12+ } else { 13+ $body = sub { 14+ my($pos) = @_; 15+ my $hash; 16+ foreach my $k (keys(%$pos)) { 17+ $hash->{$k} = $_[$pos->{$k}]; 18+ } 19+ return $hash; 20+ }; 21+ } 22+ eval { sub _hash { $body->(@_) } }; 23+} 24+ 25 @EXFUNC = qw( 26 PDFJ::Doc::Doc 27 PDFJ::TextStyle::TStyle PDFJ::Text::Text 28@@ -1093,7 +1111,7 @@ 29 return; 30 } 31 push @filters, @addfilters if @addfilters; 32- my $filter = @filters > 1 ? [map {PDFJ::Object::name($_)} @filters] : 33+ $filter = @filters > 1 ? [map {PDFJ::Object::name($_)} @filters] : 34 PDFJ::Object::name($filters[0]); 35 ($encoded, $filter); 36 } 37@@ -1537,7 +1555,7 @@ 38 unless( $self->{outlinetree} ) { 39 $self->{outlinetree} = []; 40 } 41- my $parent = $self->{outlinetree}; 42+ $parent = $self->{outlinetree}; 43 for( my $j = 0; $j < $level; $j++ ) { 44 push @$parent, ['', undef, undef, undef, []] unless @$parent; 45 $parent = $$parent[$#$parent][4]; 46@@ -2720,7 +2738,7 @@ 47 my $render = $self->{render} || 0; 48 my @shapepdf = $self->{shapestyle} ? $self->{shapestyle}->pdf : (); 49 my $contentmark = $self->{contentmark}; 50- my @pdf = $contentmark ne '' ? ("/$contentmark BMC q") : ("q"); 51+ my @pdf = ($contentmark || "") ne '' ? ("/$contentmark BMC q") : ("q"); 52 push @pdf, @shapepdf if @shapepdf; 53 push @pdf, "BT /$fontname", number($fontsize), "Tf", number($rise), "Ts $render Tr"; 54 @pdf; 55@@ -2728,7 +2746,7 @@ 56 57 sub endpdf { 58 my($self) = @_; 59- $self->{contentmark} ne '' ? "] TJ ET Q EMC " : "] TJ ET Q "; 60+ ($self->{contentmark} || "") ne '' ? "] TJ ET Q EMC " : "] TJ ET Q "; 61 } 62 63 #-------------------------------------------------------------------------- 64@@ -2874,6 +2892,7 @@ 65 my($self, $indent) = @_; 66 my $style = $self->style; 67 return unless $style->{font}; 68+ $indent = '' if (not defined $indent); 69 for my $text(@{$self->texts}) { 70 if( PDFJ::Util::objisa($text, 'PDFJ::Text') ) { 71 $text->style->merge($style); 72@@ -3201,8 +3220,8 @@ 73 $preskip = $lineskip; 74 } 75 push @lines, 76- [\%TextLineIndex, $start, $count, $shift, $fixedglues, $preaols, 77- $postaols, $preskip]; 78+ PDFJ::_hash(\%TextLineIndex, $start, $count, $shift, $fixedglues, 79+ $preaols, $postaols, $preskip); 80 $start = $nextpos; 81 } 82 @lines; 83@@ -4036,6 +4055,7 @@ 84 $font->{subset_unicodes}{$unicode} = 1 if $unicode; 85 } 86 if( @$chunks ) { 87+ no warnings 'deprecated'; 88 my $lastchunk = $chunks->[$#$chunks]; 89 my $lastmode = $lastchunk->{Mode}; 90 my $lastclass = $lastchunk->{Class}; 91@@ -4132,7 +4152,7 @@ 92 my($self, $str, $noshift) = @_; 93 my $style = $self->style; 94 my $result = []; 95- my @c = split('', $str); 96+ my @c = split('', $str || ""); 97 for( my $j = 0; $j <= $#c; $j++ ) { 98 my $c = $c[$j]; 99 next if $c eq "\x00"; 100@@ -4322,8 +4342,7 @@ 101 102 sub new { 103 my($class, @args) = @_; 104- unshift @args, \%ChunkIndex; 105- bless \@args, $class; 106+ bless PDFJ::_hash(\%ChunkIndex, @args), $class; 107 } 108 109 sub clone { 110@@ -4371,7 +4390,7 @@ 111 croak "linefeed specification missing" unless exists $style->{linefeed}; 112 croak "align specification missing" unless $style->{align}; 113 my $self = bless { text => $text, style => $style }, $class; 114- $self->typename($style->{typename}) if $style->{typename} ne ''; 115+ $self->typename($style->{typename}) if ($style->{typename}); 116 $self->{linefeed} = $style->{linefeed}; 117 if( $self->{linefeed} =~ s/s(\d+%?)// ) { 118 $self->{lineskipmin} = $1; 119@@ -4817,7 +4836,7 @@ 120 my $self = bless { direction => $direction, objects => \@objects, 121 xpreshift => 0, xpostshift => 0, ypreshift => 0, ypostshift => 0, 122 style => $style }, $dclass; 123- $self->typename($style->{typename}) if $style->{typename} ne ''; 124+ $self->typename($style->{typename}) if ($style->{typename}); 125 $self->_checkobjects; 126 $self->_calcsize; 127 $self->adjustwidth($style->{width}) if $style->{width}; 128@@ -5136,10 +5155,10 @@ 129 carp "break fails"; 130 return; 131 } 132- if( @bobjects && $bobjects[0]->{floatsep} eq 'b' ) { 133+ if( @bobjects && ($bobjects[0]->{floatsep} || "") eq 'b' ) { 134 shift @bobjects; 135 } 136- if( @bobjects && $bobjects[$#bobjects]->{floatsep} eq 'e' ) { 137+ if( @bobjects && ($bobjects[$#bobjects]->{floatsep} || '') eq 'e' ) { 138 pop @bobjects; 139 } 140 if( $repeatheader && (@bobjects >= $repeatheader) && @objects ) { 141@@ -5188,7 +5207,7 @@ 142 } elsif( $float eq '' || $float eq 'h' ) { 143 $inspos = @$objects; 144 while( $inspos > 0 && ($objects->[$inspos - 1]->float =~ /e/ || 145- $objects->[$inspos - 1]->{floatsep} =~ /e/)) { 146+ ($objects->[$inspos - 1]->{floatsep} || "") =~ /e/)) { 147 $inspos--; 148 } 149 } else { 150@@ -5210,7 +5229,7 @@ 151 $height += skipsize($self->{objects}->[$j-1], $obj); 152 } 153 if( PDFJ::Util::objisa($obj, 'PDFJ::Showable') ) { 154- my $owidth = $obj->width + $obj->blockalign; 155+ my $owidth = $obj->width + ($obj->blockalign || 0); 156 $width = $width < $owidth ? $owidth : $width; 157 $height += $obj->height; 158 } elsif( PDFJ::Util::objisa($obj, 'PDFJ::BlockElement') ) { 159@@ -5229,7 +5248,7 @@ 160 for( my $j = 0; $j < $objnum; $j++ ) { 161 my $obj = $self->{objects}->[$j]; 162 if( PDFJ::Util::objisa($obj, 'PDFJ::Showable') ) { 163- my $aib = $obj->blockalign; 164+ my $aib = $obj->blockalign || ''; 165 if( $aib eq '' ) { 166 $indents[$j] = ($width - $obj->width) * $indentratio; 167 } elsif( $aib eq 'b' ) { 168@@ -6635,8 +6654,8 @@ 169 if( $lastobjnum ) { 170 for my $objnum(1 .. $lastobjnum) { 171 printf $handle "%010.10d %05.5d n \n", 172- $self->{objposlist}->[$objnum], 173- $objtable->get($objnum)->{gennum}; 174+ $self->{objposlist}->[$objnum] || 0, 175+ $objtable->get($objnum)->{gennum} || 0; 176 } 177 } 178 print $handle "\n"; 179