I have converted an HTML sting into a PDF document using iTextSharp in VB.Net; however, the style tags are not being applied to the PDF document. The HTML string is supplied by an outside source so I need to pull the styles elements out and apply them to the generated PDF. The nested classes in the CSS elements are fouling things up. What is the best way to handle the nested CSS classes?
2
votes
2 Answers
2
votes
0
votes
The EO.PDF product line was created for this exactly. Here's most of the VB.NET you would need:
Imports System.Drawing
'This is usually the only namespace needed if you only use HTML to PDF
Imports EO.Pdf
'This is the main namespace you will need in order to use ACM (Abstract Content Model)
Imports EO.Pdf.Acm
'The following two namespaces are only needed if you use low-level content API
Imports EO.Pdf.Drawing
Imports EO.Pdf.Contents
'Convert a Url to PDF file
HtmlToPdf.ConvertUrl("http://www.google.com", "c:\test.pdf")
HtmlMovies2 movies = new HtmlMovies2(); St yleSheet styles = new StyleSheet(); styles.loadTagStyle("ul", "indent", "10"); styles.loadStyle("country", "color", "#008080"); styles.loadStyle("director", "b", ""); movies.setStyles(styles);<br/> Is it possible to add an entire css stylesheet to the document? - rolivares