0

I am using xdocreport for templating and converting docx to PDF. In my docx template I have an image, text paragraph and table (they are placed in this order). When I try to convert this file to PDF the result file have another structure - table, image, text paragraph. This is my code:

    InputStream is = new FileInputStream(CustomTemplate.TEMPLATES_PATH + template.getTemplatePathName());
    IXDocReport report;
    report = XDocReportRegistry.getRegistry().loadReport(is,TemplateEngineKind.Velocity);
    IContext context = report.createContext();

    FieldsMetadata metadata = new FieldsMetadata();
    metadata.addFieldAsImage("signature");
    metadata.addFieldAsImage("logo");
    report.setFieldsMetadata(metadata);

    processPredefinedParams(context, templateParams, user);
    processUserProvidedParams(context, templateParams);

    Options options = Options.getTo(ConverterTypeTo.PDF);

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    report.convert(context, options, out);  

For converting to PDF I am using docx4j converter. How can I resolve this issue?

Filosssof
  • 1,288
  • 3
  • 17
  • 37
  • Not sure I understand why this is tagged docx4j -- I can only see xdocreport code here (`ConverterTypeTo.PDF` is an xdocreport construct, nothing to do with docx4j). – Ben Jun 05 '14 at 12:01
  • 1
    Looks like there are a number of known issues with PDF conversion in xdocreport: https://code.google.com/p/xdocreport/issues/list?can=2&q=pdf&colspec=ID+Type+Status+Priority+Milestone+Owner+Summary&cells=tiles – Ben Jun 05 '14 at 12:07
  • @BenPoole xdocreport can use different converters: FOP, XSL, ODFDOM, XWPF, DOCX4j. I am using docx4j. – Filosssof Jun 05 '14 at 13:04
  • OK. I use docx4j and output to PDF without seeing issues such as you describe. What does the generated doc xml look like for your report? Is the output as you expect? Have you tried taking your docx file and pushing it through the docx4j PDF converter directly? You can do that here: http://webapp.docx4java.org/OnlineDemo/docx_to_pdf_fop.html – Ben Jun 05 '14 at 13:14
  • There is an update of this issue. If I insert table into the document and do not move it - it's ok. The table is on its place. But if I try to move it (drag'n drop) after converting the table appears on its first place – Filosssof Jun 06 '14 at 07:20
  • We'll need to see the XML (unzip your docx, and look at your document.xml part). Is the image floating? – JasonPlutext Jun 07 '14 at 09:59

0 Answers0