Hi Monks!
I am trying to creating PDF files using "HTML::HTMLDoc", that seems to be the easiest one to accomplish this using Perl. But with few issues. If you look at the code I am posting here I have a very simple HTML code that I am converting into PDF, but when I run the code the PDF is blank, the only thing that shows is the image, it displays in the new created PDF file, the rest of the code doesn't. Have anyone here worked with this before that could show me where the problem is? My other issue is that I would like to add into my PDF file a field that I can edit from the PDF, like an input type="text" in a form, is that possible? OK thanks for looking and here is the code I am testing with:
#!/usr/bin/perl -w
use strict;
use HTML::HTMLDoc;
my $htmldoc = new HTML::HTMLDoc();
$htmldoc->set_html_content(qq|
<html>
<body>
<br>PDF Test<br><br>
<table cellpadding="0" cellspacing="0" border="1">
<tr>
<td colspan="2" align="center"><img src="images/header.gif"></td>
</tr>
<tr>
<td>
<b>Phone Number: (123) 456-7897</b>
</td>
<td>Country Code: US</td>
</tr>
<tr>
<td colspan=2>
<b><div>Number: 00000000</div></b>
</td>
</tr>
<tr>
<td colspan="2"><b>First Name:</b> <input type="text" name="fi
+rst"></td>
</tr>
<tr>
<td colspan="2"><b>Last Name:</b> <input type="text" name="last"
+></td>
</tr>
</table>
</body>
</html>
|);
my $pdf = $htmldoc->generate_pdf();
$pdf->to_file('test.pdf');
Thank you!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.