PDFに文字を追加する
PDF::API2
pdfに文字を追加するにはPDF::APL2を使用すると簡単に作成できます。
インストール
sudo cpanm PDF::API2
実装してみる
pdfを読んで文字列を追加しpdfを作成する。
#!/usr/local/bin/perl use strict; use warnings; use PDF::API2; use utf8; my $pdf = PDF::API2->open('sample.pdf'); my $page = $pdf->openpage('1'); my $font = $pdf->cjkfont('KozGo'); my $text = $page->text(); $text->translate(50,400); $text->font($font,15); $text->fillcolor('#FF0000'); $text->text('追加のテキスト'); $text->cr(-15); $text->text('2行目のテキスト'); #$pdf->saveas('out.pdf'); print "Content-type: application/pdf; charset=utf-8\n\n"; print $pdf->stringify(); exit;
- 無精・短気・傲慢