Running a url from servlet and converting resultant html into pdf

Can anybody tell me how to access webpage throughs a servlet.i.e if a url is hardcoded in the srvlet ho will it run it in the default browser.
[149 byte] By [Sulemana] at [2007-10-2 20:14:41]
# 1

Your questiion is not clear

1. To access a URL from Servlet, use java.net.URL API to access the URL and its response.

2. Converting the content into PDF,

I am not sure what part of the HTML response content are you trying to convert to PDF.

Try iText PDF libraries... May be they have an option...

Thanks and regards,

Pazhanikanthan. P

pazhanikanthana at 2007-7-13 22:56:52 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

> 2. Converting the content into PDF,

> I am not sure what part of the HTML response content

> are you trying to convert to PDF.

>

> Try iText PDF libraries... May be they have an

> option...

I need to convert parts of the html page into pdf format, and I read this and thought you might help me.

I have a web application that uses servlets and jsp. The servlet gets the request from the client, then a DAO object queries the database and a jsp page is returned to the client with the results of the query. The returned page has some navigation links (previous and next) because the database returns lots of results. I want the user to be able to get all this results in a pdf file.

Am I clear?

Thanks

DesarrolloScreenNamea at 2007-7-13 22:56:52 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Hello DesarrolloScreenName,

I believe what you are trying to provide is a Report in PDF format. The Report is presented in the HTML as Tabular format with Prev Next navigations and then you need to provide a link upon clicking will download a PDF with similar report in a PDF with all the records. If my understanding is correct, you would probably need to do the following:

1. Create a new Servlet or reuse the same servlet with a different user action.

2. Write logic to retrieve all the records.

3. Use iText PDF Libraries to create a PDF document in runtime. Add a Table to the document and then add the records in the desired report format.

4. Close the document and convert it to byte content [byte array].

5. Open the reponse stream in the servlet and then flush the byte array content. This will result in painting the PDF in the browser.

Hope these steps help you...

Thanks and regards,

Pazhanikanthan. P

pazhanikanthana at 2007-7-13 22:56:52 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...