RE: ActionServlet return a pdf document

2002-02-14 Thread Galbreath, Mark

Then I suspect that therein your problem lies.

Cheers!
Mark

--
Try before you cry:
http://www.mail-archive.com/struts-user%40jakarta.apache.org/


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 14, 2002 7:31 AM

Here I use Itext tool to create pdf files. Its a Java library. I use
iText.jar to generate the PDF files.


"Galbreath, Mark" <[EMAIL PROTECTED]> on 2002.02.14 17:52:38
Where did PdfWriter() come from?

Cheers!
Mark

--
Try before you cry:
http://www.mail-archive.com/struts-user%40jakarta.apache.org/


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 14, 2002 5:26 AM

file.When i try to open the PDF file I get the error as
"There was an error opening this document.Could not repair this file"

public class PDF extends Action
{
 public ActionForward perform(ActionMapping mapping, ActionForm
form,HttpServletRequest request,HttpServletResponse response) throws
IOException, ServletException
 {

  try
  {

Document document = new Document();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter.getInstance(document, baos);
document.open();
document.add(new Paragraph("Hello World"));
document.close();

response.setContentType("application/pdf");
response.setContentLength(baos.size());
ServletOutputStream out = response.getOutputStream();
baos.writeTo(out);
out.flush();
}
catch (Exception e2)
  {
System.out.println("Error in "+getClass().getName()+"\n"+e2);
}
 return null;
 }
}

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: ActionServlet return a pdf document

2002-02-14 Thread Arun_Kumar_N



Hello,
 Here I use Itext tool to create pdf files. Its a Java library.
I use iText.jar  to generate the PDF files.










"Galbreath, Mark" <[EMAIL PROTECTED]> on 2002.02.14 17:52:38

Please respond to "Struts Users Mailing List" <[EMAIL PROTECTED]>
  
  
  
  To:  'Struts Users Mailing List'
   <[EMAIL PROTECTED]>   
  
  cc:  (bcc: Arun Kumar N/Satyam) 
  
  
                  
  Subject  RE: ActionServlet return a pdf document
  :   
  







Where did PdfWriter() come from?

Cheers!
Mark

--
Try before you cry:
http://www.mail-archive.com/struts-user%40jakarta.apache.org/


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 14, 2002 5:26 AM

file.When i try to open the PDF file I get the error as
"There was an error opening this document.Could not repair this file"

public class PDF extends Action
{
 public ActionForward perform(ActionMapping mapping, ActionForm
form,HttpServletRequest request,HttpServletResponse response) throws
IOException, ServletException
 {

  try
  {

Document document = new Document();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter.getInstance(document, baos);
document.open();
document.add(new Paragraph("Hello World"));
document.close();

response.setContentType("application/pdf");
response.setContentLength(baos.size());
ServletOutputStream out = response.getOutputStream();
baos.writeTo(out);
out.flush();
}
catch (Exception e2)
  {
System.out.println("Error in "+getClass().getName()+"\n"+e2);
}
 return null;
 }
}

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





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




RE: ActionServlet return a pdf document

2002-02-14 Thread Galbreath, Mark

Where did PdfWriter() come from?

Cheers!
Mark

--
Try before you cry:
http://www.mail-archive.com/struts-user%40jakarta.apache.org/


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 14, 2002 5:26 AM

file.When i try to open the PDF file I get the error as
"There was an error opening this document.Could not repair this file"

public class PDF extends Action
{
 public ActionForward perform(ActionMapping mapping, ActionForm
form,HttpServletRequest request,HttpServletResponse response) throws
IOException, ServletException
 {

  try
  {

Document document = new Document();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter.getInstance(document, baos);
document.open();
document.add(new Paragraph("Hello World"));
document.close();

response.setContentType("application/pdf");
response.setContentLength(baos.size());
ServletOutputStream out = response.getOutputStream();
baos.writeTo(out);
out.flush();
}
catch (Exception e2)
  {
System.out.println("Error in "+getClass().getName()+"\n"+e2);
}
 return null;
 }
}

--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: ActionServlet return a pdf document

