view src/kaigo/fwgo/atena.pl @ 62:a2c9a535cdd3

add watcher.go
author pyon@macmini
date Wed, 14 Oct 2020 21:30:04 +0900
parents 05f3d51ad966
children
line wrap: on
line source

# あてなをつくる
#                   Last Change: 2020-07-15 水 15:55:32.
#
# C:\> perl atena.pl input.pdf output.pdf
#

use utf8;
use PDF::API2;

my $bg_file = 'bg.pdf';

my ($in_file, $out_file) = ($ARGV[0], $ARGV[1]);
if ($in_file eq '' || $out_file eq '') {
	print "bad arguments.\n";
	exit;
}

my $new_pdf = PDF::API2->new();

my $in_pdf = PDF::API2->open($in_file);
my $bg_pdf = PDF::API2->open($bg_file);
for my $p (1..$in_pdf->pages) {
	my $page = $new_pdf->page();
	$page->mediabox('A4');
	my $gfx = $page->gfx();

	# send to
	my $xo = $new_pdf->importPageIntoForm($in_pdf, $p);
	$gfx->formimage($xo, 15, 615, 0.9);

	# background
	$xo = $new_pdf->importPageIntoForm($bg_pdf, 1);
	$gfx->formimage($xo, 0, 0, 1.0);
}
$new_pdf->saveas($out_file);
$new_pdf->end;
$in_pdf->end;
$bg_pdf->end;