I'm creating a PDF with a large table on it. In this table, there's a cell that can be filled in with HTML. If it is, the HTML must be interpreted as HTML and not be shown as regular text. However, when I do so, the layout/style gets scrambled and some pictures don't get shown. (In the example I give, the bullet dashes are replaced by 9's.)
I program in C# and am using iText7 to create the PDF.
In my project, I have the following HTML Code that I want to show. The reason the HTML code looks like this is because it's RTF converted to HTML:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="generator" content="SautinSoft.RtfToHtml.dll">
<title>Untitled document</title>
<style type="text/css">
.st1{font-family:Arial;font-size:12pt;color:#000000;}
.list-marker1 li:before {
content: "\F02D\9";
width: 30px;
font-family: Symbol;
font-size: 11pt;
}
.st2{font-family:Calibri;font-size:11pt;color:#000000;}
</style>
</head>
<body>
<div>
<p style="margin:0pt 0pt 0pt 0pt;"><span class="st1"> </span></p>
<ul style="list-style-type:none; list-style-image:none; list-style- position:outside; margin-left:0px; padding-left:0px; text-indent:0px; margin-top:0px; margin-bottom:0px;" class="list-marker1">
<li value="1" style="margin-left:36pt;text-indent:-18pt;"><span class="st2">Dishwasher soap container consumption is adjusted</span></li></ul>
<ul style="list-style-type:none; list-style-image:none; list-style-position:outside; margin-left:0px; padding-left:0px; text-indent:0px; margin-top:0px; margin-bottom:0px;" class="list-marker1">
<li value="2" style="margin-left:36pt;text-indent:-18pt;"><span class="st2">Power UP ballast water treatmant unit, adjusted what necessary. GPS signal error still pending</span></li></ul>
<ul style="list-style-type:none; list-style-image:none; list-style-position:outside; margin-left:0px; padding-left:0px; text-indent:0px; margin-top:0px; margin-bottom:0px;" class="list-marker1">
<li value="3" style="margin-left:36pt;text-indent:-18pt;"><span class="st2">Installed new insect killer in galley</span></li></ul>
<ul style="list-style-type:none; list-style-image:none; list-style-position:outside; margin-left:0px; padding-left:0px; text-indent:0px; margin-top:0px; margin-bottom:0px;" class="list-marker1">
<li value="4" style="margin-left:36pt;text-indent:-18pt;"><span class="st2">Adjust securing and highest ladder position after its tilted to low trunnion position</span></li></ul>
<ul style="list-style-type:none; list-style-image:none; list-style-position:outside; margin-left:0px; padding-left:0px; text-indent:0px; margin-top:0px; margin-bottom:0px;" class="list-marker1">
<li value="5" style="margin-left:36pt;text-indent:-18pt;"><span class="st2">SW spooling device test is done and no isses </span></li></ul>
<ul style="list-style-type:none; list-style-image:none; list-style-position:outside; margin-left:0px; padding-left:0px; text-indent:0px; margin-top:0px; margin-bottom:0px;" class="list-marker1">
<li value="6" style="margin-left:36pt;text-indent:-18pt;"><span class="st2">Sewage unit dosage pump; make permanent installation + drawing update</span></li></ul>
<ul style="list-style-type:none; list-style-image:none; list-style-position:outside; margin-left:0px; padding-left:0px; text-indent:0px; margin-top:0px; margin-bottom:0px;" class="list-marker1">
<li value="7" style="margin-left:36pt;text-indent:-18pt;"><span class="st2">Intervention on DN203: installed tracker box on ICT request</span></li></ul>
<ul style="list-style-type:none; list-style-image:none; list-style-position:outside; margin-left:0px; padding-left:0px; text-indent:0px; margin-top:0px; margin-bottom:0px;" class="list-marker1">
<li value="8" style="margin-left:36pt;text-indent:-18pt;"><span class="st2">Installed tracker box on ICT request </span></li></ul>
<ul style="list-style-type:none; list-style-image:none; list-style-position:outside; margin-left:0px; padding-left:0px; text-indent:0px; margin-top:0px; margin-bottom:0px;" class="list-marker1">
<li value="9" style="margin-left:36pt;text-indent:-18pt;"><span class="st2">Regular greasing emotors according ship specific grease list</span></li></ul>
<ul style="list-style-type:none; list-style-image:none; list-style-position:outside; margin-left:0px; padding-left:0px; text-indent:0px; margin-top:0px; margin-bottom:0px;" class="list-marker1">
<li value="10" style="margin-left:36pt;text-indent:-18pt;"><span class="st2">Regular maintenance of portable tools</span></li></ul>
<ul style="list-style-type:none; list-style-image:none; list-style-position:outside; margin-left:0px; padding-left:0px; text-indent:0px; margin-top:0px; margin-bottom:0px;" class="list-marker1">
<li value="11" style="margin-left:36pt;text-indent:-18pt;"><span class="st2">Intervention on DN203 due to problem with SB M/E</span></li></ul>
<p style="margin:0pt 0pt 0pt 0pt;"><span class="st2"> </span></p>
<p style="margin:0pt 0pt 0pt 0pt;"><span class="st1"> </span></p>
</div>
</body>
</html>
When I save this file as a HTML file and open it in a browser, you get the following result (which is correct): Correct result (website)
However, when I add it to the PDF cell, I get the following result: Bad result (PDF)
As you can see, the dashes used for bulleting have turned into 9's.
The code I use to add the HTML code to the PDF File is the following:
private void AddCellToTable(table table, string HTMLContent) {
Cell newCell = new Cell();
foreach (var element in HtmlConverter.ConvertToElements(HTMLContent))
{
var test = (IBlockElement)element;
newCell.Add(test);
}
table.AddCell(newCell);
}
This code is similar to the code suggested by https://itextpdf.com/en/resources/books/itext-7-converting-html-pdf-pdfhtml/chapter-1-hello-html-pdf (They use java instead of C#).
I would like to show bullets as dashes, instead of these 9's. Any help or suggestions would be very much appreciated.
Thank you in advance.
