<% OutputStream output=response.getOutputStream(); response.setContentType(\"application/pdf\"); response.setHeader(\"Content-Disposition\", \"inline; filename=detail
Try to new a page just like document.newPage() before you write something to document, hope that helps.
document.newPage()