Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Zero work is being done in the <code>HTMLWorker</code>, all work is being done in the separate but related project <a href="http://sourceforge.net/projects/itextsharp/files/xmlworker/" rel="nofollow"><code>XMLWorker</code></a> so please move to that. You can then pretty much then just plug this in instead of the <code>HTMLWorker</code>:</p> <pre><code>//Bind a reader to our text using (TextReader reader = new StringReader(html)) { //Parse the HTML and write it to the document XMLWorkerHelper.GetInstance().ParseXHtml(writer, document, reader); } </code></pre> <p>Side note, I'd really recommend not passing around a <code>MemoryStream</code> unless you really need to and instead just pass around the underlying byte array. When passing around the raw stream you have to worrying about the current position, checking if something closed it for you, etc. I'd recommend changing your method to something like this (also note the <code>using</code> pattern):</p> <pre><code>private byte[] createPDF(string html) { //Basic PDF setup using (var msOutput = new MemoryStream()) { using (var document = new Document(PageSize.A4, 30, 30, 30, 30)) { using (var writer = PdfWriter.GetInstance(document, msOutput)) { //Open our document for writing document.Open(); //Bind a reader to our text using (TextReader reader = new StringReader(html)) { //Parse the HTML and write it to the document XMLWorkerHelper.GetInstance().ParseXHtml(writer, document, reader); } //Close the main document document.Close(); } //Return our raw bytes return msOutput.ToArray(); } } } </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