2001-11-14 Thread Hollis, Nathan

Also, check out FOP as part of the Apache Project.  

We use it for our project here and it works great.  Free too!

-Original Message-
From: IZAGA,IGNACIO (HP-Germany,ex1) [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 14 November 2001 11:18 PM
To: 'Struts Users Mailing List'
Subject: RE: ActionServlet return a pdf document


hi,

i think that htmldoc is free of charge

http://www.easysw.com/htmldoc/faq0004.html

you could also use Html2pdf_asp 

http://128.146.118.49/pdfsamples/asp_readme.htm





-Original Message-
From: Chughtai, Imran [mailto:[EMAIL PROTECTED]]
Sent: Mittwoch, 14. November 2001 12:56
To: 'Struts Users Mailing List'
Subject: RE: ActionServlet return a pdf document


I'm looking for an HTML to PDF tool that I can run Server-side from a
Servlet. It needs to take an HTML page and create a PDF.

I checked out HTMLDOC but I don't think the command line version is free.

Are there any others available for free?


-Original Message-
From: IZAGA,IGNACIO (HP-Germany,ex1) [mailto:[EMAIL PROTECTED]]
Sent: 14 November 2001 12:01
To: '[EMAIL PROTECTED]'
Subject: ActionServlet return a pdf document



Hi,

I am trying to generate a PDF document on the fly based on dynamic html
generation comming from BroadVision.

I am using a tool called HTMLDOC that can use as input parameter a html file
or a URL.

If i used this tool directly from the command line, 

htmldoc URL -f result.pdf

then, the pdf generation is fine, includig images.


But if i called this via an action, and i get the ouput of the tool and send
it to the response, the pdf result is not displayed if i used the image tag
in the HTML.

This is the java code for my action :


Process process; 
Runtime runtime; 
java.io.InputStream input; 
byte buffer []; // Buffer for output data
int bytes; // Number of bytes

command = http://www.myfile.jsp >

runtime = Runtime.getRuntime();
   
try
{
process = runtime.exec(command);

input = process.getInputStream();
buffer = new byte[8192];

while ((bytes = input.read(buffer)) > 0)
   outputStream.write(buffer, 0, bytes);   
   
return (process.waitFor());


Any idea or suggestion ???

Thanks in advance

Regards,

ignacio




   

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

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

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

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




Re: ActionServlet return a pdf document

2001-11-14 Thread Peter Pilgrim


I am about to do a similar thing Rendered JPEG images.
Sending back binary content should be
possible from Struts Action. In the action perfrom() you return `null'
to signify that you handling the response by yourself. Generating
custom response is the same, then, as a Java Servlet.
You have to set content type. For you it would be
response.setContentType("text/pdf") or whatever the MIME type is pdf is.
Then you have to get reference to the ServlketOutputStream

ServletOutputStream out = response.getOutputStream();
Buffer it up and send your binary (PDF) stream down stream.
Dont forget to flush().

That should be it unless any body knows otherwise.
--
Peter Pilgrim ++44 (0)207-545-9923
  //_\\
"Mathematics is essentially the study of islands of  ===
disparate subjects in a sea of ignorance."   || ! ||
Andrew Wiles _


 Message History 



From: "IZAGA,IGNACIO (HP-Germany,ex1)" <[EMAIL PROTECTED]> on 14/11/2001 13:01 CET
--MCIT>


Hi,

I am trying to generate a PDF document on the fly based on dynamic html
generation comming from BroadVision.

I am using a tool called HTMLDOC that can use as input parameter a html file
or a URL.

If i used this tool directly from the command line,

htmldoc URL -f result.pdf

then, the pdf generation is fine, includig images.


But if i called this via an action, and i get the ouput of the tool and send
it to the response, the pdf result is not displayed if i used the image tag
in the HTML.

This is the java code for my action :




--

This e-mail may contain confidential and/or privileged information. If you are not the 
intended recipient (or have received this e-mail in error) please notify the sender 
immediately and destroy this e-mail. Any unauthorized copying, disclosure or 
distribution of the material in this e-mail is strictly forbidden.



--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: ActionServlet return a pdf document

2001-11-14 Thread moritz petersen

 
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

I'm quite a struts newbie, so forgive me this unqualified reply, but
isn't it possible to set the content-type of the output stream to
"application/pdf"?

Cheers,

Moritz.

> -Original Message-
> From: Balasubrahmanyam Pasumarthy [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, November 14, 2001 3:20 PM
> To: Struts Users Mailing List
> Subject: Re: ActionServlet return a pdf document
> 
> 
> Hi,
> 
> I had a similar problem with an RTF document generation on the fly.
> 
> The only thing it is working fine for Netscape but the IE is not 
> opening it 
> as word
> document because of extension it has got. ".do"
> 
> I eliminated it by introducing another mapping similar to ".do" as
> ".rtf"  in Web.xml
> 
> Hopefully you also create the similar mapping and call the action
> as  "action.pdf" instead
> of "action.do"
> 
> Balu
> 
> At 01:01 PM 11/14/01 +0100, you wrote:
> 
> >Hi,
> >
> >I am trying to generate a PDF document on the fly based on dynamic
> >html generation comming from BroadVision.
> >
> >I am using a tool called HTMLDOC that can use as input parameter 
> a html file
> >or a URL.
> >
> >If i used this tool directly from the command line,
> >
> >htmldoc URL -f result.pdf
> >
> >then, the pdf generation is fine, includig images.
> >
> >
> >But if i called this via an action, and i get the ouput of the 
> tool and send
> >it to the response, the pdf result is not displayed if i used 
> the image tag
> >in the HTML.
> >
> >This is the java code for my action :
> >
> >
> > Process process;
> > Runtime runtime;
> > java.io.InputStream input;
> > byte buffer []; // Buffer for output data
> > int bytes; // Number of bytes
> >
> > command =  > : 
> >/opt/htmldoc http://www.myfile.jsp >
> >
> > runtime = Runtime.getRuntime();
> >
> > try
> > {
> > process = runtime.exec(command);
> >
> > input = process.getInputStream();
> > buffer = new byte[8192];
> >
> > while ((bytes = input.read(buffer)) > 0)
> >outputStream.write(buffer, 0, bytes);
> >
> > return (process.waitFor());
> >
> >
> >Any idea or suggestion ???
> >
> >Thanks in advance
> >
> >Regards,
> >
> >ignacio
> >
> >
> >
> >
> >
> >
> >--
> >To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> >For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> 
> Balasubrahmanyam Pasumarthy
> **
> Sr. Consultant,
> Zensar Technologies Ltd,
> Ph: 91-20-6633001 extn 613
> ***
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> 

-BEGIN PGP SIGNATURE-
Version: PGP 7.0.4

iQA/AwUBO/KCra4aIaYbaQVBEQIDfgCg0On75otbahyY2gQowkLhDKaNiS0AnRre
rJ5foQtvq6uZn82DNiiKumV7
=cxG6
-END PGP SIGNATURE-


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




Re: ActionServlet return a pdf document

2001-11-14 Thread Balasubrahmanyam Pasumarthy

Hi,

I had a similar problem with an RTF document generation on the fly.

The only thing it is working fine for Netscape but the IE is not opening it 
as word
document because of extension it has got. ".do"

I eliminated it by introducing another mapping similar to ".do" as ".rtf" 
in Web.xml

Hopefully you also create the similar mapping and call the action as 
"action.pdf" instead
of "action.do"

Balu

At 01:01 PM 11/14/01 +0100, you wrote:

>Hi,
>
>I am trying to generate a PDF document on the fly based on dynamic html
>generation comming from BroadVision.
>
>I am using a tool called HTMLDOC that can use as input parameter a html file
>or a URL.
>
>If i used this tool directly from the command line,
>
>htmldoc URL -f result.pdf
>
>then, the pdf generation is fine, includig images.
>
>
>But if i called this via an action, and i get the ouput of the tool and send
>it to the response, the pdf result is not displayed if i used the image tag
>in the HTML.
>
>This is the java code for my action :
>
>
> Process process;
> Runtime runtime;
> java.io.InputStream input;
> byte buffer []; // Buffer for output data
> int bytes; // Number of bytes
>
> command = /opt/htmldoc http://www.myfile.jsp >
>
> runtime = Runtime.getRuntime();
>
> try
> {
> process = runtime.exec(command);
>
> input = process.getInputStream();
> buffer = new byte[8192];
>
> while ((bytes = input.read(buffer)) > 0)
>outputStream.write(buffer, 0, bytes);
>
> return (process.waitFor());
>
>
>Any idea or suggestion ???
>
>Thanks in advance
>
>Regards,
>
>ignacio
>
>
>
>
>
>
>--
>To unsubscribe, e-mail:   
>For additional commands, e-mail: 

Balasubrahmanyam Pasumarthy
**
Sr. Consultant,
Zensar Technologies Ltd,
Ph: 91-20-6633001 extn 613
***



--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: ActionServlet return a pdf document

2001-11-14 Thread IZAGA,IGNACIO (HP-Germany,ex1)

hi,

i think that htmldoc is free of charge

http://www.easysw.com/htmldoc/faq0004.html

you could also use Html2pdf_asp 

http://128.146.118.49/pdfsamples/asp_readme.htm





-Original Message-
From: Chughtai, Imran [mailto:[EMAIL PROTECTED]]
Sent: Mittwoch, 14. November 2001 12:56
To: 'Struts Users Mailing List'
Subject: RE: ActionServlet return a pdf document


I'm looking for an HTML to PDF tool that I can run Server-side from a
Servlet. It needs to take an HTML page and create a PDF.

I checked out HTMLDOC but I don't think the command line version is free.

Are there any others available for free?


-Original Message-
From: IZAGA,IGNACIO (HP-Germany,ex1) [mailto:[EMAIL PROTECTED]]
Sent: 14 November 2001 12:01
To: '[EMAIL PROTECTED]'
Subject: ActionServlet return a pdf document



Hi,

I am trying to generate a PDF document on the fly based on dynamic html
generation comming from BroadVision.

I am using a tool called HTMLDOC that can use as input parameter a html file
or a URL.

If i used this tool directly from the command line, 

htmldoc URL -f result.pdf

then, the pdf generation is fine, includig images.


But if i called this via an action, and i get the ouput of the tool and send
it to the response, the pdf result is not displayed if i used the image tag
in the HTML.

This is the java code for my action :


Process process; 
Runtime runtime; 
java.io.InputStream input; 
byte buffer []; // Buffer for output data
int bytes; // Number of bytes

command = http://www.myfile.jsp >

runtime = Runtime.getRuntime();
   
try
{
process = runtime.exec(command);

input = process.getInputStream();
buffer = new byte[8192];

while ((bytes = input.read(buffer)) > 0)
   outputStream.write(buffer, 0, bytes);   
   
return (process.waitFor());


Any idea or suggestion ???

Thanks in advance

Regards,

ignacio




   

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

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

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




RE: ActionServlet return a pdf document

2001-11-14 Thread Chughtai, Imran

I'm looking for an HTML to PDF tool that I can run Server-side from a
Servlet. It needs to take an HTML page and create a PDF.

I checked out HTMLDOC but I don't think the command line version is free.

Are there any others available for free?


-Original Message-
From: IZAGA,IGNACIO (HP-Germany,ex1) [mailto:[EMAIL PROTECTED]]
Sent: 14 November 2001 12:01
To: '[EMAIL PROTECTED]'
Subject: ActionServlet return a pdf document



Hi,

I am trying to generate a PDF document on the fly based on dynamic html
generation comming from BroadVision.

I am using a tool called HTMLDOC that can use as input parameter a html file
or a URL.

If i used this tool directly from the command line, 

htmldoc URL -f result.pdf

then, the pdf generation is fine, includig images.


But if i called this via an action, and i get the ouput of the tool and send
it to the response, the pdf result is not displayed if i used the image tag
in the HTML.

This is the java code for my action :


Process process; 
Runtime runtime; 
java.io.InputStream input; 
byte buffer []; // Buffer for output data
int bytes; // Number of bytes

command = http://www.myfile.jsp >

runtime = Runtime.getRuntime();
   
try
{
process = runtime.exec(command);

input = process.getInputStream();
buffer = new byte[8192];

while ((bytes = input.read(buffer)) > 0)
   outputStream.write(buffer, 0, bytes);   
   
return (process.waitFor());


Any idea or suggestion ???

Thanks in advance

Regards,

ignacio




   

--
To unsubscribe, e-mail:

For additional commands, e-mail:


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: ActionServlet return a pdf document

2001-11-14 Thread IZAGA,IGNACIO (HP-Germany,ex1)

Hi,

i return null for the action, i did not paste the complete code for the
action.

What do you mean by handling the output of the pdf by myself?

I don't want to save the pdf file into the file system, i want to send
directly to the response the output of the call the the tool.

ignacio



-Original Message-
From: Jens Kühnberger [mailto:[EMAIL PROTECTED]]
Sent: Mittwoch, 14. November 2001 13:09
To: Struts Users Mailing List
Subject: Re: ActionServlet return a pdf document


Just handle the output of the pdf by yourself and return null for your 
Action.

Jens


IZAGA,IGNACIO (HP-Germany,ex1) wrote:

>Hi,
>
>I am trying to generate a PDF document on the fly based on dynamic html
>generation comming from BroadVision.
>
>I am using a tool called HTMLDOC that can use as input parameter a html
file
>or a URL.
>
>If i used this tool directly from the command line, 
>
>htmldoc URL -f result.pdf
>
>then, the pdf generation is fine, includig images.
>
>
>But if i called this via an action, and i get the ouput of the tool and
send
>it to the response, the pdf result is not displayed if i used the image tag
>in the HTML.
>
>This is the java code for my action :
>
>
>Process process; 
>Runtime runtime; 
>java.io.InputStream input; 
>byte buffer []; // Buffer for output data
>int bytes; // Number of bytes
>
>command = /opt/htmldoc http://www.myfile.jsp >
>
>runtime = Runtime.getRuntime();
>   
>try
>{
>process = runtime.exec(command);
>
>input = process.getInputStream();
>buffer = new byte[8192];
>
>while ((bytes = input.read(buffer)) > 0)
>   outputStream.write(buffer, 0, bytes);   
>   
>return (process.waitFor());
>
>
>Any idea or suggestion ???
>
>Thanks in advance
>
>Regards,
>
>ignacio
>
>
>
>
>   
>
>--
>To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>



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

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




Re: ActionServlet return a pdf document

2001-11-14 Thread Jens Kühnberger

Just handle the output of the pdf by yourself and return null for your 
Action.

Jens


IZAGA,IGNACIO (HP-Germany,ex1) wrote:

>Hi,
>
>I am trying to generate a PDF document on the fly based on dynamic html
>generation comming from BroadVision.
>
>I am using a tool called HTMLDOC that can use as input parameter a html file
>or a URL.
>
>If i used this tool directly from the command line, 
>
>htmldoc URL -f result.pdf
>
>then, the pdf generation is fine, includig images.
>
>
>But if i called this via an action, and i get the ouput of the tool and send
>it to the response, the pdf result is not displayed if i used the image tag
>in the HTML.
>
>This is the java code for my action :
>
>
>Process process; 
>Runtime runtime; 
>java.io.InputStream input; 
>byte buffer []; // Buffer for output data
>int bytes; // Number of bytes
>
>command = /opt/htmldoc http://www.myfile.jsp >
>
>runtime = Runtime.getRuntime();
>   
>try
>{
>process = runtime.exec(command);
>
>input = process.getInputStream();
>buffer = new byte[8192];
>
>while ((bytes = input.read(buffer)) > 0)
>   outputStream.write(buffer, 0, bytes);   
>   
>return (process.waitFor());
>
>
>Any idea or suggestion ???
>
>Thanks in advance
>
>Regards,
>
>ignacio
>
>
>
>
>   
>
>--
>To unsubscribe, e-mail:   
>For additional commands, e-mail: 
>
>



--
To unsubscribe, e-mail:   
For additional commands, e-mail: