I am using following snippet code for Generate PDF as Output Stream in HTTP request in java
Code is:-
webAppAccess.getHttpServletResponse().setContentType("application/pdf");
try {
// step 1
Document document = new Document();
// step 2
PdfWriter.getInstance(document, webAppAccess
.getHttpServletResponse().getOutputStream());
// step 3
document.open();
// step 4
document.add(new Paragraph("Hello World"));
document.add(new Paragraph(new Date().toString()));
// step 5
document.close();
} catch (DocumentException de) {
throw new IOException(de.getMessage());
}
I am getting pdf on screen
%PDF-1.4 %���� 2 0 obj <>stream x�+�r �26S�00SI�2P�5�1���BҸ4>>>/MediaBox[0 0 595 842]/Parent 3 0 R/Contents 2 0 R/Type/Page>> endobj 1 0 obj <> endobj 3 0 obj <> endobj 5 0 obj <> endobj 6 0 obj <> endobj xref 0 7 0000000000 65535 f 0000000331 00000 n 0000000015 00000 n 0000000419 00000 n 0000000174 00000 n 0000000470 00000 n 0000000515 00000 n trailer <]/Info 6 0 R>> %iText-5.4.0 startxref 668 %%EOF
Please help me out for the same