Home » FreeBSD » Migrate to FreeBSD 9.1-RELEASE (PDFJ.pm) (Tag: , )

今回の適用内容は FreeBSD のバージョンよりインストールされている Perl のバージョンに依存するため、他の FreeBSD のバージョンや OS (CentOS, Mac OS 等) でも有用でしょう。

Drive Network では、見積書・請求書等は PDFJ.pm を使用して 100% Pure Perl で作成しています。

当初作成した 2004 年以降、システム系も顧客収容機器もすべて Perl のバージョンを 5.005 から 5.8.9 に変更しました。

PDFJ.pm は 0.72 を使用していましたが、バージョンアップされたリリースではインストールや使用時の違和感が拭えず、継続して 0.72 を使用することとしました。

ところが、Perl 5.8.9 で使用すると以下の様な警告が多発します。

Pseudo-hashes are deprecated at /usr/local/lib/perl5/site_perl/5.8.9/PDFJ.pm line 2839.
Pseudo-hashes are deprecated at /usr/local/lib/perl5/site_perl/5.8.9/PDFJ.pm line 2470.
Pseudo-hashes are deprecated at /usr/local/lib/perl5/site_perl/5.8.9/PDFJ.pm line 2475.
Pseudo-hashes are deprecated at /usr/local/lib/perl5/site_perl/5.8.9/PDFJ.pm line 2481.
Pseudo-hashes are deprecated at /usr/local/lib/perl5/site_perl/5.8.9/PDFJ.pm line 3570.
Pseudo-hashes are deprecated at /usr/local/lib/perl5/site_perl/5.8.9/PDFJ.pm line 3571.
Pseudo-hashes are deprecated at /usr/local/lib/perl5/site_perl/5.8.9/PDFJ.pm line 3572.
Pseudo-hashes are deprecated at /usr/local/lib/perl5/site_perl/5.8.9/PDFJ.pm line 3573.
Pseudo-hashes are deprecated at /usr/local/lib/perl5/site_perl/5.8.9/PDFJ.pm line 3570.
Pseudo-hashes are deprecated at /usr/local/lib/perl5/site_perl/5.8.9/PDFJ.pm line 3571.
Pseudo-hashes are deprecated at /usr/local/lib/perl5/site_perl/5.8.9/PDFJ.pm line 3572.
Pseudo-hashes are deprecated at /usr/local/lib/perl5/site_perl/5.8.9/PDFJ.pm line 3573.

Pseudo-hashes は Perl 5.10 以降ではエラーとして進まない様です。5.8.9 では警告で収まりますが、1 つの PDF ファイルを作成するだけで数 100 行以上出る場合があります。

PDFJ 0.90 Perl 5.10 向け patch は公開されていますが、PDFJ 0.72 用には公開されていないため、前述の patch を参考に PDFJ 0.72 用 patch を作成しました。

--- PDFJ.pm.0    2011-06-27 17:17:13.000000000 +0900
+++ PDFJ.pm      2011-06-27 17:35:56.000000000 +0900
@@ -2206,13 +2206,6 @@
     $self->{hyphened} = 0;
 }

-my %TextLineIndex = (
-    Start => 1,
-    Count => 2,
-    Shift => 3,
-    FixedGlues => 4,
-);
-
 sub _fold {
     my($self, $linesize, $align) = @_;
     my $chunks = $self->chunks;
@@ -2307,7 +2300,13 @@
                     $self->fixsize($start, $count, $fixedglues)) / 2;
             }
         }
-        push @lines, [\%TextLineIndex, $start, $count, $shift, $fixedglues];
+        my %hash =(
+            Start      => $start ,
+            Count      => $count ,
+            Shift      => $shift ,
+            FixedGlues => $fixedglues ,
+            );
+        push(@lines,\%hash);
         $start = $nextpos;
     }
     @lines;
