java - Send whole content to mail in pdf after clicking a button in jsp -


i creating java server page.
has button send email.
after clicking button whole page content should sent pdf client attachment.
not want store pdf on server.

you can use itext generate pdf document without having physically create file.

example:

file out = new file("somewhere.pdf"); pdfdocument pdfdocument = new pdfdocument(new pdfwriter(new filewriter(out))); document layoutdocument = new document(pdfdocument); layoutdocument.add(new paragraph("hello world")); layoutdocument.close(); 

in particular example i've used filewriter, writer do. so

bytearrayoutputstream baos = new bytearrayoutputstream(); writer w = new outputstreamwriter(baos);  // itext logic here ...  // add bytes email byte[] mimebytes = baos.tobytearray(); ... 

check out documentation itext @ http://developers.itextpdf.com/content/itext-7-jump-start-tutorial/examples


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -