document has no pages with itext

后端 未结 4 695
北荒
北荒 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:52

    XMLWorkerHelper.parseXHtml() expects (X)HTML or (X)HTML snippets. Try this:

    worker.parseXHtml(writer, document, new StringReader("<p>helloworld</p>"));
    
    0 讨论(0)
  • 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. 
    
    0 讨论(0)
  • 2021-02-09 17:06

    Try to new a page just like document.newPage() before you write something to document, hope that helps.

    0 讨论(0)
  • 2021-02-09 17:14

    I know it's a bit late to this answer, but in my case just upgraded iTextSharp to v. 5.5 from 5.0 and started to work correctly.

    0 讨论(0)
提交回复
热议问题