0

添付された HTML の変換に UTF-8 エンコーディングを使用するように、XMLWorkerHelper.ParseToElementList メソッドを変更しました。

<p>​&lt;span style="font-size: 10pt; font-family: &quot;tahoma&quot;, &quot;sans-serif&quot;">Med pripravo vozil za ladjo M/V SEA PATRIS, dne 19.02.2017 je prišlo do delovne nezgode in poškodbe dveh vozil Seat Ateca. Voznik ( RETRANS d.o.o.) je z vozilom Seat Ateca VIN: VSSZZZ5FZH6536022 &#160;zapeljal vzvratno in trčil v stoječe vozilo Seat Ateca VIN: VSSZZZ5FZH6545134.</span> </p>
<div><span style="font-size: 10pt; font-family: &quot;tahoma&quot;, &quot;sans-serif&quot;">&#160;</span></div>
<div><span style="font-size: 10pt; font-family: &quot;tahoma&quot;, &quot;sans-serif&quot;">Priloge: fotografije, seznam poškodb&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></div>
<div><span style="font-size: 10pt; font-family: &quot;tahoma&quot;, &quot;sans-serif&quot;">&#160;</span></div>
<table class="MsoNormalTable" border="1" cellspacing="0" cellpadding="0" style="border-top: black 1pt solid; border-right: black 1pt solid; background: white; border-bottom: black 1pt solid; border-left: black 1pt solid"><tbody><tr><td style="border-top: gray 1pt solid; border-right: gray 1pt solid; background: #ededed; border-bottom: gray 1pt solid; padding-bottom: 0.75pt; padding-top: 0.75pt; padding-left: 1.5pt; border-left: gray 1pt solid; padding-right: 1.5pt"><div><b><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: black">#</span></b></div></td>
<td style="border-top: gray 1pt solid; border-right: gray 1pt solid; background: #ededed; border-bottom: gray 1pt solid; padding-bottom: 0.75pt; padding-top: 0.75pt; padding-left: 1.5pt; border-left: gray 1pt solid; padding-right: 1.5pt"><div><b><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: black">PR</span></b></div></td>
<td style="border-top: gray 1pt solid; border-right: gray 1pt solid; background: #ededed; border-bottom: gray 1pt solid; padding-bottom: 0.75pt; padding-top: 0.75pt; padding-left: 1.5pt; border-left: gray 1pt solid; padding-right: 1.5pt"><div><b><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: black">DATUM PREGLEDA</span></b></div></td>
<td style="border-top: gray 1pt solid; border-right: gray 1pt solid; background: #ededed; border-bottom: gray 1pt solid; padding-bottom: 0.75pt; padding-top: 0.75pt; padding-left: 1.5pt; border-left: gray 1pt solid; padding-right: 1.5pt"><div><b><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: black">VIN</span></b></div></td>
<td style="border-top: gray 1pt solid; border-right: gray 1pt solid; background: #ededed; border-bottom: gray 1pt solid; padding-bottom: 0.75pt; padding-top: 0.75pt; padding-left: 1.5pt; border-left: gray 1pt solid; padding-right: 1.5pt"><div><b><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: black">DEL</span></b></div></td>
<td style="border-top: gray 1pt solid; border-right: gray 1pt solid; background: #ededed; border-bottom: gray 1pt solid; padding-bottom: 0.75pt; padding-top: 0.75pt; padding-left: 1.5pt; border-left: gray 1pt solid; padding-right: 1.5pt"><div><b><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: black">OPIS DELA</span></b></div></td>
<td style="border-top: gray 1pt solid; border-right: gray 1pt solid; background: #ededed; border-bottom: gray 1pt solid; padding-bottom: 0.75pt; padding-top: 0.75pt; padding-left: 1.5pt; border-left: gray 1pt solid; padding-right: 1.5pt"><div><b><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: black">POŠK</span></b></div></td>
<td style="border-top: gray 1pt solid; border-right: gray 1pt solid; background: #ededed; border-bottom: gray 1pt solid; padding-bottom: 0.75pt; padding-top: 0.75pt; padding-left: 1.5pt; border-left: gray 1pt solid; padding-right: 1.5pt"><div><b><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: black">OPIS POŠKODBE</span></b></div></td>
<td style="border-top: gray 1pt solid; border-right: gray 1pt solid; background: #ededed; border-bottom: gray 1pt solid; padding-bottom: 0.75pt; padding-top: 0.75pt; padding-left: 1.5pt; border-left: gray 1pt solid; padding-right: 1.5pt"><div><b><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: black">DIMENZIJE / OPOMBE</span></b></div></td></tr>
<tr><td style="border-top: gray 1pt solid; border-right: gray 1pt solid; background: #ededed; border-bottom: gray 1pt solid; padding-bottom: 0.75pt; padding-top: 0.75pt; padding-left: 1.5pt; border-left: gray 1pt solid; padding-right: 1.5pt"><div><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: black">1</span></div></td>
<td style="border-top: #cccccc 1pt solid; border-right: #cccccc 1pt solid; border-bottom: #cccccc 1pt solid; padding-bottom: 0cm; padding-top: 0cm; padding-left: 1.5pt; border-left: #cccccc 1pt solid; padding-right: 1.5pt; background-color: transparent"><div><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: #303030">ZP</span></div></td>
<td style="border-top: #cccccc 1pt solid; border-right: #cccccc 1pt solid; border-bottom: #cccccc 1pt solid; padding-bottom: 0cm; padding-top: 0cm; padding-left: 1.5pt; border-left: #cccccc 1pt solid; padding-right: 1.5pt; background-color: transparent"><div><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: #303030">2017-02-19&#160;11:56:52.0</span></div></td>
<td style="border-top: #cccccc 1pt solid; border-right: #cccccc 1pt solid; border-bottom: #cccccc 1pt solid; padding-bottom: 0cm; padding-top: 0cm; padding-left: 1.5pt; border-left: #cccccc 1pt solid; padding-right: 1.5pt; background-color: transparent"><div><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: #303030">VSSZZZ5FZH6536022</span></div></td>
<td style="border-top: #cccccc 1pt solid; border-right: #cccccc 1pt solid; border-bottom: #cccccc 1pt solid; padding-bottom: 0cm; padding-top: 0cm; padding-left: 1.5pt; border-left: #cccccc 1pt solid; padding-right: 1.5pt; background-color: transparent"><div><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: #303030">43</span></div></td>
<td style="border-top: #cccccc 1pt solid; border-right: #cccccc 1pt solid; border-bottom: #cccccc 1pt solid; padding-bottom: 0cm; padding-top: 0cm; padding-left: 1.5pt; border-left: #cccccc 1pt solid; padding-right: 1.5pt; background-color: transparent"><div><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: #303030">zadnji&#160;odbijač</span></div></td>
<td style="border-top: #cccccc 1pt solid; border-right: #cccccc 1pt solid; border-bottom: #cccccc 1pt solid; padding-bottom: 0cm; padding-top: 0cm; padding-left: 1.5pt; border-left: #cccccc 1pt solid; padding-right: 1.5pt; background-color: transparent"><div><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: #303030">12</span></div></td>
<td style="border-top: #cccccc 1pt solid; border-right: #cccccc 1pt solid; border-bottom: #cccccc 1pt solid; padding-bottom: 0cm; padding-top: 0cm; padding-left: 1.5pt; border-left: #cccccc 1pt solid; padding-right: 1.5pt; background-color: transparent"><div><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: #303030">PODRSANO</span></div></td>
<td style="border-top: #cccccc 1pt solid; border-right: #cccccc 1pt solid; border-bottom: #cccccc 1pt solid; padding-bottom: 0cm; padding-top: 0cm; padding-left: 1.5pt; border-left: #cccccc 1pt solid; padding-right: 1.5pt; background-color: transparent"><div><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: #303030">100X10&#160;20X2&#160;10X2&#160;50X2</span></div></td></tr>
<tr><td style="border-top: gray 1pt solid; border-right: gray 1pt solid; background: #ededed; border-bottom: gray 1pt solid; padding-bottom: 0.75pt; padding-top: 0.75pt; padding-left: 1.5pt; border-left: gray 1pt solid; padding-right: 1.5pt"><div><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: black">2</span></div></td>
<td style="border-top: #cccccc 1pt solid; border-right: #cccccc 1pt solid; border-bottom: #cccccc 1pt solid; padding-bottom: 0cm; padding-top: 0cm; padding-left: 1.5pt; border-left: #cccccc 1pt solid; padding-right: 1.5pt; background-color: transparent"><div><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: #303030">ZP</span></div></td>
<td style="border-top: #cccccc 1pt solid; border-right: #cccccc 1pt solid; border-bottom: #cccccc 1pt solid; padding-bottom: 0cm; padding-top: 0cm; padding-left: 1.5pt; border-left: #cccccc 1pt solid; padding-right: 1.5pt; background-color: transparent"><div><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: #303030">2017-02-19&#160;11:57:38.0</span></div></td>
<td style="border-top: #cccccc 1pt solid; border-right: #cccccc 1pt solid; border-bottom: #cccccc 1pt solid; padding-bottom: 0cm; padding-top: 0cm; padding-left: 1.5pt; border-left: #cccccc 1pt solid; padding-right: 1.5pt; background-color: transparent"><div><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: #303030">VSSZZZ5FZH6545134</span></div></td>
<td style="border-top: #cccccc 1pt solid; border-right: #cccccc 1pt solid; border-bottom: #cccccc 1pt solid; padding-bottom: 0cm; padding-top: 0cm; padding-left: 1.5pt; border-left: #cccccc 1pt solid; padding-right: 1.5pt; background-color: transparent"><div><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: #303030">43</span></div></td>
<td style="border-top: #cccccc 1pt solid; border-right: #cccccc 1pt solid; border-bottom: #cccccc 1pt solid; padding-bottom: 0cm; padding-top: 0cm; padding-left: 1.5pt; border-left: #cccccc 1pt solid; padding-right: 1.5pt; background-color: transparent"><div><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: #303030">zadnji&#160;odbijač</span></div></td>
<td style="border-top: #cccccc 1pt solid; border-right: #cccccc 1pt solid; border-bottom: #cccccc 1pt solid; padding-bottom: 0cm; padding-top: 0cm; padding-left: 1.5pt; border-left: #cccccc 1pt solid; padding-right: 1.5pt; background-color: transparent"><div><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: #303030">12</span></div></td>
<td style="border-top: #cccccc 1pt solid; border-right: #cccccc 1pt solid; border-bottom: #cccccc 1pt solid; padding-bottom: 0cm; padding-top: 0cm; padding-left: 1.5pt; border-left: #cccccc 1pt solid; padding-right: 1.5pt; background-color: transparent"><div><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: #303030">PODRSANO</span></div></td>
<td style="border-top: #cccccc 1pt solid; border-right: #cccccc 1pt solid; border-bottom: #cccccc 1pt solid; padding-bottom: 0cm; padding-top: 0cm; padding-left: 1.5pt; border-left: #cccccc 1pt solid; padding-right: 1.5pt; background-color: transparent"><div><span style="font-size: 8.5pt; font-family: &quot;verdana&quot;, &quot;sans-serif&quot;; color: #303030">800X50</span></div></td></tr></tbody></table>
<p>&#160;</p>

