Skip to content

Instantly share code, notes, and snippets.

@marti1125
Created August 22, 2014 16:15
Show Gist options
  • Save marti1125/c2b93ba5cdef7ac0f464 to your computer and use it in GitHub Desktop.
Save marti1125/c2b93ba5cdef7ac0f464 to your computer and use it in GitHub Desktop.
itext show in pdf vierwer
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
// step 1
Document document = new Document();
// step 2
PdfWriter writer = PdfWriter.getInstance(document, outputStream);
// step 3
document.open();
// step 4
document.add(new Paragraph("Hello World! 2222555"));
// step 5
document.close();
writer.flush();
writer.close();
outputStream.close();
ByteArrayOutputStream out = new ByteArrayOutputStream();
out.flush();
System.out.println("test 1 " + out.size());
out.write(outputStream.toByteArray());
System.out.println("test 2 " + out.size());
out.close();
//6 out to in
InputStream is = new ByteArrayInputStream(out.toByteArray());
renderBinary(is, "ReporteDeDistribucionClasesPorHoras.pdf","application/pdf",true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment