Okay. I think we've got it.
This MOD utilizes PerlStudio's PD
Fever script, located at
www.perlstudio.de/pdfintro.html .
You can download the script for 30-day evaluation. Registration is $10/$20 for continued use.
The modifications listed here are all made in the
html.pl file of DBMan 2.04.
1) Install PD
Fever as instructed; it is very easy to install.
2) Create a
sub export_to_pdf at the bottom of the
html.pl file, before the
1 at the bottom:
Code:
sub export_to_pdf {
my (@hits) = @_;
my ($numhits) = ($#hits+1) / ($#db_cols+1);
$linefeed=chr(10); # Assigns ASCII code for Line Feed
for (0 .. $numhits - 1) {
%rec = &array_to_hash($_, @hits);
$rec{'Description'} =~ tr/"/''/; # Replaces Quotes (") with two apostrophe (''), otherwise it'll crash your DB
$output .= "RECORD $rec{'ID'} -- $rec{'Title'}: $linefeed $rec{'Description'} $linefeed $linefeed $rec{'Phone'} $linefeed
-------------------------------------------------------------------------------------------------------------------------------------------- -------------- $linefeed";
}
$output =~ s/<([^>]|\n)*>/ /g; # strips all HTML codes
$output .= " "; # Adds a space at the end (PDFever bug)
print qq^
<form action="/path/to/pdfever.cgi" method="POST" enctype="application/x-www-form-urlencoded" target="output">
<input type="HIDDEN" name="measUnit" value="1">
</-- UNIT OF MEASURE - 1=inch, 2.54=cm, 25.4=mm -->
<input type="HIDDEN" name="paper" value="A4">
</-- PAPER SIZE - Letter,Legal,A4,B5,Index Card,Postcard -->
<input type="HIDDEN" name="pageOrient" value="portrait" checked>
</-- ORIENTATION - portrait or landscape -->
<input type="HIDDEN" name="usePageBorder" checked>
</-- PAGE BORDER - remove "checked" to disable page borders -->
<input type="HIDDEN" name="pageBorderWidth" value="0.5">
</-- BORDER WIDTH - Width of borders, if borders used -->
<input type="HIDDEN" name="marginTop" value="1">
<input type="HIDDEN" name="marginLeft" value="1">
<input type="HIDDEN" name="marginRight" value="1">
<input type="HIDDEN" name="marginBottom" value="1">
</-- MARGINS - Top,Left,Right,and Bottom margin widths in inches -->
<input type="HIDDEN" name="columnNum" value="1">
</-- NUMBER OF COLUMNS - value 1 up to 5 -->
<input type="HIDDEN" name="useColumnDivider">
</-- COLUMN DIVIDER - remove this line to disable vertical line between columns -->
<input type="HIDDEN" name="columnDef" value="byWidth" checked>
<input type="HIDDEN" name="columnWidth" value="4">
<input type="HIDDEN" name="columnDef" value="bySpacing">
<input type="HIDDEN" name="columnSpacing" value="1">
</-- DEFINE COLUMN - move "checked" to either bySpacing or byWidth -->
<input type="HIDDEN" name="fontFace" value="Arial">
</-- FONT FACE - Times, Arial, or Verdana -->
<input type="HIDDEN" name="fontStyle" value="">
</-- FONT STYLE - "" (normal), Bold, Italic, or BoldItalic -->
<input type="HIDDEN" name="fontSize" value="8">
</-- Font size in points -->
<input type="HIDDEN" name="textAlign" value="left">
</-- TEXT ALIGNMENT - left or justify -->
<input type="HIDDEN" name="lineDef" value="byHeight" checked>
<input type="HIDDEN" name="lineHeight" value="14">
<input type="HIDDEN" name="lineDef" value="byNumber">
<input type="HIDDEN" name="lineNumbers" value="66">
</-- LINE DEFINITION - move "checked" to either byHeight or byNumber -->
<input type="HIDDEN" name="customHeader" value="PDF Search Export">
</-- CUSTOM HEADER - The text used in the document header -->
</-- *NOTE* - For header and footer (below), these variables are identical to those listed above. -->
<input type="HIDDEN" name="headerFontFace" value="Verdana">
<input type="HIDDEN" name="headerFontStyle" value="BoldItalic">
<input type="HIDDEN" name="headerFontSize" value="10">
<input type="HIDDEN" name="headerTextAlign" value="center">
<input type="HIDDEN" name="customFooter" value="Page <page> / <time>">
</-- CUSTOM FOOTER - The text used in the document footer -->
<input type="HIDDEN" name="footerFontFace" value="Verdana">
<input type="HIDDEN" name="footerFontStyle" value="">
<input type="HIDDEN" name="footerFontSize" value="9">
<input type="HIDDEN" name="footerTextAlign" value="center">
<input type="HIDDEN" name="text" value="$output">
</-- TEXT - This is the main body text. -->
<input type="Submit" value="Export to PDF">
</form>
^;
}
In this code, I use four fields: ID, Title, Description, and Phone. You should customize this line to match your database.
NOTE: For a line break (essentially a <BR> ) use one $line feed. for a Paragraph (essentially a <P> ) use two $linefeed $linefeed.
NOTE: PDFever is a great script, but has a few bugs. One of them is that you have to put at least one blank space at the end of every field and every line, or the last word of that line will wordwrap:
Code:
|;
&export_to_pdf;
print qq|
If you want to put this in the bottom of each page, and usable only by authors, insert:
Code:
if($per_add) { &export_to_pdf };
after:
Code:
print qq!| <A HREF="$db_script_link_url&admin_display=1">Admin</A>| ! if ($per_admin);
print qq!| <A HREF="$db_script_link_url&delete_search=1">Delete</A> ! if ($per_del);
print qq!| <A HREF="$db_script_link_url&modify_search=1">Modify</A> ! if ($per_mod);
and before:
Code:
print qq!|!;
print qq!</font></p>!;
There may be multiple instances of this code in your database, or it may be in
sub html_footer, depending on how you've modified your script. (I have it in many places, and have totally forgotten how it was originally!)
Or, if you want everyone to see this button, insert this code instead:
4) Lastly, go through the settings of the
sub export_to_pdf.
ALL THESE FIELDS ARE REQUIRED, AND ARE VERY CASE- AND CONTENT-SENSITIVE! If you remove any, do so ONLY if the comment line says you'd need to remove it, or you will get weird, unexpected errors. The comments are always below the line they are referencing.
5) Test the script. You may have to do a bit of work on the
$output = "..."; line to make it look the way you want to.
[This message has been edited by leisurelee (edited April 18, 2000).]
[This message has been edited by leisurelee (edited April 18, 2000).]