1

i have the following html

<div style="border: 2px solid black; padding: 5px;">
    <p align="CENTER">test1</p>
    <p align="CENTER">test2</p>
</div>

and convert it to pdf with the open office lib

    <dependency>
        <groupId>com.artofsolving</groupId>
        <artifactId>jodconverter</artifactId>
        <version>2.2.1</version>
    </dependency>

and this function

public synchronized static byte[] htmlToPdf(String html) throws Exception {
    ByteArrayOutputStream pdfOutputStream = new ByteArrayOutputStream();
    DefaultDocumentFormatRegistry defaultDocumentFormatRegistry = new DefaultDocumentFormatRegistry();

    OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
    connection.connect();
    DocumentConverter converter = new OpenOfficeDocumentConverter(connection);

    converter.convert(IOUtils.toInputStream(html, Charset.forName("UTF-8")), defaultDocumentFormatRegistry.getFormatByFileExtension("html"), pdfOutputStream, defaultDocumentFormatRegistry.getFormatByFileExtension("pdf"));

    connection.disconnect();
    return pdfOutputStream.toByteArray();
}

and we are running this ooversion

@linux-9jgs:~> soffice --version
LibreOffice 4.3.7.2 430m0(Build:2)

but in the pdf each line gets it's own border, in a browser the html looks ok

enter image description here

i remeber in a previous version of open office it worked correct

wutzebaer
  • 14,365
  • 19
  • 99
  • 170

0 Answers0