我们的 REST-API 应该提供基于 HTML 模板的 PDF。
我们的目的是使用 ISML 生成 HTML,将其填充到 PDF 处理器中并获取 REST 响应的输出。
使用 Intershop 7.9 实现这一目标的最佳方法是什么?
最佳答案
使用 Intershop PDF 创建文档可以轻松完成 PDF 渲染。
从 ISML 模板获取 HTML 更加棘手,主要是因为缺少示例。但在 ISH 代码中隐藏了两个示例类:
PageEntryPoint2PDFInteractionProcessor:TemplateCallable
MailMgrImpl:MailTemplateCallable
两者都可以从两个不同地方的 ISML 获取 HTML。
LocaleMgr localeMgr = NamingMgr.getManager(LocaleMgr.class);
String webpageContent = "";
// put some demo stuff into the PD
PipelineDictionary dict = new PipelineDictionaryImpl();
dict.put("foo", "foo");
Request request = Request.getCurrent();
ExecutorService executorService = Executors.newCachedThreadPool();
try {
// demo code, you might want to use another template than Empty.isml
TemplateCallable callable = new TemplateCallable("Empty", localeMgr,
dict, request);
Future<ServletResponse> future = executorService.submit(callable);
ServletResponse fwResponse = future.get();
webpageContent = fwResponse.getContent();
} catch (Exception e) {
Logger.error(this, "Error while getting template render result.");
}
您使用的Callable
类的代码可以从我上面提到的示例类派生。
关于intershop - 从 ISML 渲染 PDF 并检索二进制数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58920028/