【问题标题】:OpenOffice HTML & CSS : JODConverterOpenOffice HTML & CSS : JODConverter
【发布时间】:2018-05-22 21:07:15
【问题描述】:

我在我的应用程序中使用 JODConverter 将具有基本 CSS 2 的 HTML 文件转换为 PDF 文件。

当我转换文件时,pdf只是一团糟,当我尝试直接在openOffice中查看时也是一团糟。

这是生成的文件:

这就是我的 chrome 浏览器中的内容:

如您所见,差别很大。

这是我的代码:

<div style="padding : 5% 25% 0% 10%; diplay : inline-block; ">
  <div>
    <span style="color : green; float : left; "><b>MyCompany - MyConsultant</b></span>
    <hr style="width : 100%; border-top: dotted 1px; " />
  </div>
  <div>
    <div>
      <div style="float : left;">Number of days</div>
      <div style="float : right ">20,5</div>
      <hr style="width : 100%; border-top: dotted 1px; " />
    </div>
    <div>
      <div style="float : left ">Your number</div>
      <div style="float : right ">520,00€</div>
      <hr style="width : 100%; border-top: dotted 1px; " />
    </div>
    <div>
      <div style="float : left ">Total HT</div>
      <div style="float : right ">10 660,00€</div>
      <hr style="width : 100%; border-top: dotted 1px; " />
    </div>
    <div>
      <div style="float : left ">TVA [20%]</div>
      <div style="float : right ">2 132,00€</div>
    </div>
    <div>
      <hr style="width : 100%; border-top: dotted 3px;font-weight : bold;" />
      <div style="float : left;font-weight : bold;">TOTAL TTC</div>
      <div style="float : right;font-weight : bold;">12 792,00€</div>
    </div>
  </div>

如果有人有其他解决方案,那么我想要:),谢谢

【问题讨论】:

  • 什么操作系统?为了完整起见,请同时提及 LibreOffice 或 Apache OpenOffice 的版本。

标签: java html css openoffice.org jodconverter


【解决方案1】:

LibreOffice/Apache OpenOffice 是一个很棒的应用程序,但在这种情况下,它不是适合这项工作的工具。有许多应用程序可以更有效地呈现 HTML。

这对我有用,改编自 https://superuser.com/questions/592974/how-to-print-to-save-as-pdf-from-a-command-line-with-chrome-or-chromium

./chrome.exe --headless --disable-gpu --print-to-pdf=file1.pdf http://www.example.com/

编辑

要在 Java 中进行此调用,请参阅 How to execute system commands (linux/bsd) using Java

【讨论】:

  • 是的,但我需要在 java 中实现,如何?
猜你喜欢
  • 2023-03-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多