@@ -2322,7 +2321,7 @@
     my($can, $canleft, $pre, $word);
     if( $string =~ /([A-Za-z]-)([A-Za-z])/ ) {
         $can = $`.$1;
-        $canleft = $2.$';
+        $canleft = $2.$'; #'
     } elsif( $string =~ /[A-Za-z]{5,}/ ) {
         $pre = $`;
         $word = $&;
@@ -3289,28 +3288,30 @@

 # chunk array index
 my %ChunkIndex = (
-    Style => 1,           # PDFJ::TextStyle object
-    Mode => 2,            # description as above
-    Class => 3,           # description as above
-    Splittable => 4,      # 1 for splittable at pre-postion
-    Glue => 5,            # normal glue width
-    GlueDec => 6,         # decrease adjustable glue width
-    GlueInc => 7,         # increase adjustable glue width
-    GluePref => 8,        # glue preference
-    Count => 9,           # characters count
-    String => 10,         # characters string
-    PreShift => 11,       # postion shift at pre-postion
-    PostShift => 12,      # postion shift at post-postion
-    GlueFix => 13,        # fixed glue (to be calculated)
-    Hyphened => 14,       # 1 for splitted, 2 for hyphened
-    RubyText => 15,       # ruby PDFJ::Text object
-    AltObj => 16,         # alternative object for String
+    Style       =>  0,    # PDFJ::TextStyle object
+    Mode        =>  1,    # description as above
+    Class       =>  2,    # description as above
+    Splittable  =>  3,    # 1 for splittable at pre-postion
+    Glue        =>  4,    # normal glue width
+    GlueDec     =>  5,    # decrease adjustable glue width
+    GlueInc     =>  6,    # increase adjustable glue width
+    GluePref    =>  7,    # glue preference
+    Count       =>  8,    # characters count
+    String      =>  9,    # characters string
+    PreShift    => 10,    # postion shift at pre-postion
+    PostShift   => 11,    # postion shift at post-postion
+    GlueFix     => 12,    # fixed glue (to be calculated)
+    Hyphened    => 13,    # 1 for splitted, 2 for hyphened
+    RubyText    => 14,    # ruby PDFJ::Text object
+    AltObj      => 15,    # alternative object for String
+    RubyOverlap => 16,    # ruby overlap size
 );

 sub new {
     my($class, @args) = @_;
-    unshift @args, \%ChunkIndex;
-    bless \@args, $class;
+        my %hash  = map {  $_ => $args[ $ChunkIndex{ $_ } ] } keys(%ChunkIndex) ;
+
+    bless \%hash, $class;
 }

 sub clone {

上記を適用することで警告は収まることは確認しています。

なお、適用の有無に関わらず Perl 5.8.9 では生成される PDF ファイルの内容に md5 の照合でも差がないこともまた確認しています。

# が、PDFJ のすべての動作を確認した訳ではありません。予めご了承ください。

Random Select

豚骨野菜ラーメン 醤油 (1)
哲麺 (豚骨塩 チャーシューメン 味こいめ 脂あっさり) で、豚骨ラーメンの醤油・味噌・塩を一通り試しました。左上から 2 番目の列に 3 種類程ぽつんとあるメニュー、特に豚骨野菜ラーメンが気になっ
富士家ぜんざい + ミニぜんざい
沖縄本島 (No. 34 – はっぱとマメの木) の続きです。前日 古宇利島 (No. 1 – 古宇利大橋 〜 ハートロック) を訪れた後、ぜんざいでも食べに行く ? と案が出
神田カレーグランプリ 2013 (2)
欧風カレー ボンディ (神保町本店) を後にし、東京名物神田古本まつり 開催の一部でもある神田すずらん通り商店街をゆったり散歩しつつ 神田カレーグランプリ の開催場所まで移動しました。まるで神田カレー
青のヱビス (2)
通年販売されたためにケース買いした ザ・プレミアム・モルツ <香るプレミアム> (Part 2) がそろそろなくなりかけたため、近所のスーパーで買い足そうと訪れた際、YEBISU ヱビスビ
Pioneer BDR-XS05J (1)
VAIO Fit 13A (リカバリーメディアの作成) の続きです。VAIO Fit 13A はディスプレイサイズが 13.3inch ながらバッテリー込みで 1.31kg ですから、当然の様に DV
猫丸庵カレー (1)
沖縄本島 (No. 53 – 猫丸庵 Part 2) の続きです。猫たちとたわむれながら静かに待っていると、ついに出て来ました。私が辛いカレーを良く食べていることを知ってか、スパイスも付け
hp dv5
自宅や出張時に使用しているノート PC は現在 hp の dv5 (2008/12 頃のスペシャルエディション) です。デザインと解像度 (15.4inch, 1680 x 1050) 優先で選びまし
Herb
セールスメモ (No. 1) の続きです。以前社内で開催されたセールス・プロモーションに関する勉強会の内容を整理してみました。事例 -> 拡販リスティング広告以前に SEO 対策が必要。インター
超クリーミー泡サーバー (12)
新開発 ! 超クリーミー泡サーバー (Part 5) の続きです。せっかくですから、旧バージョンのクリーミー生サーバーと並べてみました。デザイン的には超クリーミー泡サーバーの方が好みではあります。果た
My DeskTop (Front)
IT 業界に入る 1 年程前に akia のノート PC を買った後は、4 年程はノート PC のみで作業していました。それ程必要に迫られることもなく、スペース的な理由からも不自由は感じなく使っていま
Valid HTML5 Valid CSS3 Another HTML Lint