in reply to Dynamic text (amount in decimal) not aligned on PDF
poj#!perl use strict; use PDF::API2; my $pdf = new PDF::API2(-file => "align.pdf"); $pdf->mediabox(842, 595); #A4 Landscape my $page = $pdf->page(); my $font = $pdf->corefont('helvetica'); my $gfx = $page->gfx(); $gfx->move(600,595);$gfx->vline; $gfx->move(200,595);$gfx->vline; $gfx->stroke; my $content = $page->text(); $content->font($font,24); my $y = 500; for my $text (1,1.2,1.23,12.34,123.45,12345.67,123456.78){ my $len = length $text; my $width = $content->advancewidth($text); $content->translate(200,$y); $content->text("$text ($len)($width) left align"); $y -= 30;; $content->translate(600,$y); $content->text_right("right align $text"); $y -= 30;; } $pdf->saveas();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Dynamic text (amount in decimal) not aligned on PDF
by osexplorer (Novice) on Nov 17, 2014 at 20:05 UTC | |
by poj (Abbot) on Nov 17, 2014 at 22:08 UTC | |
by osexplorer (Novice) on Nov 18, 2014 at 18:33 UTC | |
|
Re^2: Dynamic text (amount in decimal) not aligned on PDF
by osexplorer (Novice) on Feb 19, 2015 at 21:23 UTC |