Note that there are some explanatory texts on larger screens.

plurals
  1. POiTextSharp HTMLWorker ParseHTML Tablestyle and PDFStamper
    text
    copied!<p>Hi I have succesfully used a HTMLWorker to convert a gridview using asp.NET / C#.</p> <p>(1) I have applied some limited style to the resulting table but cannot see how to apply tablestyle for instance grid lines or apply other formatting style such as a large column width for example for a particular column. (2) I would actually like to put this text onto a pre-existing template which contains a logo etc. I've used PDF Stamper before for this but cannot see how I can use both PDFStamper and HTMLWorker at once. HTMLWorker needs a Document which implements iDocListener ... but that doesnt seem compatible with usign a PDFStamper. I guess what I am looking for is a way to create a PDFStamper, write title etc, then add the parsed HTML from the grid. The other problem is that the parsed content doesnt interact with the other stuff on the page. For instance below I add a title chunk to the page. Rather than starting below it, the parsed HTML writes over the top. How do I place / interact the parsed HTML content with the rest of what is on the PDF document ? </p> <p>Thanks in advance Rob</p> <p>Here';s the code I have already </p> <pre><code> Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 30f, 0f); HTMLWorker htmlWorker = new HTMLWorker(pdfDoc); StyleSheet styles = new StyleSheet(); styles.LoadTagStyle("th", "size", "12px"); styles.LoadTagStyle("th", "face", "helvetica"); styles.LoadTagStyle("span", "size", "10px"); styles.LoadTagStyle("span", "face", "helvetica"); styles.LoadTagStyle("td", "size", "10px"); styles.LoadTagStyle("td", "face", "helvetica"); htmlWorker.SetStyleSheet(styles); PdfWriter.GetInstance(pdfDoc, HttpContext.Current.Response.OutputStream); pdfDoc.Open(); //Title - but this gets obsured by data, doesnt move it down Font font = new Font(Font.FontFamily.HELVETICA, 14, Font.BOLD); Chunk chunk = new Chunk(title, font); pdfDoc.Add(chunk); //Body htmlWorker.Parse(sr); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload