I use iTextSharp to convert HTML to PDF and does not seem to work with absolutely positioned elements. For example, I have this HTML file:
<html>
<body>
<p style="position: absolute; left: 10px; top: 100px; width: 50px;">Hello World</p>
</body>
</html>
The text is not set correctly in the resulting PDF file. Do you know if it is possible to have absolutely positioned elements when converting HTML to PDF? Any free solution (iTextSharp or another) that allows this would be greatly appreciated.
Here is the code I use to convert with iTextSharp:
class Program
{
static void Main(string[] args)
{
Document document = new Document(PageSize.A4);
using (Stream output = new FileStream("out.pdf", FileMode.Create, FileAccess.Write, FileShare.None))
using (Stream htmlStream = new FileStream("input.htm", FileMode.Open, FileAccess.Read, FileShare.Read))
using (XmlTextReader reader = new XmlTextReader(htmlStream))
{
PdfWriter.GetInstance(document, output);
HtmlParser.Parse(document, reader);
}
Process.Start(@"C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe", "out.pdf");
}
}
EDIT:
, iTextSharp HTML PDF HTML-. Java- Flying Saucer, HTML-. IKVM, . , - . 31 HTML PDF . "" .