javapdfconvertersodt

Converting odt document to pdf with fr.opensagres.xdocreport: variables remain empty


opensagres.xdocreport to convert odt documents to PDF in the past. But this time the variables in the PDF document remain empty even though the pojo and the context have all the Information. I use this Code:

private ByteArrayOutputStream makePdf(Object sheet, String file)
{
  final java.util.logging.Logger app = java.util.logging.Logger.getLogger("org.odftoolkit.odfdom.pkg.OdfXMLFactory");
  app.setLevel(java.util.logging.Level.ALL);

  try (InputStream in = DocumentPortImpl.class
        .getResourceAsStream(PATH + file);
        ByteArrayOutputStream out = new ByteArrayOutputStream())
  {
     IXDocReport report = XDocReportRegistry.getRegistry()
           .loadReport(in, TemplateEngineKind.Freemarker);
     IContext context = report.createContext();
     context.put("h", sheet);

     Options options = Options.getFrom(
           fr.opensagres.xdocreport.core.document.DocumentKind.ODT).to(ConverterTypeTo.PDF);

     report.convert(context, options, out);
     return out;
  } catch (IOException | XDocReportException e)
  {
     LOGGER.error("Error producing pdf", e);
     return null;
  }
}

This is the pojo sheet:

private class HerbarySheetComplete
{
  private String herbary = "";
  private String latinname = "";
  private String author = "";
  private String germanname = "";
  private String book = "";
  private String locality = "";
  private String coordinates = "";
  private String epsg = "";
  private String blur = "";
  private String habitat = "";
  private String person = "";
  private String date = "";
  private String uuid = "";

  public String getHerbary()
  {
     return herbary;
  }

  public void setHerbary(String herbary)
  {
     this.herbary = herbary;
  }

  public String getLatinname()
  {
     return latinname;
  }

  public void setLatinname(String latinname)
  {
     this.latinname = latinname;
  }

  public String getAuthor()
  {
     return author;
  }

  public void setAuthor(String author)
  {
     this.author = author;
  }

  public String getGermanname()
  {
     return germanname;
  }

  public void setGermanname(String germanname)
  {
     this.germanname = germanname;
  }

  public String getBook()
  {
     return book;
  }

  public void setBook(String book)
  {
     this.book = book;
  }

  public String getLocality()
  {
     return locality;
  }

  public void setLocality(String locality)
  {
     this.locality = locality;
  }

  public String getCoordinates()
  {
     return coordinates;
  }

  public void setCoordinates(String coordinates)
  {
     this.coordinates = coordinates;
  }

  public String getEpsg()
  {
     return epsg;
  }

  public void setEpsg(String epsg)
  {
     this.epsg = epsg;
  }

  public String getBlur()
  {
     return blur;
  }

  public void setBlur(String blur)
  {
     this.blur = blur;
  }

  public String getHabitat()
  {
     return habitat;
  }

  public void setHabitat(String habitat)
  {
     this.habitat = habitat;
  }

  public String getPerson()
  {
     return person;
  }

  public void setPerson(String person)
  {
     this.person = person;
  }

  public String getDate()
  {
     return date;
  }

  public void setDate(String date)
  {
     this.date = date;
  }

  public String getUuid()
  {
     return uuid;
  }

  public void setUuid(String uuid)
  {
     this.uuid = uuid;
  }
}

And I reference the variables in the odt document like this:

Herbarium: ${h.herbary!}
Lat. Name: ${h.latinname!} ${h.author!}
Dt. Name:  ${h.germanname!}
Bestimmungsquelle: ${h.book!}
Fundort: ${h.locality!}
Koordinaten: ${h.coordinates!} Länge/Breite
EPSG-Code: ${h.epsg!}, ${h.blur!} Unschärfe
Habitat: ${h.habitat!}
Sammler: ${h.person!}
Funddatum: ${h.date!}
UUID: ${h.uuid!}

Has anyone any ideas what could be wrong? I have tried with version 1.0.5 and 2.0.1 as dependency. The only INFO I get is something like this:

org.odftoolkit.odfdom.pkg.OdfXMLFactory : None-ODF attribute created for loext:contextual-spacing

I googled a lot but could not find anything helpful. Thanks in advance.


Solution

  • The class HerbarySheetComplete may not be private, ist must be public!!!