These insomnias are killing me. Another nightmare and this time the clock says 4:00 AM!!! Why can't I sleep???
Maybe a little programming will put me back to bed. I'm working on converting array of text to PDF using
PDF::API2 module. There were many other Perl modules to create PDF. This one just happens to be the most "robust". Documentation cited that it is compatible with Perl 5.8, but I am using Perl 5.6 and it works fine.
Perl Graphics Programming actually goes into little detail about PDF and annotation objects.
I'd like to implement this "idea" at work: A summary report that allow drill through (using links) to more detailed data on separate page of the PDF or to another URL page.
Creating PDF was simple enough. The sweetness comes from creating hyperlinks (within the PDF or to a URL) within the PDF.
Creating PDF (2 Pages)...#see use of special variable for naming files below
my $pdf = PDF::API2->new();
#or
(my $pdf = PDF::API2->new(-file => "Links.pdf");
my $pagefrom = $pdf->page();
my $pageto = $pdf->page();
You create an annotation object:my $annotation = $pagefrom->annotation();
You then create a rectangle around text to link to another page in the PDF$annotation->link($pageto,-rect => [$x + ($font->width($text) * $fsize), $y + $fsize, $x, $y, ],-border => [0,0,0],-fith => 800);
or to a URL$annotation->url($url,-rect => [$x + ($font->width($text) * $fsize),$y + $fsize,$x,$y,],-border => [0,0,0],-fith => 800);
#$0 special variable that holds the name of the file containing the Perl script being executed.
$pdf->saveas("$0.pdf");
$pdf->end();
Being a newbie to PERL, I think it's just cool that not only can you create a PDF, you can create hyperlinks and bookmarks also in the PDF.
---Other special variables that I ran across---$_ The default input and pattern-searching space.
$. The current input line number of the last filehandle that was read. Reset only
when the filehandle is closed explicitly.
$/ The input record separator, newline by default. May be multi-character.
$, The output field separator for the print operator.
$" The separator which joins elements of arrays interpolated in strings.
$\ The output record separator for the print operator.
$# The output format for printed numbers. Deprecated.
$* Set to 1 to do multilinematching within strings. Deprecated, see the m and s
modifiers in section 'Search and replace functions'.
$? The status returned by the last '. . .' command, pipe close or system
operator.
$] The Perl version number, e.g. 5.004.
$[ The index of the first element in an array, and of the first character in a
substring. Default is 0. Deprecated.
$; The subscript separator for multi-dimensional array emulation. Default is
"\034".
$! If used in a numeric context, yields the current value of errno. If used in a
string context, yields the corresponding error string.
$@ The Perl error message from the last eval or do EXPR command.
$: The set of characters after which a string may be broken to fill continuation
fields (starting with 'ˆ') in a format.
$0 The name of the file containing the Perl script being executed. May be
assigned to.
$$ The process ID of the Perl interpreter running this script. Altered (in the
child process) by fork.
$< The real user ID of this process.
$> The effective user ID of this process.
$( The real group ID of this process.
$) The effective group ID and groups of this process.
$^A The accumulator for formline and write operations.
$^D The debug flags as passed to Perl using '-D'.
$^E Extended error message on some platforms.
$^F The highest system file descriptor, ordinarily 2.
$^H Set of syntax checks enabled by 'use strict'.