HTMLDOC 1.8.27 Software Users Manual

[ Comments | Contents | Previous | Next ]


Calling HTMLDOC from Perl

Perl scripts offer the ability to generate more complex reports, pull data from databases, etc. The easiest way to interface Perl scripts with HTMLDOC is to write a report to a temporary file and then execute HTMLDOC to generate the PDF file.

Here is a simple Perl subroutine that can be used to write a PDF report to the HTTP client:

    sub topdf {
	# Get the filename argument...
	my $filename = shift;

	# Make stdout unbuffered...
	select(STDOUT); $| = 1;

	# Tell HTMLDOC not to run in CGI mode...
        $ENV{HTMLDOC_NOCGI} = 1;

	# Write the content type to the client...
	print "Content-Type: application/pdf\n\n";

	# Run HTMLDOC to provide the PDF file to the user...
	system "htmldoc -t pdf --quiet --webpage $filename";
    }

[ Comments | Contents | Previous | Next ]


User CommentsAdd Comment ]

No comments for this page.