<%
OutputStream output=response.getOutputStream();
response.setContentType(\"application/pdf\");
response.setHeader(\"Content-Disposition\", \"inline; filename=detail
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.