我正在创建adf项目并使用itextpdf 5.1.3生成报告。 例如: - 我的表客户有3000行。在我的jspx页面有客户表&按钮有文件下载列表程序那里我只是简单地调用报告。 只有前50行(最多4页)才会生成报告。 为什么剩余的行不在报告中?itextpdf中的最大页面大小
private void generatePDFFile(FacesContext facesContext, java.io.OutputStream outputStream) {
try {
DCBindingContainer dcBindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding iterBind1 = (DCIteratorBinding)dcBindings.get("CustomerView1Iterator");
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(FILE)); \\file path local disk D:\mywork\customer.pdf
document.open();
Row[] rows= iterBind1.getAllRowsInRange();
for(Row row:rows){
custcode = (String) row.getAttribute("CustomerCode");
custname = (String) row.getAttribute("CustomerNameE");
addgroup(document);
}
document.close();
facesContext = facesContext.getCurrentInstance();
ServletContext context = (ServletContext)facesContext.getExternalContext().getContext();
File file = new File(FILE);
FileInputStream fileInputStream;
byte[] b;
System.out.println(file.getCanonicalPath());
System.out.println(file.getAbsolutePath());
fileInputStream = new FileInputStream(file);
int n = fileInputStream.available();
while (n > 0) {
b = new byte[n];
//b = new byte[8192];
int result = fileInputStream.read(b);
outputStream.write(b, 0, b.length);
if (result == -1)
break;
}
outputStream.flush();
} catch (Exception e) {
e.printStackTrace();
}
}
private static void addgroup(Document document) throws DocumentException{
Paragraph preface1 = new Paragraph();
Paragraph preface2 = new Paragraph();
preface1.add(new Chunk("\n"));
preface1.add(new Chunk("Customer : "+custcode+" "+custname,BlueFont));
preface1.add(new Chunk("\n"));
document.add(preface1);
document.add(preface2);
}
真是个坏问题。你能改善它吗? –
嗨布鲁诺, 我的表有3000行。当调用pdf代时只有前50行才会来。为什么? 以下是我的代码.... –
您的代码不在下面。成千上万的开发者使用iText创建了超过3000行的PDF。如果你问我*为什么*你的应用程序只渲染50行,答案很简单:因为你做错了什么。你在做什么错了?也许你不应该使用近6年前的iText版本。你有没有尝试升级? –