如何使用primefaces DataExporter导出带有阿拉伯语数据的PDF
我使用p:dataExporter导出p:dataTable的内容,该表包含阿拉伯语内容。当我将其导出为Excel时,它工作正常,但如果我尝试将其导出为PDF,则不会显示阿拉伯语内容。 我正在使用iText2.1.7 这是我的p:dataTable和p:dataExporter如何使用primefaces DataExporter导出带有阿拉伯语数据的PDF,primefaces,itext,openpdf,Primefaces,Itext,Openpdf,我使用p:dataExporter导出p:dataTable的内容,该表包含阿拉伯语内容。当我将其导出为Excel时,它工作正常,但如果我尝试将其导出为PDF,则不会显示阿拉伯语内容。 我正在使用iText2.1.7 这是我的p:dataTable和p:dataExporter <p:dataTable id="chequeReport_tbl" value="#{reportsController.listOfChequeReports}" var="chequeReport"
<p:dataTable id="chequeReport_tbl" value="#{reportsController.listOfChequeReports}" var="chequeReport"
paginator="true" editable="false" rows="10"
tableStyle="width: auto;" style="direction: ltr; text-align: right;margin-top: 5px;margin-bottom:20px"
paginatorTemplate="{Exporters} {CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10">
<f:facet name="{Exporters}">
<div style="float:right;">
<h:commandLink actionListener="#{reportsController.generateBankChequeReportPDF()}">
<p:graphicImage value="res/images/pdf_2.png" width="12"/>
</h:commandLink>
<h:commandLink>
<p:graphicImage value="res/images/excel.png" width="24"/>
<p:dataExporter type="xls" target="chequeReport_tbl" fileName="chequeReport"/>
</h:commandLink>
</div>
</f:facet>
<p:column headerText="تاريخ الصرف" style="text-align: center">
<h:outputText value="#{chequeReport.exchangeDate}"/>
</p:column>
<p:column headerText="أسم المستفيد" style="text-align: center">
<h:outputText value="#{chequeReport.beneficiaryName}"/>
</p:column>
<p:column headerText="مبلغ الشيك بالدولار" style="text-align: center">
<h:outputText value="#{chequeReport.chequeAmountInDollar}"/>
</p:column>
<p:column headerText="العملة" style="text-align: center">
<h:outputText value="#{chequeReport.currency}"/>
</p:column>
<p:column headerText="قيمة الشيك" style="text-align: center">
<h:outputText value="#{chequeReport.chequeAmount}"/>
</p:column>
<p:column headerText="تاريخ الإصدار" style="text-align: center">
<h:outputText value="#{chequeReport.issuingDate}"/>
</p:column>
<p:column headerText="القطاع الإقتصادي" style="text-align: center">
<h:outputText value="#{chequeReport.financialDep}"/>
</p:column>
<p:column headerText="الفرع" style="text-align: center">
<h:outputText value="#{chequeReport.branch}"/>
</p:column>
<p:column headerText="رقم الحساب" style="text-align: center">
<h:outputText value="#{chequeReport.accountNumber}"/>
</p:column>
<p:column headerText="رقم الهوية" style="text-align: center">
<h:outputText value="#{chequeReport.idNumber}"/>
</p:column>
<p:column headerText="أسم العميل" style="text-align: center">
<h:outputText value="#{chequeReport.customerName}"/>
</p:column>
</p:dataTable>
实际上,您的问题可以(也应该)分为两个问题,两个问题在stackoverflow中都有Q/A 问题1:使用iText时,如何在PDF中显示阿拉伯语。
答复1: 问题2:导出为PDF时如何自定义PrimeFaces数据导出器
答复2:
将它们结合起来,您就有了自己的解决方案。欢迎来到Stakoverflow。请提供一个没有代码,这是很难真正帮助你。为中国日语等相同。。。试着让它在一段非常简单的普通代码中工作,只需使用itext和它的一些扩展,然后使用PrimeFaces预处理器功能将相关代码添加到导出器。@Lonzak我用包含数据和dataExporter@Kukeltje我知道我能做到,但我有很多数据表,我想将其数据导出为pdf格式,每个表都有不同的列名和数据,因此很难为每个表实现代码。然后请人来完成。。。它创建一个类并向每个数据表添加一个属性。下一次请说明你尝试过的和知道的,本可以为我节省15-30分钟的搜索时间谢谢,但我已经看到了这些问题,但它们并不能解决我的问题。对于第一种方法,只有当我有静态数据(硬编码)时,它才起作用,但我的数据是从数据库中获取的。至于第二个问题,我不是想定制它。对于问题中的所有错误,我很抱歉,我仍然是新的。当您想要添加这些字体(或覆盖导出器的源)时,您需要自定义它