2017-06-19 94 views
0

我正在创建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); 

} 
+2

真是个坏问题。你能改善它吗? –

+0

嗨布鲁诺, 我的表有3000行。当调用pdf代时只有前50行才会来。为什么? 以下是我的代码.... –

+1

您的代码不在下面。成千上万的开发者使用iText创建了超过3000行的PDF。如果你问我*为什么*你的应用程序只渲染50行,答案很简单:因为你做错了什么。你在做什么错了?也许你不应该使用近6年前的iText版本。你有没有尝试升级? –

回答

0

通过14,400个用户单位,PDF文档中页面的最大大小为14,400。查看博文Help, I only see blank pages in my PDF。这不是iText引入的限制;这是PDF阅读器(如Adobe Reader)中存在的限制。其他观众(如Apple Preview)在显示较大页面的PDF时没有问题。

这会回复您帖子主题行中的问题。

您帖子的正文包含完全不同的问题。也许你不是在问页面大小,而是关于文件大小。过去也回答了这个问题。见What is the size limit of pdf file?

请允许我总结了答案:

  • 与年纪比PDF 1.5大约10千兆字节的某个版本的PDF的最大尺寸。
  • 使用压缩交叉引用流的PDF版本为1.5或更高版本的PDF的最大大小仅取决于处理PDF的软件的限制。
  • 使用5.3之前的iText版本创建的PDF的最大大小为2千兆字节。使用iText版本5.3和更高版本创建的PDF的最大大小为1 TB。

由于您使用的是iText 5.1.3,因此您可以创建2 GB的PDF。它打败了我,为什么你使用的是2011年11月的iText版本,而不是更新的版本,但没有理由不能将包含3000行的表格放在PDF中,这样的表格可以同样大为2 GB。

有可能是你的代码非常糟糕。不幸的是,你不会向我们展示你的代码。您是否阅读过有关如何创建Large Tables的文档?

我不能在这里你说的部分评论:

在我JSPX页面有客户表&按钮有文件下载听者有我只是打电话报告。

这似乎没有在您的问题的上下文中相关。