是否可以使用素数的数据导出器将编辑器数据导出为 pdf。
我尝试使用以下代码,但它不起作用。
<p:editor value="#{mailBean.mail}" id="editor">
</p:editor>
<p:commandLink>
<p:graphicImage value="/images/pdf.gif" />
<p:dataExporter type="pdf" target="editor" fileName="files" pageOnly="true"/>
</p:commandLink>
不,它不是
从用户指南:
DataExporter可以方便地将使用Primefaces Datatable列出的数据导出为各种格式 例如Excel,PDF,CSV和XML。
用户指南中的更多信息
目标必须 指向 PrimeFaces 数据表
编辑
您可以尝试的是:将TinyMCE编辑器集成到您的项目中,并查看此线程HTML到PDF演示,这是直接链接所见即所得编辑器导出为PDF
数据导出器发布者按钮不能 ajax,目标值应引用数据表,您还需要 itext 2.1.7 可选数据导出器 (PDF) *apache poi 3.7 可选数据导出器* 库 (Excel)。
即使它们没问题,数据导出器还不稳定,这取决于您的数据表。例如,当您将动态列与列组一起使用时,它无法导出数据。
我更喜欢使用 itext 库导出您自己的文档,它也更灵活。
祝你好运!
如果目标必须指向PrimeFaces Datatable,那么下面的代码是如何可能的这是来自Primeface网站。(http://www.primefaces.org/showcase/ui/chartExport.jsf)
<p:lineChart value="#{chartBean.linearModel}" legendPosition="e" zoom="true"
title="Linear Chart" minY="0" maxY="10" style="width:500px;height:300px" widgetVar="chart"/>
<p:commandButton type="button" value="Export" icon="ui-icon-extlink" onclick="exportChart()"/>
<p:dialog widgetVar="dlg" showEffect="fade" modal="true" header="Chart as an Image">
<p:outputPanel id="output" layout="block" style="width:500px;height:300px"/>
</p:dialog>
function exportChart() {
//export image
$('#output').empty().append(PF('chart').exportAsImage());
//show the dialog
PF('dlg').show();
}
这里的源文件是一个图表,使用函数 exportChart() 获取导出的数据作为图像.这意味着我们可以导出任何数据,而不仅仅是 primeface 数据表。