Re: Anything wrong with this code

2001-09-26 Thread Semprini Davide



Hi,

01c701c145fd$006f6f70$[EMAIL PROTECTED]">
  
  When the PDF data is sent back to my client.
 Am I suppose to tell my client
  (IE6) that this is a PDF file (or a stream).
 I do set response.contentType to 
  "application/pdf". 
  
This is an information that you send correctly to the client setting contentType()
with this code:
  
  response.setContentType("application/pdf");
  01c701c145fd$006f6f70$[EMAIL PROTECTED]">
Am I suppose to do  something else?

what do you want to do?

D.Semprini
01c701c145fd$006f6f70$[EMAIL PROTECTED]">
  
  Carmelo
  
  
  

- Original Message - 

From:
Semprini Davide


To:
[EMAIL PROTECTED]


Sent: Tuesday, September 25, 2001 3:51AM

Subject: Re: Anything wrong with thiscode


Hi,

PDF file is a binary file!!!
Use this code it'swork:

byte[] content = outPDF.toByteArray();
response.setContentLength(content.length);
response.getOutputStream().write(content);
response.getOutputStream().flush(); 

D.Semprini


CarmeloMontanez wrote:
02be01c1452d$7953e270$[EMAIL PROTECTED]" type="cite">
  
  
  Hi All:
  
  I know that my browser can
 display PDF propertly now, however the following
  piece of code (that generates
PDF data) sends  the data back to the client 
  (IE6) and still does not not
looks like  PDF at all. Can someone please tell me
  if there is something wrong with
this  code. By the way
  (out = response.getOutputStream()
and "foFile"  comes from an "FO" file).
  
  
  
   public void  renderFO(InputSource
foFile, HttpServletResponse  response)
 throws  IOException
 {
 try  {
 ByteArrayOutputStream outPDF  = new ByteArrayOutputStream();
  response.setContentType("application/pdf");
  
 Driver driver =  new Driver(foFile,  outPDF);
  driver.setRenderer(Driver.RENDER_PDF);
  driver.setOutputStream(outPDF);
  driver.run();
  
   byte[] content 
=  outPDF.toByteArray();
  response.setContentLength(content.length);
  out.write(content);
  out.flush();
 }  
 catch (Exception ex)  {
  System.out.println(ex);
 }
   
  Thanks,
  Carmelo Montanez
  
  Carmelo Montanez
NIST Stop  8970
Gaithersburg, MD 20899
  
  
[EMAIL PROTECTED]
  
  
  
  
  
  
  
  
  


Re: Anything wrong with this code

2001-09-25 Thread Semprini Davide



Hi,

PDF file is a binary file!!!
Use this code it's work:

byte[] content = outPDF.toByteArray();
 response.setContentLength(content.length);
 response.getOutputStream().write(content);
 response.getOutputStream().flush(); 

D.Semprini


Carmelo Montanez wrote:
02be01c1452d$7953e270$[EMAIL PROTECTED]">
  
  
  Hi All:
  
  I know that my browser can  display
PDF propertly now, however the following
  piece of code (that generates PDF data)
sends the  data back to the client 
  (IE6) and still does not not looks like
PDF  at all. Can someone please tell me
  if there is something wrong with this
code.  By the way
  (out = response.getOutputStream() and
"foFile"  comes from an "FO" file).
  
  
  
   public void renderFO(InputSource  foFile,
HttpServletResponse response)
 throws  IOException
 {
 try  {
 ByteArrayOutputStream outPDF =  new ByteArrayOutputStream();
  response.setContentType("application/pdf");
  
 Driver driver = new  Driver(foFile,  outPDF);
  driver.setRenderer(Driver.RENDER_PDF);
  driver.setOutputStream(outPDF);
  driver.run();
  
   byte[] content =  outPDF.toByteArray();
  response.setContentLength(content.length);
  out.write(content);
  out.flush();
 }  
 catch (Exception ex)  {
  System.out.println(ex);
 }
   
  Thanks,
  Carmelo Montanez
  
  Carmelo Montanez
NIST Stop 8970
Gaithersburg,  MD 20899
  
  [EMAIL PROTECTED]
  
  
  
  
  
  


Same servlet problem

2001-09-24 Thread Semprini Davide



Hi at All,

I have encountered the same problem of
Carmelo, I have a JSP Page that generate
dinamically PDF file getting input XML Dynamic and urlXSL!
My jsp generate correctly with FOP 0.20.1 a PDF file
but when I'm trying to open it M.IE visualize me
(the pdf) like a object ActiveX on left top page!

Please can something help me?


tanks in advance 




Rajagopal. V wrote:
[EMAIL PROTECTED]">
  Its a IE bug. Look at the msdn.microsoft.com for howto open PDFs from IE. IE expects ur command line toend with a .pdf so that it will opn the PDF. I couldnot find a solution ot the problem.--- Carmelo Montanez [EMAIL PROTECTED] wrote:
  
Thanks!!!Actually I changed the servlet to use the"getOutputStream()" and it worksfine evenfor non-binary data.  My new problem is the IE6 donot properly displays thePDF data, I get what seems to be PDF internal stuff(what you will see ifyou try to edit a PDF file in an editor).  I thinkIE6 should be able toreadPDF data correctly.  Anyone aware of any details Ineed to set?Carmelo

-

  To unsubscribe, e-mail:[EMAIL PROTECTED]For additional commands, email:[EMAIL PROTECTED]
  
  __Do You Yahoo!?Get email alerts  NEW webcam video instant messaging with Yahoo! Messenger. http://im.yahoo.com-To unsubscribe, e-mail: [EMAIL PROTECTED]For additional commands, email: [EMAIL PROTECTED]
  
  
  
  


Re: FOP WARNING

2001-09-24 Thread Semprini Davide



Hi,

I want explain that the error:
WARNING: Unknown formatting object ^root
for me is locate in stylesheet
Instead the error that 
Ihave encountered it was on my XML
I think that the parser didn't know my element root!
For this reason I haven't used the code in fop home
and I have perform first the transformation
and then the driver

Bye

D.Semprini











Semprini Davide wrote:
[EMAIL PROTECTED]">   Hi,
  
 I have had the same problem
 Nobody give me a response! 
  
 This code in FOP Home page don't work (for me!) !
  Driver driver = new Driver();  driver.setRenderer(Driver.RENDER_PDF);  InputHandler inputHandler = new XSLTInputHandler(xmlFile, xslFile);  XMLReader parser = inputHandler.getParser();  driver.setOutputStream(new FileOutputStream(outFile));  driver.render(parser, inputHandler.getInputSource());
  
 I have solved the problem using 2 phase:
  
 1) generate the transformation using XSLTrasform, Xalan1Transform etc... 
(you can choose)
 code:
  
 XSLTransform traXSLT = new XSLTransform();
 traXSLT.transform(urlXML, urlXSL, urlFoFile);
  
 You can choose 4 transform type (see the api documentation)
  
 2) Apply the result at the driver
  
 FileInputStream file = new FileInputStream(urlFoFile);
  
  response.setContentType("application/pdf");
  
  Driver driver = new Driver(new InputSource(file), out);
  driver.setRenderer(Driver.RENDER_PDF);
  driver.run();
  byte[] content = out.toByteArray();
  response.setContentLength(content.length);
  response.getOutputStream().write(content);
  response.getOutputStream().flush();
  
 THIS CODE WORK FINE!!!
  
 Bye
  
 
  
 Amit wrote:
  [EMAIL PROTECTED]">
