OpenOffice HTML & CSS : JODConverter

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 16:26:16

问题


I'm using JODConverter in my application to convert a HTML file with basic CSS 2 to a PDF file.

When I convert the file, the pdf is just a mess, And when I tried to view in openOffice directly it was a mess also.

This is the file generated :

and this is what I have in my chrome browser :

As you see there's a big difference.

This is my code :

<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>

And if anyone got another solution, then I wanted :), thx


回答1:


LibreOffice/Apache OpenOffice is a great application, but in this case it is not the right tool for the job. There are many applications that render HTML more effectively.

This worked for me, adapted from 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/

EDIT:

To make this call in Java, see How to execute system commands (linux/bsd) using Java.



来源:https://stackoverflow.com/questions/47717417/openoffice-html-css-jodconverter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!