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

ESXi 5.1 Install - NG (Boot image is corrupted)
ある日、予備機に VMware ESXi 5.1.0 Update 1 をインストールしました。ISO イメージ自体が 300 MB 強でじわじわと時間が掛かりますが、これからまさにインストーラが起動
豚骨野菜 辛味噌ラーメン + まかない丼
哲麺 (豚骨野菜ラーメン 醤油) からほぼ 2 ヶ月ぶりに訪れました。普段から 50 円で替玉食べ放題のため、毎回 3 玉は替玉しますが開店 4 周年記念で今月は無料で食べ放題だそうです。無料であれば
WS-C2960S-48TS-L (1)
今回は WS-C2960S-48TS-L の Cisco IOS 12.2 系と 15.0 系が混在している環境を、すべて現時点で最新の 15.2 系にアップデートする際のメモです。他の機種でも参考に
伊江島 (11)
伊江島 (No. 4 – 湧出 〜 島の駅) の続きです。島の駅から戻って伊江港ターミナルにつくと、もう車を搬入するにはちょうど良い時間でした。乗船まではまだ少し時間がありそうでしたので、
八重山そば (大) + 八重山飯
沖縄本島 (No. 6 – 打ち上げ) の続きです。05:00 頃までは起きていた気がしますが、普通通り目が覚めてお昼前にはお泊り宅を後にしました。この後半分はいつものメンバーとは離れても
radserv ope 09
radserv ope (SATA 1 -> 2TB) では 3.5inch ハードディスクで納品された機器の、ハードディスクのみの交換を行いました。今回は 2.5inch ハードディスクで納品
インド風カレー (インドカレー)
最近松戸に引っ越した友達が、松戸駅周辺のディープな感じのお店を投稿していました。そのうちの 1 つが カレー専門店 印度 です。松戸駅は、月 1 回程不定期に船橋を訪れる際に通過するだけで降りる機会は
辛つけ麺 (中) + 半熟玉子
三田製麺所 (つけ麺) で開店間もない御茶ノ水店を訪れて 1 週間も空けずに再び訪れました。辛つけ麺が気になっていたからです。つけ麺さとう (辛つけ麺)つけ麺屋やすべえ (辛味つけ麺)近場にすでにある
遠隔地バックアップ開始のお知らせ
2012/08/01 より Drive Network では従来の東京データセンター内でのバックアップに加え、富山データセンターにさらにバックアップする運用を開始しました。Drive Network
ゴーヤーチャンプルー定食
すっかり全メニュー制覇の勢いで ニライカナイ に通っていますが、まだそばと同じくらい沖縄ご飯の本命とも言える "ゴーヤーチャンプルー" を試していません。夜の居酒屋でおつまみとして
Valid HTML5 Valid CSS3 Another HTML Lint