1

I'm using this code to convert an XWPFDocument to PDF:

ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfOptions options = PdfOptions.create();

PdfConverter.getInstance().convert(xwpfDocument, baos, options);

The converter is setting wrong margins on the pdf. Here is the original .docx:

enter image description here

And this is the pdf after conversion:

enter image description here

How can I retain the original left and right margins?

Wafula Samuel
  • 530
  • 1
  • 8
  • 25
  • 1
    Margins _and_ individual table column widths. Maybe a conversion **docx-to-html** + **html-to-pdf** would do better, as html is a better "understood" format. – Joop Eggen Sep 19 '18 at 08:56
  • 1
    @sam-ziggler, you can try to adjust page margins using [next approach >>](https://stackoverflow.com/questions/52466352/how-to-change-margins-when-converting-with-apache-poi/52471740#52471740), but need to take into account that PDF converter will not provide ideal result anyway. – marme1ad Sep 24 '18 at 01:42

0 Answers0