Page 1 of 1

OpenOffice vs docx4j pdf output

PostPosted: Wed Mar 30, 2016 7:17 am
by fil78
Hello,
I have docx file(report.docx in attachments) and I try to generate pdf - it looks nice with content but it differs from OpenOffice output(also in attachments). I wonder what settings should I use to make them similar? I use 3.2.0 version. My code for generation:
Code: Select all
        String regex = ".*(arial|times).*";
        PhysicalFonts.setRegex(regex);

        Mapper fontMapper = new IdentityPlusMapper();
        template.setFontMapper(fontMapper);

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        Docx4J.toPDF(template, bos);

        return bos;

Thanks in advance.

Re: OpenOffice vs docx4j pdf output

PostPosted: Tue Apr 12, 2016 5:38 pm
by jason
settings aren't going to make a difference; these are completely different approaches to generating PDF, each with their own quirks.

Note that docx4j itself offers a couple of different ways of generating PDF, and for 3.3, per https://github.com/plutext/docx4j/blob/ ... ANGELOG.md

XSL FO based PDF output moved to new/separate project docx4j-export-fo; default PDF converter changed from XSL FO + Apache FOP to Plutext's PDF Converter. The instance at converter-eval.plutext.com is used by default, but you can (and should!) alter it to your own instance, by setting docx4j property, eg:

com.plutext.converter.URL=http://converter-eval.plutext.com:80/v1/00000000-0000-0000-0000-000000000000/convert

See further http://www.plutext.com/m/index.php/prod ... o-pdf.html

If you want to use the existing XSL FO + Apache FOP PDF Conversion, just add docx4j-export-fo (+ deps) to your classpath. These jars are in the zip file, in dir optional/export-fo docx4j will detect that they are present, and revert to the FO based conversion.