问题描述
我在应用程序中使用JODConverter将具有基本CSS 2的HTML文件转换为PDF文件.
I'm using JODConverter in my application to convert a HTML file with basic CSS 2 to a PDF file.
当我转换文件时,pdf只是一团糟,而当我尝试直接在openOffice中查看时,也是一团糟.
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.
这是生成的文件:
这就是我的Chrome浏览器中的内容:
and this is what I have in my chrome browser :
您所看到的有很大的不同.
As you see there's a big difference.
这是我的代码:
<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
推荐答案
LibreOffice/Apache OpenOffice是一个很棒的应用程序,但在这种情况下,它不是完成此任务的正确工具.有许多应用程序可以更有效地呈现HTML.
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.
这对我有用,改编自.
./chrome.exe --headless --disable-gpu --print-to-pdf=file1.pdf http://www.example.com/
编辑:
要使用Java进行此调用,请参见如何执行使用Java的系统命令(linux/bsd).
To make this call in Java, see How to execute system commands (linux/bsd) using Java.
这篇关于OpenOffice HTML和CSS:JODConverter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!