데이터 테이블의 pdf를 생성하기 위해 dataexporter를 사용하고 있습니다. 데이터 테이블에서 열 헤더가 중앙화되어 있지만 같은 열의 pdf 버전은 왼쪽에 정렬되어 있습니다. 어떻게 pdf의 열을 데이터 테이블처럼 중앙화 할 수 있습니까?Dataexporter pdf header position
1
A
답변
2
나는 PDFExporter을 사용자 정의 솔루션을 사용을 만들기 위해 자신의 프로세서를 작성해야합니다. 다음은 내가했던 방법입니다
내 사용자 정의 클래스 :
public class CustomPDFExporter extends PDFExporter {
@Override
protected void addColumnFacets(DataTable table, PdfPTable pdfTable, ColumnType columnType) {
for(UIColumn col : table.getColumns()) {
if(!col.isRendered()) {
continue;
}
if(col instanceof DynamicColumn) {
((DynamicColumn) col).applyModel();
}
if(col.isExportable()) {
addHeaderValue(pdfTable, col.getFacet(columnType.facet()), FontFactory.getFont(FontFactory.TIMES, "iso-8859-1", Font.DEFAULTSIZE, Font.BOLD));
}
}
}
protected void addHeaderValue(PdfPTable pdfTable, UIComponent component, Font font) {
String value = component == null ? "" : exportValue(FacesContext.getCurrentInstance(), component);
PdfPCell cell = new PdfPCell(new Paragraph(value, font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
pdfTable.addCell(cell);
}
}
는 콩 : 내 페이지에서
public void exportPDF(DataTable table, String filename) throws IOException {
FacesContext context = FacesContext.getCurrentInstance();
Exporter exporter = new CustomPDFExporter();
exporter.export(context, table, filename, false, false, "iso-8859-1", null, null);
context.responseComplete();
}
내가 추가 :
<h:commandLink action="#{boxBean.exportPDF(boxTable, 'relatorio_caixas')}" >
<p:graphicImage value="/resources/img/pdf.png"/>
</h:commandLink>
0
그럼 당신의 대답에 유래에 이미 :
changing style on generating pdf with Primefaces dataExporter 또한 여기 좀 봐 : http://www.primefaces.org/showcase/ui/exporterProcessor.jsf Primefaces의 exportProcessor을 사용하는 방법.
은 한마디로 당신은 당신의 관심을 주셔서 감사합니다, 그것은 매우 잘 작동 사용자 정의 PDF