我正在尝试使用*.odt
将某些*.pdf
文件转换为IXDocReport。
这里是*.odt
文件的假设内容:${amount?string.currency} to be paid
这是我进行转换的代码(您可以在kotlin REPL中运行它:]]
import fr.opensagres.xdocreport.converter.ConverterTypeTo import fr.opensagres.xdocreport.converter.ConverterTypeVia import fr.opensagres.xdocreport.converter.Options import fr.opensagres.xdocreport.document.IXDocReport import fr.opensagres.xdocreport.document.registry.XDocReportRegistry import fr.opensagres.xdocreport.template.TemplateEngineKind import java.io.ByteArrayInputStream import java.io.File val options: Options = Options.getTo(ConverterTypeTo.PDF).via(ConverterTypeVia.ODFDOM) val content: ByteArray = File("/home/sandro/tmp/report.odt").readBytes() val templateId: String = "someId" val registry: XDocReportRegistry = XDocReportRegistry.getRegistry() val data: MutableMap<String, Any> = mutableMapOf("amount" to 10) ByteArrayInputStream(content).use { input -> val report: IXDocReport = registry.loadReport(input, templateId, TemplateEngineKind.Freemarker, true) val tmpFile: File = createTempFile("out", ".pdf") tmpFile.outputStream().use { output -> report.convert(data, options, output) println(tmpFile.toString()) } }
结果是带有字符串
$10.00 to be paid
的pdf文件>如何在转换过程中为XDocReport设置所需的语言环境,以便可以将结果正确更改为其他货币?
P.S。
我无法控制模板本身-因此请不要告诉我向模板本身添加<#setting locale="${bean.locale}">
或其他内容。我唯一可以更改的地方是代码。预先感谢。P.P.S。我需要为每个请求呈现许多模板,并且需要为每个模板设置区域设置。
我正在尝试使用IXDocReport将一些* .odt文件转换为* .pdf。这是* .odt文件的假设内容:$ {amount?string.currency}要付款这是我使用(you ...
我从未使用过XDocReport,但也许可以使用:https://github.com/opensagres/xdocreport/wiki/FreemarkerTemplate“如何配置Freemarker?”
从那里报价: