[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] Making a PDF with Perl...



not 100% sure this meets your precision requirements...

-tim

#for Dan, 2012

use PDF::API2 qw();
#perhaps the best documentation for PDF::API2 is
#http://pdfapi2.sourceforge.net/pdfapi2_for_fun_and_profit_APW2005.pdf

$pdf=PDF::API2->new;

$pdf->mediabox('A4');
$page=$pdf->page;
$gfx=$page->gfx;
$gfx->linewidth(1);
$gfx->strokecolor('black');

my $x = 100;
my $tick = 10;
my $spacing = 20;

$gfx->move($x,50);
$gfx->line($x,800);
$gfx->stroke;

for(my $y=50; $y<=800; $y+=$spacing){
	$gfx->move($x,$y);
	$gfx->line($x+$tick,$y);
	$gfx->stroke;
}

$pdf->saveas('DansRuler.pdf');

On Wed, Apr 11, 2012 at 5:15 PM, Dan Linder <dan@linder.org> wrote:
> I'd like to see if anyone has ever worked with the PDF modules for Perl?
>  Specifically, I'm looking to print a ruler (something like here:
> http://www.vendian.org/mncharity/dir3/paper_rulers/ ;), but I need to adjust
> the spacing between ticks and put in my own numbers for the new marks.
>
> Most (all?) of the examples I've found are concentrating on placing blocks
> of text and a couple images on the page.  What I need is a way to precisely
> place tic marks and text next to them every so often.
>
> Any hints or code snippets?   I had hoped someone would have made a generic
> ruler printing page, but haven't found that yet.
>
> Dan
>
> My use? I'm printing a custom timing tape for my 350 V8 - as luck would have
> it, each degree is 2mm on this flywheel.  My first attempt was to print a
> blank cm/mm ruler, then hand print the degree numbers.  I'd like something a
> bit more professional looking - possibly have it printed onto a
> brass/aluminum tape that could be affixed to the engine.
>
> --
> ***************** ************* *********** ******* ***** *** **
> "Quis custodiet ipsos custodes?"
>     (Who can watch the watchmen?)
>     -- from the Satires of Juvenal
> "I do not fear computers, I fear the lack of them."
>     -- Isaac Asimov (Author)
> ** *** ***** ******* *********** ************* *****************
>
> _______________________________________________
> Omaha-pm mailing list
> Omaha-pm@pm.org
> http://mail.pm.org/mailman/listinfo/omaha-pm