All,

Sorry, mentioned the wrong transformer earlier. Used stream generator,
posted xml, saved to file. See code below.

JAVA CLASS:
            URL url = new URL("http://path/xml2pdf.pdf";);
            HttpURLConnection httpConn = null;
            try {
                httpConn = (HttpURLConnection)url.openConnection();
                httpConn.setDoInput(true);
                httpConn.setDoOutput(true);
                httpConn.setRequestMethod("POST");
                httpConn.setUseCaches(false);
                httpConn.setDefaultUseCaches(false);
 
httpConn.setRequestProperty("content-type","application/x-www-form-urlen
coded");
 
httpConn.setRequestProperty("content-length",String.valueOf(xml_os.size(
)));
                PrintWriter pw = new
PrintWriter(httpConn.getOutputStream());
                String content = "Foo=" + URLEncoder.encode(new
String(xml_os.toByteArray()),"UTF-8");
                pw.println(content);
                pw.close();

                InputStream is = httpConn.getInputStream();
                BufferedInputStream bis = new BufferedInputStream(is);
                byte[] buff = new byte[512];
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                String line = null;
                int len = 0;
                while( (len=bis.read(buff)) != -1) {
                    bos.write(buff, 0, len);
                }
                bis.close();
                String fileName = "out.pdf";
                FileOutputStream fos = null;
                File file = null;
                try {
                    file = new File(fileName);
                    fos = new FileOutputStream(file);
                    fos.write(bos.toByteArray());
                } catch (IOException ioe) {
                    System.out.println("Exception Caught: Creating .pdf
File");
                    ioe.printStackTrace();
                } finally {
                    if (fos!=null) {
                        fos.close();
                    }
                }
                System.out.println("***** FILE CREATED: "+fileName+"
*****");

SITEMAP.XMAP :
        <map:match pattern="*.pdf">
        <map:generate type="stream">
            <map:parameter name="form-name" value="Foo"/>
        </map:generate>
        <map:transform type="xslt" src="doc2pdf.xsl"/>
        <map:serialize type="fo2pdf"/>
      </map:match>


-----Original Message-----
From: Derek Hohls [mailto:[EMAIL PROTECTED]] 
Sent: Friday, August 16, 2002 1:50 AM
To: [EMAIL PROTECTED]
Subject: RE: Can cocoon write pdf to a file?


Can you supply a link to this discussion/anwer?

>>> [EMAIL PROTECTED] 16/08/2002 12:20:57 >>>
This has been answered in the archives.
I used the pdf transformer and saved the output stream to a file.
 
TA
-----Original Message-----
From: Geoff Howard [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, August 15, 2002 2:07 PM
To: '[EMAIL PROTECTED]' 
Subject: RE: Can cocoon write pdf to a file?


you should check the archives - i'm pretty sure this has been answered a
lot.  Think you'll want SourceWritingTransformer from Cocoon 2.1 dev
(cvs check out from HEAD)
 
Geoff
-----Original Message-----
From: kyle koss [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, August 15, 2002 1:54 PM
To: [EMAIL PROTECTED] 
Subject: Can cocoon write pdf to a file?


Is it possible for Cocoon to do an XML+XSL -> PDF transformation, but
instead of serving the PDF into the browser, writing it to a file?
 
What I would like to do is, take information entered into a form on a
jsp page, turn it into an XML file, and then apply my XSL to it to
produce a PDF which is then stored to disk on the server.
 
Can this be done using Cocoon, or would it be easier to just use FOP
embedded in a servlet? If it can be done, what do I have to do?
 
Regards, Kyle Koss

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

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






---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

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

Reply via email to