document has no pages with itext

后端 未结 4 694
北荒
北荒 2021-02-09 16:41
<%
OutputStream output=response.getOutputStream();
response.setContentType(\"application/pdf\");
response.setHeader(\"Content-Disposition\", \"inline; filename=detail         


        
4条回答
  •  终归单人心
    2021-02-09 16:53

    Other answers are good. This is an alternative.

    In general, to prevent this error which often occurs when the document contains no meaningful data for content, even despite document.open() and document.newPage() having been called, and even after stamping other pages into that document, you can add an empty chunk when the document is opened to ensure the library never considers it empty. e.g.

    document.open(); 
    document.add(new Chunk("")); // << this will do the trick. 
    

提交回复
热议问题