Note that there are some explanatory texts on larger screens.

plurals
  1. POiTextSharp preserve html formatting on pdf
    primarykey
    data
    text
    <p>I am using some basic styles in ckeditor bold, italic, etc. to allow my users to style their text for report writing.</p> <p>When this string is passed to iTextSharp I am removing the html otherwise the html is printed on the pdf. I am removing this with</p> <pre><code>Regex.Replace(item.DevelopmentPractice.ToString(), @"&lt;[^&gt;]*&gt;|&amp;nbsp;", String.Empty) </code></pre> <p>Is there a way to format the text on the pdf to preserve the bold but not display</p> <pre><code>&lt;strong&gt;&lt;/strong&gt; </code></pre> <p><strong>UPDATE</strong></p> <p>I have provided full code below as requested.</p> <pre><code>public FileStreamResult pdf(int id) { // Set up the document and the Memory Stream to write it to and create the PDF writer instance MemoryStream workStream = new MemoryStream(); Document document = new Document(PageSize.A4, 30, 30, 30, 30); PdfWriter.GetInstance(document, workStream).CloseStream = false; // Open the pdf Document document.Open(); // Set up fonts used in the document Font font_body = FontFactory.GetFont(FontFactory.HELVETICA, 10); Font font_body_bold = FontFactory.GetFont(FontFactory.HELVETICA, 10, Font.BOLD); Chunk cAreasDevelopmentHeading = new Chunk("Areas identified for development of practice", font_body_bold); Chunk cAreasDevelopmentComment = new Chunk(item.DevelopmentPractice != null ? Regex.Replace(item.DevelopmentPractice.ToString(), @"&lt;[^&gt;]*&gt;|&amp;nbsp;", String.Empty) : "", font_body); Paragraph paraAreasDevelopmentHeading = new Paragraph(); paraAreasDevelopmentHeading.SpacingBefore = 5f; paraAreasDevelopmentHeading.SpacingAfter = 5f; paraAreasDevelopmentHeading.Add(cAreasDevelopmentHeading); document.Add(paraAreasDevelopmentHeading); Paragraph paraAreasDevelopmentComment = new Paragraph(); paraAreasDevelopmentComment.SpacingBefore = 5f; paraAreasDevelopmentComment.SpacingAfter = 15f; paraAreasDevelopmentComment.Add(cAreasDevelopmentComment); document.Add(paraAreasDevelopmentComment); document.Close(); byte[] byteInfo = workStream.ToArray(); workStream.Write(byteInfo, 0, byteInfo.Length); workStream.Position = 0; // Setup to Download HttpContext.Response.AddHeader("content-disposition", "attachment; filename=supportform.pdf"); return File(workStream, "application/pdf"); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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