2

我正在尝试使用该itextsharp itexthandler.parse方法将 XML 转换为 PDF,但现在我将 DLL 更新为itextsharp新的。

这是要转换的 XML

<?xml version="1.0" encoding="utf-16"?>
<itext xmlns:cs="urn:cs">
<ignore />
<chapter numberdepth="0" depth="0" indent="0" leading="18.0">
<title leading="15.0" align="Default" font="Helvetica, Arial" size="18.0" fontstyle="normal" red="140" green="43" blue="120">
  <chunk font="Helvetica, Arial" fontstyle="normal">Statistics Report</chunk>
  <chunk red="140" green="43" blue="120" fontstyle="italic">
            Main
          </chunk>
</title>
<section numberdepth="1" depth="1" indent="0">
  <title leading="25.0" align="Default" font="Helvetica, Arial" size="17.0" fontstyle="normal" red="85" green="85" blue="85">
    <chunk font="Helvetica, Arial" fontstyle="normal">General Statistics</chunk>
  </title>
  <table columns="3" width="80%" align="Center" cellpadding="5.0" cellspacing="5.0" widths="33.33333;33.33333;33.33333">
    <row>
      <cell horizontalalign="center" verticalalign="center" leading="18.0" bgred="140" bggreen="43" bgblue="120">
        <paragraph leading="18.0" font="Georgia, Arial" red="255" green="255" blue="255" bgred="140" bggreen="43" bgblue="120">
          Registered Users<newline />15</paragraph>
      </cell>
      <cell horizontalalign="center" verticalalign="center" leading="18.0" bgred="140" bggreen="43" bgblue="120">
        <paragraph leading="18.0" font="Georgia, Arial" red="255" green="255" blue="255">
          All Hotels<newline />78</paragraph>
      </cell>
      <cell horizontalalign="center" verticalalign="center" leading="18.0" bgred="140" bggreen="43" bgblue="120">
        <paragraph leading="18.0" font="Georgia, Arial" red="255" green="255" blue="255">
          All Departments<newline />9</paragraph>
      </cell>
    </row>
  </table>
</section>
</chapter>
</itext>

我也使用了这段代码,但这也失败了:

using (StringReader sr = new StringReader(xmlTransformed))
                    {
                        PdfWriter writer = PdfWriter.GetInstance(document, myMemoryStream);
                        document.Open();
                        XMLWorkerHelper.GetInstance().ParseXHtml(
                          writer, document, sr
                        );
                    }
4

0 回答 0