Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: PDF Creation

by tradez (Pilgrim)
on May 21, 2002 at 21:21 UTC ( #168286=note: print w/replies, xml ) Need Help??

in reply to PDF Creation

Not sure if this is exactly what you are looking for, but when I last had a project where PDF creation was the issue, I stepped away from using the Modules and the ::API2 approach and just did the nitty gritty PDF scripting. You'll find it is not that tough, and looks alot like an OO'ified Postscript. Snippet Follows:
6 0 obj << /Length 4634 >> stream BT /F1 10 Tf 11.5 TL 72 556 Td (This is pdf, done the cool way, acrobat is for \ weanies!!! ) Tj T* (This is by far the best way to know what you are going to get. + rules!) Tj ET 178 520 m 407 520 l .8 w S #Stroking the line to underline above ur +l
The hardest part would be to establish an XREF table schema, and a way of generating this. Along with Defining the length tags around each object that are required for viewers such as Acrobat to read them. Monk Russ showed me a way like this:
print scalar <>; while (!eof(ARGV)) { $pos = tell(ARGV); $line = scalar <>; my ($Obj) = $line =~ /^(\d+) \d+ obj/; $xref[$Obj - 1] = $pos if defined $Obj; $Str{$#xref + 1}->[0] = tell(ARGV) if $line =~ /^stream/; $Str{$#xref + 1}->[1] = $pos if $line =~ /^endstream/; print $line; } $pos = tell; print "xref\n0 ", scalar @xref + 1, "\n"; printf "%010d 65535 f \n", 0; foreach $entry (@xref) { printf "%010d 00000 n \n", $entry; } print "trailer\n<< /Size ", scalar @xref + 1, " /Root 1 0 R /Info 8 0 +R >>\n"; print "startxref\n$pos\n%%EOF\n"; for my $Key (sort {$a <=> $b} keys %Str){ warn "Stream in $Key ", "begins: $Str{$Key}->[0] ", "ends: $Str{$Key}->[1] ", "length: @{[$Str{$Key}->[1] - $Str{$Key}->[0]]}\n"; }
as a script to send a .pdf you create into the ARGV and have it output a file with a correct XREF table at it's conclusion, and length's of streams to STDOUT for easy viewing and updating. Have Fun

"Never underestimate the predicability of stupidity"
- Bullet Tooth Tony, Snatch (2001)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://168286]
and nobody stirs...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2017-12-12 20:54 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (336 votes). Check out past polls.