Writing FOP output to BLOB

Hi Experts !
i am using Apache FOP to generate PDF from xml. I am able to generate PDF file from the xml by using fol code :-
public void convertXML2PDF(File xmlfile, File xsltfile, File pdffile)
throws IOException, TransformerException {
     //OutputStream pdfout = null;
     try {
// configure fopFactory as desired
FopFactory fopFactory = FopFactory.newInstance();
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
// configure foUserAgent as desired
// Setup output
OutputStream out = new java.io.FileOutputStream(pdffile);
out = new java.io.BufferedOutputStream(out);
try {
// Construct fop with desired output format
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
// Setup XSLT
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new StreamSource(xsltfile));
// Set the value of a <param> in the stylesheet
transformer.setParameter("versionParam", "2.0");
// Setup input for XSLT transformation
Source src = new StreamSource(xmlfile);
// Resulting SAX events (the generated FO) must be piped through to FOP
Result res = new SAXResult(fop.getDefaultHandler());
// Start XSLT transformation and FOP processing
transformer.transform(src, res);
} finally {
out.close();
System.out.println("Success!");
} catch (Exception e) {
e.printStackTrace(System.err);
System.exit(-1);
this code writes the output to a file on disk. I am required to write the output to BLOB as File IO is not an option. Can someone please help me out in directing the outputstream to BLOB with no file IO.
Best Regards !

Use PreparedStatement.setBlob(int, java.io.InputStream) (with a PipedInputStream/PipedOutputStream pair if you can't get an InputStream from FOP?).
http://download.oracle.com/javase/6/docs/api/java/sql/PreparedStatement.html#setBlob(int,%20java.io.InputStream)

Similar Messages

  • What are the cases that cause the I/O error writing to output file

    may i ask what are the cases that cause the I/O error writing to output file ??
    cause i have the write path and the input file has data
    any ideas???

    and the permission is to write first time then append to itBy "permission" is meant the operating system controlled rights that let
    particular users do specified things with specified files or directories.
    the error message is a the title of the message
    I/O error writing to output fileThe java runtime actually creates a much more useful error message than
    this but, unfortunately, your program is swallowing this error message and
    replacing it with the message you see.
    Somewhere in your code you have something like:try {
        // all sorts of stuff goes here
        // including the code that is intended to
        // write to the file
    } catch(IOException ioe) {
        System.out.println("I/O error writing to output file");
            // add this line
        //ioe.printStackTrace();
    }It might say Exception rather than IOException.
    To get a much more useful error message add the commented line.

  • Store report output to blob column

    Hi,
    I would like to know whether it is possible to execute a report built using Report 10G and store its output, e.g. PDF content, onto a blob column of a table directly? If it's possible, could anyone show me an example in achieving it. Thank you.
    Regards,
    John

    Navneet,
    Thanks for the sample. I've tried setting up this custom destination and I get the following error when trying to run a report.
    REP-50125: Caught exception: java.lang.NullPointerException
    The URL that I am using is as follows:
    http://server_name:port/reports/rwservlet?report=report_name.rdf&userid=username/password@tnsname_entry&destype=BLOBdestination&desformat=PDF&DESNAME=http://username/password@host_name:port/instance/table_name/document_column_name/primary_key_column_name/10/report_desc_column_name
    Any ideas on what I've done wrong?
    Thanks
    David

  • Writing file output on arbitrary lines

    Hi,
    I'd like to know whether it is possible to select the line number on which I am writing the next output string when making a .txt or .csv file.
    Background: I am writing a survey, for which I need to record people's responses. The survey questions will be presented in random order. However, I want the text file output to show the responses in the same order for everyone.
    So if a person sees the survey questions in the order CBDAE, and replies "green" "no" "cheese" "yes" "true", I want the output file to read
    A "yes"
    B "no"
    C "green"
    D "cheese"
    E "true"
    Currently I'm using a buffered file writer to write the responses:
    BufferedWriter out = new BufferedWriter(new FileWriter("outfilename"));
    out.write(response);
    out.close();What would be the best way to change things so that I can pick which line I write to?
    Thanks!

    Hmmm... Ok. Will it it safe to assume that writing a
    couple hundred integers to a text file at once should
    be pretty safe and quick on any computer?I don't know what you mean by "safe."
    It should be fast, but fast is a very subjective and context-sensitive term. Try it and see if it's fast enough for you.

  • Cocoon-FOP Output Problem

    Hi, I'm trying to implement Carl Backstrom's Tomcat-Cocoon-FOP solution.
    I know its probably a Coccoon/FOP issue... when I click "Test Report" I get the following (see below).
    I haven't edited anything :), and i'm just trying to output one field from a table as a test (no empty fields).
    Oh ya... and the PDF that won't display?? ...Is actually HTML output.
    Is there a hidden problem of stream definition/assignment/error handling lurking in the background as well?
    Anybody seen this one before?
    javax.xml.transform.TransformerException: attribute-set named #TEXT_ALIGN# does not exist
    cocoon://fop_post/xsl - 148:58
    Cocoon stacktrace[hide]
    attribute-set named #TEXT_ALIGN# does not exist
    cocoon://fop_post/xsl - 148:58     
    Exception in StreamGenerator.generate()
    cocoon://fop_post/xsl - 148:58     [TransformerException]
    file:/C:/apex_fop/apache-tomcat-6.0.14/webapps/cocoon/fop_post/sitemap.xmap - 10:32      <map:serialize type="xml">
    file:/C:/apex_fop/apache-tomcat-6.0.14/webapps/cocoon/fop_post/sitemap.xmap - 6:33 <map:generate type="stream">
    file:/C:/apex_fop/apache-tomcat-6.0.14/webapps/cocoon/fop_post/sitemap.xmap - 38:37  <map:serialize type="fo2pdf">
    file:/C:/apex_fop/apache-tomcat-6.0.14/webapps/cocoon/fop_post/sitemap.xmap - 31:39  <map:transform>
    file:/C:/apex_fop/apache-tomcat-6.0.14/webapps/cocoon/fop_post/sitemap.xmap - 30:38  <map:generate>
    file:/C:/apex_fop/apache-tomcat-6.0.14/webapps/cocoon/sitemap.xmap - 1034:92 <map:mount>

    Ok then... paying attention always works doesn't it? As he takes another (closer) at the tutorial video... :)
    I've been trying to do a test report via:
    Home > Application Builder > Application # > Shared Components > Report Queries
    ...and I get the above error. But when I plug it into an for real app it works like magic. Kool, PDF's to die for! Thanx.
    Bit of a problem with printing to Word docs tho...
    Word says "Missing file: C:\cocoon\styles\main.css", and a bunch of the usual bafflegab.
    Am looking for the reference to "c:\cocoon\..." to figure out how to change it, but haven't found it yet.

  • Problem writing to output using servlet

    Hi All,
    I created a servlet which reads file and writes to output . This works fine
    when request protocol is http . But if protocol is changed to https servlet doesnt write to output. This servlet is deployed in secure environment as EAR project .But pops up error in popup
    Internet explorer cannot download /ImageServlet/.... from the server....
    requested site is unavailable.
    Here is my servlet code
                        String key = request.getParameter("key");
                        if( key != null){
                             String[] keys = key.split(":");
                             System.out.println("request.getAuthType() :"+ request.getAuthType());
                             if(request.getAuthType() != null){
                             if(keys != null && keys.length >1){
                                  ImageUtil imageUtil = new ImageUtil();
                                  byte[] bytes = imageUtil.getDocumentContent(keys[0]);
                                  ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
                                  BufferedInputStream bis = new BufferedInputStream(bais);
                                  ServletOutputStream out = response.getOutputStream();
                                  BufferedOutputStream bos = new BufferedOutputStream(out);
                                  response.reset();
                                  if(keys[1].equalsIgnoreCase("doc") ) {
                                       response.setContentType("application/msword;charset=utf-8");
                                       response.setHeader("Content-Disposition","inline;filename=\"file.doc\";");
                                  }else if(keys[1].equalsIgnoreCase("xls") ) {
                                       response.setContentType("application/vnd.ms-excel");
                                       response.setHeader("Content-Disposition","inline;filename=\"file.xls\";");
                                  }else if(keys[1].equalsIgnoreCase("rtf") ){
                                       response.setContentType("application/msword");
                                       response.setHeader("Content-Disposition","inline;filename=\"file.rtf\";");                         
                                  }else if(keys[1].equalsIgnoreCase("html") || keys[1].equalsIgnoreCase("htm")){
                                       response.setContentType("text/html");
                                       response.setHeader("Content-Disposition","inline;filename=\"file.html\";");                         
                                  }else if(keys[1].equalsIgnoreCase("txt")){
                                       response.setContentType("text/plain");
                                       response.setHeader("Content-Disposition","inline;filename=\"file.txt\";");                         
                                  //setting some response headers
                                  response.setHeader("Cache-Control","no-store, no-cache, must-revalidate,post-check=0, pre-check=0"); //HTTP 1.1
                                  response.setHeader("Pragma","no-cache"); //HTTP 1.0
                                  response.setDateHeader ("Expires", 0);
                             int i;
                             while ( (i = bis.read(bytes)) > 0)
                                  bos.write(bytes,0,i);
                             bos.flush();               
                             bos.close();
                             bis.close();
                             bais.close();
                             System.out.println("Has written");
                             }else{
                                  log.error("Key is not good.");
                   }else{
                        log.error("Please enter key for streaming.");
              }catch(Exception e)     {
    log.error(e.toString());
    e.printStackTrace();
    In web.xml
         <servlet>
              <servlet-name>ImageServlet</servlet-name>
              <servlet-class>
                   com.pfpc.opdesktop.image.servlet.ImageServlet
              </servlet-class>
         </servlet>     
         <servlet-mapping>
         <servlet-name>ImageServlet</servlet-name>
         <url-pattern>/ImageServlet/*</url-pattern>
         </servlet-mapping>
         <security-constraint>
              <display-name>ImageServlet</display-name>
              <web-resource-collection>
                   <web-resource-name>ImageServlet</web-resource-name>
                   <description>ImageServlet</description>
                   <url-pattern>/ImageServlet/*</url-pattern>
                   <http-method>GET</http-method>
                   <http-method>POST</http-method>
                   <http-method>OPTIONS</http-method>
              </web-resource-collection>
              <auth-constraint>
                   <description>ImageServlet</description>
                   <role-name>ImageServlet</role-name>
              </auth-constraint>
              <user-data-constraint>
                   <transport-guarantee>NONE</transport-guarantee>
              </user-data-constraint>
         </security-constraint>
              <security-role>
              <description>ImageServlet - OpDesktopWAR</description>
              <role-name>ImageServlet</role-name>
         </security-role>
    In application.xml
         <security-role id="SecurityRole_1164052833984">
              <description>ImageServlet - OpDesktopWAR</description>
              <role-name>ImageServlet</role-name>
         </security-role>
    Can anyone please tell me what is problem.very urgent.
    Thankyou

    Hi,
    Found the solution for the problem. For some reason
    response.setHeader("Cache-Control","no-store, no-cache, must-revalidate,post-check=0, pre-check=0"); //HTTP 1.1
                                  response.setHeader("Pragma","no-cache"); //HTTP 1.0
                                  response.setDateHeader ("Expires", 0);
    These header settings were causing this issue. If I take out these settings then it works
    FYI
    Thankyou very much for all help

  • Writing smartform output in application server

    Hi,
    i have a smartform output having logo and other details. After this i am converting the smartform output to PDF file and i tried write into application server using Open Dataset, Close Dataset. The thing is i am unable to see the output in pdf file and when i tried to open am getting some error. Is there any way to write pdf file which having logo into application server.
    please guide me.

    what mode did you use in th open dataset statement?
    You should use BIN mode in open dataset statement.
    Regards,
    Ravi

  • Writing smartform output into application server.

    Hi,
    i have a smartform output having logo and other details. After this i am converting the smartform output to PDF file and i tried write into application server using Open Dataset, Close Dataset. The thing is i am unable to see the output in pdf file and when i tried to open am getting some error. Is there any way to write pdf file which having logo into application server.
    i tried for both binary mode as well as for text mode of open dataset.
    please guide me.

    Hi Subas.
    I would like to suggest a couple of references,
    [SDN - Reference for Issue regarding the uploading the pdf file to the application server|regarding the uploading the pdf file to the application server;
    Hope that's usefull.
    Good Luck & Regards.
    Harsh Dave

  • Writing console output from numerous classes to JTextArea?

    I have written a GUI for several classs and I was wondering if it is possible to have the output from these classes written to something like a JTextArea or equivalent.
    I know I could store the output (instead of System.out.print) and then setup a JTextArea and set the text equal to the stored output. I was hoping there was another way to do this that'd be more aesthetic.
    Thanks in advance.
    Se�n

    I have written a GUI for several classs and I was
    wondering if it is possible to have the output from
    these classes written to something like a JTextArea
    or equivalent.
    I know I could store the output (instead of
    System.out.print) and then setup a JTextArea and set
    the text equal to the stored output. I was hoping
    there was another way to do this that'd be more
    aesthetic.
    java.util.logging?Alternatively, create a TextAreaPrintStream class, overriding the appropriate methods and then call
    System.setOut(someTextAreaPrintStream);Jim S.

  • Writing JavaFX output to videofile

    Hi, I have some interesting question to you. Is there a way to write JavaFX application's frame output to videofile even if the application is minimized?

    I haven't been able to play with JavaFX 2.0 thus far since I am a Linux user, but I have read that JavaFX 2.0 is using an entirely new windowing system called "Glass". There shouldn't be a JFrame to retrieve anything from. The only hack thus far developed to retrieve an image from a JavaFX scene is described here: Image conversion between AWT and FX
    I don't think that hack is compatible with a JavaFX window.

  • Questions about reading/writing with output and input streams

    I'm getting a bit confused on this subject. I have written an array of doubles to a file, and now I need to know how to read them back in to another array. I have also wrapped each double into its own object, but I need to know how to write those to a file, and read the doubles contained in them back into an array.
    Here is what I have so far; the method that writes the array of doubles to a file.
    public void writePrimDoubles() {
              DataOutputStream outStream;
              System.out.println("Now writing the values to file...");
              try     {               
                   outStream = new DataOutputStream(new FileOutputStream("file.dat"));
              catch (IOException ex) {
                   System.out.println("Error opening file");
              return;
              try {
                   for(int i = 0; i<arraySize; i++)
                        outStream.writeBytes(numberArray[i] + "\n");
                   outStream.close();
              catch(IOException e) {
                   System.out.println("Error writing to file");
         }

    * writes all doubles in the given array to the file 'file.dat'
    public void writePrimDoubles(double[] array) throws IOException {
       DataOutputStream out = new DataOutputStream(new FileOutputStream("file.dat"));
       for(int i=0; i<array.length; i++) {
          out.writeDouble(array);
    out.close();
    * reads in all stored doubles from the given file ('file.dat').
    * cause of each double has been written to a 8byte part of the file
    * you could get the number of doubles stored in the file by dividing
    * its filesize by 8.
    * Alternatively you might first store all read doubles as Double in
    * a list (e.g. java.util.ArrayList). After reading all doubles you could then
    * create a new double[] with the lists size (double[] array = new double[list.size()];)
    * -> this alternative is commented out in the following code.
    public double[] readPrimDoubles() throws IOException {
    File file = new File("file.dat");
    DataInputStream in = new DataInputStream(new FileInputStream(file));
    double[] array = new double[file.length()/8];
    for(int i=0; i<array.length; i++) {
    array[i] = in.readDouble();
    in.close();
    return array;
    ArrayList list = new ArrayList();
    try {
    while(true) {
    list.add(new Double(in.readDouble()));
    catch(EOFException e) {} // catchs the exception thrown when end of file is reached
    in.close();
    double[] array = new double[list.size()];
    for(int i=0; i<list.size(); i++) {
    array[i] = ((Double)list.get(i)).doubleValue();
    return array;
    For further information on the classes you have to use you might have a look to the concerning API documentation (http://java.sun.com/j2se/1.4.2/docs/api/). In this docs you could find all methods, constructors and fields accessable for a class.
    have fun...

  • Regarding  writing  the output

    Hi All,
    I have the input value in a string fromat '12345'.
    I wanted it to  display as
    output>>
    1
    2
    3
    4
    5
    but if at all i give the input as' 1 2 3  4  5'.
    tehn i ma able to get it .. but his is not the r eqt...
    pls suggest em ASAP..
    Thanks in Advance.

    hi..
    try dis...
    data str(5) TYPE c.
    data str1(1) type c.
    data k TYPE i.
    str = '12345'.
    data b TYPE i.
    data a type i.
    b = STRLEN( str ).
    k = 0.
    WHILE a lt b.
    str1 = str+a(1).
    write:/ str1.
    a = a + 1.
    ENDWHILE.
    outtput is same as u want.
    Message was edited by:
            abapuser

  • Writing and outputing from txt file

    Hello guys,
    Can you guys show me where I can find the source of learning how to writing and getting the data that I input to the text file?
    Thanks.

    The java tutorial of course!
    http://java.sun.com/docs/books/tutorial/index.html
    The section about I/O is:
    http://java.sun.com/docs/books/tutorial/essential/io/index.html

  • Writing Analog Output

    Hi,
    I am now actually at the part in my program where i'm going to output some data to adjust mirrors for the positioning of a laser dot. I just want to know if i am doing the right way... I use the example in the example finder Voltage (non-regeneration) Continuous Output.
    I have some files with many samples more then 1.000.000 samples (patterns for the laser dot) and want to output them in parts (1024 samples at one loop cycle), but also want to be able to push on Pause when it has to hold. So is this the right way then? 
    Best regards,
    Thijs
    Solved!
    Go to Solution.

    The VI which i am going to use is the one in the Example finder... but my only question is, is that the right one for the job... I haven't write any VI for the data generation yet...
    So is this the right way? Or is there a cleaner way to do this, i don't like the part with the case and the "first call" vi in front of it... but some how you have to start the generation after the DAQmx write... i find that odd and then repeat the write DAQmx after the start...
    Best regards,
    Thijs

  • How can i run my vi writing its output in Excel in a real time?

    My vi is open and excel is open while my vi is inserting the data in excel.
    Thank You
    (can i have a simple example?)

    Are you running LabVIEW or LabVIEW Real-Time?
    To write data from LabVIEW to Excel, you can either use Write to Spreadsheet VI from the File I/O palette, or use activeX technology. Additionally, if you have the Report Generation Toolkit you could create Excel reports with LabVIEW.
    Here are some links that should help you.
    Writing Rows to Excel 97 and Excel 2000 Using ActiveX
    Creating a Report in Microsoft Excel Using the LabVIEW Report Generation Toolkit: Introduct
    ion
    Zvezdana S.

Maybe you are looking for

  • Open vi reference sub-VI problem

    Hi, I am trying to make a splash-screen front to one of my applications. I use the scheme in the attachments. It works well when in development mode, but when I create an executable, I get the error attached. It seems that the executable can't find s

  • New contract account for every line item in subscription order....

    Hi Guys, I am having a problem with the subscription order. Whenever I change the subscription order and add a line item to it, SAP by default  creates a new contract account for that line item. Whereas I want to assign the same contract account to t

  • Procure to Pay reports

    Dear all, Could you please let me know the standard reports available in Procure to Pay module. Thanks. Best regards, Venkat

  • Report painter: Can I do this report?

    hi, I want to make a report for library 8a2.  I want to use characteristic "Profit Center" for "General data selection" and I want to use the same "Profit Center"  in the  rows to distribute by "Profit Center"  and "Account number". Example: First se

  • CS 4 Upgrade Setup fails

    I am trying to upgrade CS4 Standard from CS3. The download seems to have worked fine. Once I run setup, It accepts my serial number and the install begins after about a minute it seems to stop. The install button is highlighted. Clicking the install