【发布时间】:2019-11-18 17:29:30
【问题描述】:
我们的 REST-API 应该提供基于 HTML 模板的 PDF。
我们的目的是使用 ISML 生成 HTML,将其填充到 PDF 处理器中并获取 REST 响应的输出。
使用 Intershop 7.9 实现该功能的最佳方式是什么?
【问题讨论】:
标签: intershop
我们的 REST-API 应该提供基于 HTML 模板的 PDF。
我们的目的是使用 ISML 生成 HTML,将其填充到 PDF 处理器中并获取 REST 响应的输出。
使用 Intershop 7.9 实现该功能的最佳方式是什么?
【问题讨论】:
标签: intershop
使用 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-Class 的代码可以从我上面提到的示例类派生而来。
【讨论】: