API XDocReport Java: проблема преобразования ODT в PDF - PullRequest
0 голосов
/ 05 марта 2020

Проблема при попытке преобразования простого ODT в PDF, когда в ODT присутствует таблица. Таблица не отображается, а символы отображаются в виде документа по всему документу.

XDocReport: https://github.com/opensagres/xdocreport

Код:

  /**
   * https://github.com/opensagres/xdocreport/wiki
   */
  public OdtBuilder gravaPdf(File fileDest) throws Exception {
    File file = new File(fileName);

    if (!file.exists()) {
      throw new RuntimeException("Documento precisa ser gravado antes de exportar para PDF");
    }

    // 1) Create options ODT to PDF
    Options options = Options.getFrom(DocumentKind.ODT).to(ConverterTypeTo.PDF);

    // 2) Get the converter from the registry
    IConverter converter = ConverterRegistry.getRegistry().getConverter(options);

    InputStream in = new FileInputStream(file);
    OutputStream out = new FileOutputStream(fileDest);

    // 3) Convert ODT to PDF
    converter.convert(in, out, options);

    in.close();
    out.close();

    return this;
  }

pom . xml:

<!-- https://mvnrepository.com/artifact/fr.opensagres.xdocreport/xdocreport -->
<dependency>
    <groupId>fr.opensagres.xdocreport</groupId>
    <artifactId>xdocreport</artifactId>
    <version>2.0.2</version>
</dependency>

ODT:

ODT

Полученный PDF:

PDF

1 Ответ

0 голосов
/ 05 марта 2020

Это была проблема со стилями в моем документе. Решаемые.

...