I am trying to generate PDFs using FOP-0.20.1. The input files are xmland xsl filesI am using JRun3.0 with java1.2.2Here is the error I getWARNING: Unknown formatting object ^rootAnybody any ideas?-To unsubscribe, e-mail: [EMAIL PROTECTED]For additional commands, email: [EMAIL PROTECTED]








Re: FOP WARNING

2001-09-24 Thread Semprini Davide



Okay,

The example that I give is only to explain
that you can perform the PDF in two distinc phase
1) perform a trasformation 
2) use driver

You can use the "tranform method" 
with input like Dynamic xml (Dom Document) or urlXML 
and getting out a fo (Dom Document) or Writer object
YOU HAVE A LOT OF TRANSFORM TO USE!!
YOU HAVE TO SEE THE APIDOC FOR THE
COMPLETE DOCUMENTATION

For example in my project I use
xalan transform and with some
conversion I use the Fop driver
and my XML is dynamic.
WITH Transformer XALAN: 
StringWriter SstringWriter = new StringWriter();
/* this is the fo file */
StreamResult SstreamResult = new StreamResult(SstringWriter);

transformer.transform(SstreamSourceXML, SstreamResult)

/* convert the fo file in a right format for driver
ByteArrayOutputStream outPDF = new ByteArrayOutputStream();
SResult = SstringWriter.toString(); 
ByteArrayInputStream str = new ByteArrayInputStream(SResult.getBytes());
 
Driver driver = new Driver(new InputSource(str), outPDF);


Is this performance? I think yes!!

Bye
 

Amit wrote:
[EMAIL PROTECTED]"> Looking at
your code I am guessing that you wrote the fo file out to the filesystem
and then used the driver to convert it to PDF...how is performance on that? 
  
Instead of writing the file out to the file system did you try converting 
into some sorta stream and use the driver?? 
  thanks for your help 
Amit 
  Semprini Davide wrote: 
  Hi, 
I have had the same problem 
Nobody give me a response! 
This code in FOP Home page don't work (for me!) ! 
Driver driver = new Driver(); driver.setRenderer(Driver.RENDER_PDF); InputHandler inputHandler = new XSLTInputHandler(xmlFile, xslFile); XMLReader parser = inputHandler.getParser(); driver.setOutputStream(new FileOutputStream(outFile)); driver.render(parser, inputHandler.getInputSource());

I have solved the problem using 2 phase: 
1) generate the transformation using XSLTrasform, Xalan1Transform
etc... (you can choose) 
code: 
XSLTransform traXSLT = new XSLTransform(); 
traXSLT.transform(urlXML, urlXSL, urlFoFile); 
You can choose 4 transform type (see the api documentation) 
2) Apply the result at the driver 
FileInputStream file = new FileInputStream(urlFoFile); 
 response.setContentType("application/pdf"); 
 Driver driver = new Driver(new InputSource(file), out); 
 driver.setRenderer(Driver.RENDER_PDF); 
 driver.run(); 
 byte[] content = out.toByteArray(); 
 response.setContentLength(content.length); 
 response.getOutputStream().write(content); 
 response.getOutputStream().flush(); 
THIS CODE WORK FINE!!! 
Bye 
 
 
Amit wrote: 
[EMAIL PROTECTED]">
  I am trying to generate PDFs using FOP-0.20.1. The input files are xmland xsl filesI am using JRun3.0 with java1.2.2Here is the error I getWARNING: Unknown formatting object ^rootAnybody any ideas?-To unsubscribe, e-mail: [EMAIL PROTECTED]For additional commands, email: [EMAIL PROTECTED]
  
  
  
  
  
  


HELP - PASSING PARAMETER

2001-09-21 Thread Semprini Davide

Hi at all,

I have two important question:

1) I have a jsp page that call a java function of my external class.
I pass at this object dynamic xml and stylesheet xsl
and then I have to pass some parameter at my stylesheet
that are stored in HttpSession object.
If I use XSLTransform from fop there isn't
a possibility passing parameter! Is this True??
I have utilized instead of it the class: javax.xml.transform.Transformer
With this class I can pass parameter to stylesheet and perform the 
transformation
getting out InputSource that I pass at Driver.

2) When the render process end in my JSP
return ByteArrayOutputStream that I convert
setting the contentType:

1) response.setContentType(application/pdf);
2) ByteArrayOutputStream ris_pdf = ((XMLTransform) 
request.getAttribute(XMLTransform)).processXML_PDF(abs_path, 
(ParamXSL[]) request.getAttribute(ParamXSL), formato);
  
 
   3) byte[] content = ris_pdf.toByteArray();
4) response.setContentLength(content.length);
5) response.getOutputStream().write(content);
6) response.getOutputStream().flush(); 

At this point appear the browser form that call
me If I want to save or open the result
why if I have set the content type?? and If I choose
acrobat I can view the PDF File!

(I use Struts and the file my output file is called ListaFacolta.do)


 


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




Generating PDF on Fly

2001-09-21 Thread Semprini Davide

Hi,

I have a question:

Is possible to generate and VISUALIZE
with a common Browser with Acrobat Reader plug-in
a PDF using a JSP that take in input a Dynamic XML?

Tanks!

D.Semprini




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




help please Problem with generation PDF

2001-09-14 Thread Semprini Davide

Hi,

I have witten a Servlet that take two file in input (file.xml and file.xsl)
my code is:

 Driver driver = new Driver();
 driver.setRenderer(Driver.RENDER_PDF);
 File xmlFile = new File(c:\\xml_to_pdf.xml);
 File xslFile = new File(c:\\TransformPDF.xsl);   
 InputHandler inputHandler = new 
XSLTInputHandler(xmlFile,xslFile);   
 XMLReader parser=createParser();
 driver.setOutputStream(new FileOutputStream(outFile.pdf));
 driver.render(parser, inputHandler.getInputSource());
  
and my servlet have a block inside Method render( )
The parser is instantiated correctly I think that there is a problem
in the way that i pass the Files!!  TOMCAT REPLY ME:

building formatting object tree
setting up fonts
WARNING: Unknown formatting object ^val

 and then an error inside driven.render()

my xml is very simple like this:
?xml version=1.0 encoding=UTF-8?
val
titleProva di PDF/title
sourceSorgente/source
date13-09-01/date
paragraph number=1
lineQuesta e' una prova di creazione di PDF utilizzando i tag 
XSL-FO/line
/paragraph
/val

WHY the transform don't know my root element!

Please can somebody help me??

Tanks a lot

D.Semprini



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