1
<p:dataExporter type="pdf" target="callRpt"preProcessor="#{pc_CallReportBean.preProcessPDF}"
        fileName="#{reportLbl['callReport.callsReportFileName']}" />

public void preProcessPDF(Object document) throws IOException, BadElementException, DocumentException 
{  
    Document pdf = (Document) document;  
    pdf.open();  
    pdf.setPageSize(PageSize.A4);  

    ServletContext servletContext = (ServletContext)FacesContext.
               getCurrentInstance().getExternalContext().getContext();  
    String logo = servletContext.getRealPath("") + File.separator + "images" + File.separator + "prime_logo.png";  

    pdf.add(Image.getInstance(logo));  
} 

上記のコードでは、primefaces のタグを使用してテーブルを pdf 形式でエクスポートし、フロント ページにロゴを設定します。

p:dataExporter を使用してページ番号、ヘッダー、およびフッターを設定するにはどうすればよいですか?

また、複数のページが生成される場合、すべてのページにテーブルの見出しを設定したいですか?

4

1 に答える 1

2

iText を PDF ジェネレーターとして使用していると思われるのでPdfPageEventHelper、ヘッダーとフッターを作成するために を実装する必要があります。この関数を使用すると、各ページ フッターのページ番号をインクリメントできます。

これを実装する方法を示す完全な例を次に示します。

于 2013-05-27T18:13:16.347 に答える