#!/usr/bin/perl use strict; use warnings; use CGI; my $cgi=new CGI; print $cgi->header( -type => 'application/pdf' ); use HTML::HTMLDoc; my $htmldoc = new HTML::HTMLDoc(); $htmldoc->set_html_content('A PDF file'); my $pdf = $htmldoc->generate_pdf(); print $pdf->to_string(); $pdf->to_file('newpdfdoc.pdf');