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

与那国島ビーフカレー (6)
銀座わしたショップ 2015/02/19 (いちばん桜) の際に購入した 与那国島ビーフカレー | 崎元酒造所 をいよいよ試すことにしました。2014/12/02 に新発売した様です。2 月の時点で東
開拓味噌ラーメン "天神"
沖縄本島 (No. 14 – キングタコス 長田店) の続きです。さて、少し時間を空けてふたたび天神矢を訪れました。投稿は 沖縄出張 (No. 25 – 天神矢) 以来約 1
城山 (10)
伊江島 (No. 2 – 伊江島タッチュー Part 1) の続きです。階段も途切れて岩肌がむき出しの中をそのまま進むと、視界が開けました。中央に立って島の北側の眺めです。ふと右手を見ると
牛赤身ひき肉 (9)
自宅 de タコライス (S&B タコスシーズニング Part 1) の続きです。タコスミートS&B タコスシーズニング は 1 パックに 2 袋入りで、1 袋 (8g) をひき肉 1
Office Desk
今でも移転元の船橋にはほぼ 2 週間毎には訪れています。普段腰の重い私が 印鑑登録・印鑑証明 の手続きをしている最中、また訪れる機会がありました。住民票はすぐ移したものの、本籍地は船橋のまま未処理でし
コントロールパネル (更新後)
今回は Windows の話ですが、Firefox を 13.0.1 の最新版に更新した後、ふと気が付くと YouTube の動画が再生出来なくなる現象に出くわしました。INTERNET Watch
五目焼きそば (3)
とちぎや (肉野菜炒め定食) から日を空けずして、前回ロックオンした五目焼きそばを求めて訪れました。ピリ辛炒めに反応しそうでしたが、キクラゲに興味がないので初志貫徹出来そうです。豚の絵がキュートです。
VAIO Fit 13A (背面)
VAIO Fit 13A (到着) 後のカスタマイズで、Windows 8.1 Pro 付属のツール "ペイント" の動作に違和感を感じました。Alt + Print Screen
iPhone 6 + iPhone 6 Plus
ARROWS X F-10D を使い続けて 2 年。使い始めから電池の持ちが悪かったのですが、iPhone 6 Plus が発売開始となり、ついに機種変更に踏み切りました。Apple Store Gi
タコライス + KAGOME サルサ
自宅 de タコライス (S&B タコスシーズニング Part 2) の続きです。盛り付け盛り付け順は 沖縄本島 (No. 14 ? キングタコス 長田店) "タコライスチーズ野菜
Valid HTML5 Valid CSS3 Another HTML Lint