エンコーディングは UTF-8 に設定されています。

//ParseToElementList overided method (UTF-8)
public static ElementList ParseToElementList(String html, String css)
{
    // CSS
    ICSSResolver cssResolver = new StyleAttrCSSResolver();
    if (css != null)
    {
        ICssFile cssFile = XMLWorkerHelper.GetCSS(new MemoryStream(Encoding.UTF8.GetBytes(css)));
        cssResolver.AddCss(cssFile);
    }

    // HTML
    CssAppliers cssAppliers = new CssAppliersImpl(FontFactory.FontImp);
    HtmlPipelineContext htmlContext = new HtmlPipelineContext(cssAppliers);
    htmlContext.SetTagFactory(Tags.GetHtmlTagProcessorFactory());
    htmlContext.AutoBookmark(false);

    // Pipelines
    ElementList elements = new ElementList();
    ElementHandlerPipeline end = new ElementHandlerPipeline(elements, null);
    HtmlPipeline htmlPipeline = new HtmlPipeline(htmlContext, end);
    CssResolverPipeline cssPipeline = new CssResolverPipeline(cssResolver, htmlPipeline);

    // XML Worker
    XMLWorker worker = new XMLWorker(cssPipeline, true);
    XMLParser p = new XMLParser(worker);
    p.Parse(new MemoryStream(Encoding.UTF8.GetBytes(html)));

    return elements;
}

解析された HTML を PdfCell に入力する

List<IElement> elementsIzv = ParseToElementList(nonConformity[Helper_ND_Display.porociloIzvedba].ToString(), null);
foreach (IElement e in elementsIzv)
{
    porociloData.AddElement(e);
}
resitevTable.AddCell(porociloData);

文字 č(Č) (č) を除いてすべて正常に動作します (欠落)。何か足りないのですか、それとも ParseToElementList メソッドにバグがありますか? GetInstance メソッドによる HTML の変換

XMLWorkerHelper.GetInstance().ParseXHtml(writer, document, reader);

必要に応じてすべての文字を変換しています。

4

0 に答える 0