Last active
February 11, 2018 20:31
-
-
Save trytone/0ed0d6816f676e08f026c8e0b8632ab1 to your computer and use it in GitHub Desktop.
Perl PDF::API scale
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use PDF::API2; | |
| my $filePath = 'example.pdf'; | |
| my $scale = 0.82; # Scale 82% | |
| my ($x,$y) = (-13,113); # Coordinates | |
| my $old_pdf = PDF::API2->open($filePath); # Open existing PDF file | |
| my $pdf = PDF::API2->new(); # Open empty new PDF Document | |
| my $page = $pdf->page(); | |
| my $gfx = $page->gfx(); | |
| my $xo = $pdf->importPageIntoForm($old_pdf, 1); # Return page view from content as Form | |
| $gfx->formimage($xo, $x, $y, $scale); # Add our Form as Image at new blank page | |
| $old_pdf->end; # Close handle to our PDF file ! IMPORTANT | |
| $pdf->saveas($filePath); | |
| $pdf->end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment