Ah, your doing something even less typical :)

There really is no easy way to do this... once your on the client, about the only way to generate a PDF would be if the user had Acrobat, or a suitable substitute available, one that exposes a print driver (i.e., Print to PDF functionality).

Two options I can think of... first, is there any reason you have to generate the document on the client? If not, I would suggest looking at any of the PDF generation packages out there, iText being the one I've personally used, and do it on the server. You say "open this dynamically generated window". which I take to mean that you pop a new window and write to it. If that's correct, how you would do it instead is open the window, and set its source to an Action, which does the PDF generation. You then write it to the response stream and it will show up in the window, assuming the user has a suitable plugin installed.

Alternatively, you could generate it on the client, but then send the result to the server to generate and send back. This is really a pretty bad idea IMO, so I'd be going with option A for sure. But again, maybe you have some good reason for doing it on the client, in which case I doubt you'll find many options... *maybe* an applet that could grab the written contents of the document body and generate a PDF, but even that would be way more work than it needs to be.

Generate on the server, that's the simplest and best answer :)

Frank

Anjishnu Bandyopadhyay wrote:
Hi Frank,

I am generating the HTML page from my JavaScript file through
"document.writeln()";

I want to open this dynamically generated window in a PDF document.

With best regards,

Anjishnu.

-----Original Message-----
From: Frank W. Zammetti [mailto:[EMAIL PROTECTED] Sent: Thursday, September 07, 2006 11:22 AM
To: Struts Users Mailing List
Subject: Re: Converting HTML content to PDF

Hi,

Setting the content type is not sufficient to generate a PDF... are you trying to output a PDF from an existing HTML file, or are you dynamically generating the HTML? You say you aren't using JSP, so I'm thinking your either forwarding to an HTML page, or generating it in
your Action.  While there are HTML to PDF converters, I'm not sure which


if any could be called from a webapp, and even so, typically dynamically


generated PDF doesn't make a stop as HTML first, so it might help to understand a little better what your trying to do to offer some
suggestions.  But, it is definitely more than just the content type.

Frank

Anjishnu Bandyopadhyay wrote:

Hi all,





I am trying to programmatically convert an HTML file to pdf
dynamically;

by setting the content type. But, I am not being able to succeed.


Any pointers regarding the same will be of much use.





Please note that, I am not using a JSP here. (So that, I could be able

to set the "content" of the "response").





With best regards,


Anjishnu.







**************** CAUTION - Disclaimer *****************

This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended
solely for the use of the addressee(s). If you are not the intended
recipient, please notify the sender by e-mail and delete the original
message. Further, you are not to copy, disclose, or distribute this
e-mail or its contents to any other person and any such actions are
unlawful. This e-mail may contain viruses. Infosys has taken every
reasonable precaution to minimize this risk, but is not liable for any
damage you may sustain as a result of any virus in this e-mail. You
should carry out your own virus checks before opening the e-mail or
attachment. Infosys reserves the right to monitor and review the content
of all messages sent to or from this e-mail address. Messages sent to or
from this e-mail address may be stored on the Infosys e-mail system.

***INFOSYS******** End of Disclaimer ********INFOSYS***


--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: [EMAIL PROTECTED]
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to