gpt4 book ai didi

java - 使用 fr.opensagres.xdocreport : variables remain empty 将 odt 文档转换为 pdf

转载 作者:行者123 更新时间:2023-11-30 06:09:14 26 4
gpt4 key购买 nike

opensagres.xdocreport 将odt文档转换为PDF过去。但这一次,即使 pojo 和上下文具有所有信息,PDF 文档中的变量仍为空。我使用这段代码:

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;
}
}

这是 pojo 表:

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;
}
}

我像这样引用 odt 文档中的变量:

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!}

有人知道可能出了什么问题吗?我尝试过使用版本 1.0.5 和 2.0.1 作为依赖项。我得到的唯一信息是这样的:

org.odftoolkit.odfdom.pkg.OdfXMLFactory:为 loext:contextual-spacing 创建 None-ODF 属性

我用谷歌搜索了很多,但找不到任何有用的东西。提前致谢。

最佳答案

HerbarySheetComplete 类不能是私有(private)的,它必须是公共(public)的!!!

关于java - 使用 fr.opensagres.xdocreport : variables remain empty 将 odt 文档转换为 pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50624829/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com