如何使用主要字体数据导出器导出包含阿拉伯语数据的 PDF



我正在使用p:dataExporter导出我的p:dataTable的内容,其中包含阿拉伯语内容。当我将其导出为 Excel 时,它工作正常,但如果我尝试将其导出为 PDF,则不会显示阿拉伯语内容。我正在使用 iText 2.1.7。

这是我的 p:dataTable 与 p:dataExporter

<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>

实际上,您的问题可以(并且应该(分为两个问题,这两个问题在堆栈溢出中都有现有的问答。

问题 1:使用 iText 时如何在 PDF 中显示阿拉伯语。
答案 1: 如何在使用 iText 创建的 PDF 中显示阿拉伯语

问题 2:导出为 PDF
时如何自定义 PrimeFaces 数据导出器答案 2: 如何从 PrimeFaces p:dataExporter 自定义 PDF,例如页面大小

将它们结合起来,你就有了自己的解决方案。

最新更新