From: Jakob Haufe Date: Sun, 16 Jul 2017 11:29:05 +0000 (+0000) Subject: Correctly implement placement of pages with offsets X-Git-Tag: v0.4^0 X-Git-Url: https://git.sur5r.net/?p=pdfstitch;a=commitdiff_plain;h=3adb6b5996b5e14bbaa9261ab0f030f91b89429a Correctly implement placement of pages with offsets The coordinate origin of the imported page does not change when applying a bounding box. Formula adjusted accordingly. Also include previously forgotten per-page offset in this calculation. Also change internal row/column counter to zero-based. --- diff --git a/pdfstitch b/pdfstitch index e1c60dc..4c151e1 100755 --- a/pdfstitch +++ b/pdfstitch @@ -175,11 +175,11 @@ else my $stitchedpdf = PDF::API2->new(); my $page = $stitchedpdf->page(); - $page->mediabox($width + 100, $height + 100); + $page->mediabox($width, $height); my $content = $page->gfx(); - my $column = 1; - my $row = 1; + my $column = 0; + my $row = 0; foreach my $pagenr (@{$meta->{pageorder}}) { @@ -194,15 +194,15 @@ else $xo->bbox($llx, $lly, $urx, $ury); - my $xpos = ($column - 1) * $meta->{width}; - my $ypos = $height - ($row * $meta->{height}); + my $xpos = ($column) * $meta->{width} - ($meta->{x} + $meta->{pageoffsets}->{$pagenr}->{x}); + my $ypos = $height - (($row+1) * $meta->{height}) - ($meta->{y} + $meta->{pageoffsets}->{$pagenr}->{y}); $content->formimage($xo, $xpos, $ypos); } $column++; - if($column > $meta->{columns}) + if($column == $meta->{columns}) { $row++; - $column=1; + $column=0; } }