Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Render my web page in pdf instead that hmtl  RSS feed

 
Martin Lefebvre
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody!
I have a J2EE application, and i'm trying to intercept the (inputstream or outputstream???)...in other word the html content that the server is sending to the client. So that I can manipulate it, make a PDF document with it, and send it to the browser in PDF.
I have find a way, to make the PDF document.
But I can't find how to intercept the html the server sends
Somebody can help me out??
Thanks
Martin
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look into servlet filters.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can fake out the HTTPServletResponse and use a response filter to trap the data from that faked out servlet response , then construct the pdf and send it to the client.
But how are you going to construct the pdf from data.Most of the pdf generating tool needs a additional file (syr in case of iText) as template and the merge data with that to make the actual pdf.This can only work if you have an application with similar pages.
 
Martin Lefebvre
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I have found the iText library, if I can reand the html, then I could make a pdf with the iText library.
The servlet, that's what I thaught...
Could you be more specific...
I have tried this:

is = request.getInputStream();
InputStreamReader isr = new InputStreamReader ( is );
BufferedReader bufRead = new BufferedReader ( isr );
do
{
// aLine = bufRead.readLine();
if ( aLine != null )
{
// work out which lines to keep here
content += aLine;
}
} while ( aLine != null );
But aLine is always empty!!!
I have tried this code, in the doGet method of my servlet...
Do you know where I could use this code and get something in aLine??
Thanks
Martin
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.icesoft.com/products/icebrowser_itext.html
This might be a commercial tool but this perfectly fits your requirement.You give this a html inputstream and this would give pdf byte outputstream.

And as how to get the exact response at filer , it has been explained with example in the end of book Head First servlets and jsp.
 
Martin Lefebvre
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
Do you know where I can find this book "Head First servlets and jsp"??
I have look at the icesoft software, it may work, but they seem to open a new connectionurl to read the content of the page, it is something I can't do, because my webpage are SSO protected
And I can't read the page, because they are dynamic page...

Thanks
Martin
[ November 03, 2006: Message edited by: Martin Lefebvre ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!