[XSQL] Displaying PDF stored in database as BLOB

Dear Sirs,
we have PDF stored in the database as BLOB.
I have written a PLSQL function which I call accordingly
<xsql:ref-cursor-function >
digitallibrary.getdocs('{@resource_seqid}')
</xsql:ref-cursor-function>
however what I get is the following
<page>
<rowset>
<row num="1">
<document>255044462D312E320A...</document>
</row>
</rowset>
</page>
instead of having the customer's browser starting up Acrobat.
It looks to me as if the data is the HEX of the BLOB:
25 %
50 P
44 D
46 F
2D -
31 1
2E .
32 2
0A Line Feed
This coincides with what previously reported
"BLOB data is serialized as hex bytes in XSU."
I understand that "XSQL has no built-in support for BLOB data, but it is extensible via user-written action handlers or user-written serializers."
I have the feeling that I should use an appropriate serializer for this purpose but it is not entirely clear to me how ...
Any suggestion is appreciated.
Looking forward your advice.
Regards and thanks
Luca

The following serializer
public void serialize(Document document, XSQLPageRequest xsqlpagerequest) throws java.lang.Throwable {
NodeList nodelist=document.getElementsByTagName("*");
xsqlpagerequest.setContentType("application/pdf");
OutputStream outputstream=xsqlpagerequest.getOutputStream();
String DocString = new String();
for (int loopIndex=0; loopIndex<=10; loopIndex++) {
display(nodelist.item(loopIndex),"");
if (loopIndex == 6 ) { DocString=displayStrings[loopIndex];}
byte abyte0[] = oracle.xml.sql.core.OracleXMLConvert.convertHexStringToByte(DocString);
outputstream.write(abyte0, 0, abyte0.length);
outputstream.flush();
works fine however the Internet Explorer 5.5 displays the native PDF code instead of firing the plugin... any suggestion ?

Similar Messages

  • Display PDF stored in database

    A page has a region of type “PL/SQL Procedure (anonymous block)” and the following region source:
    BEGIN
    get_image(3660);
    END;
    The code for the Get_Image procedure is shown below. This procedure extracts PDF images from a BLOB column in the database.
    When the page is executed, a popup window with the title “File Download” appears and the user is asked whether to open or save the file. If the user chooses to open the file, another popup window appears in which the user is asked to select the program to be used to open the file. If the user selects Acrobat Reader, the PDF image is displayed correctly. How can the image be displayed without any user intervention?
    The get_image procedure is as follows:
    PROCEDURE get_image (id_in IN NUMBER) IS
    vblob BLOB;
    buf RAW(32000);
    buf_size INTEGER := 32000;
    offset INTEGER := 1;
    len NUMBER;
    mime_type VARCHAR2(30);
    BEGIN
    -- get image_data and its mime type from the database
    SELECT image,image_type
    INTO vblob,mime_type
    FROM payslip_archive_local
    WHERE id=id_in;
    owa_util.mime_header(mime_type, false);
    owa_util.http_header_close;
    wpg_docload.download_file(vblob);
    -- set the mime type for the http protocol
    owa_util.mime_header(mime_type);
    -- read the data with htp package
    len:=dbms_lob.getlength(vblob);
    WHILE offset < len
    LOOP
    dbms_lob.read(vblob,buf_size,offset,buf);
    htp.prn(utl_raw.cast_to_varchar2(buf));
    offset:=offset+buf_size;
    END LOOP;
    -- check for exception
    EXCEPTION
    WHEN OTHERS THEN
    htp.p(SQLCODE || SQLERRM);
    END get_image;
    Vincent

    Hi,
    Forms can only show binary formats that are wrapped as OLE components and we discourage using this because OLE wont work on teh web, which is the only runtime available for Forms 9i and above.
    I suggest writing a Java Servlet that streams the document from the database to the local client
    Frank

  • Problem displaying PDF stored in BLOB column

    Hello everyone.
    I've been trying to follow this tutorial http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::p11_question_id:232814159006 on displaying PDFs stored in BLOB columns. This is being performed on Apex 4.2, with my DB running 11g. I've got my procedure, which I'll post below:
    create or replace procedure "PDF" (p_id IN gvo_documents.doc_id%type)
    is
        l_lob    blob;
        l_amt    number default 30;
        l_off   number default 1;
        l_raw   raw(4096);
    begin
        select contents into l_lob
            from gvo_documents
             where doc_id = p_id;
    -- make sure to change this for your type!
        owa_util.mime_header( 'application/pdf' );
        begin
            loop
              dbms_lob.read( l_lob, l_amt, l_off, l_raw );
              htp.prn( utl_raw.cast_to_varchar2( l_raw ) );
              l_off := l_off+l_amt;
              l_amt := 4096;           
        end loop;
            exception
               when no_data_found then
                  NULL;
            end;
    end;
    I am trying to run this through a PL/SQL dynamic region and while I don't receive any error's, the content displayed is a huge mess of garbled text and odd characters. I've tried to run this procedure on numerous other document types, including word files and jpeg images, all with the necessary changes in my procedure, and regardless of what I use, I still get a large mess of strange characters. Does anyone have any information or ideas about why this is happening?

    If I understand correctly, your requirements needs to be broken down into two problems:
    1) click link that pops up a window displaying a new APEX page
    2) an APEX page the displays the document, not downloads it.
    I haven't done #1 (yet).
    However, you may be able to generate a URL that points to the new page as part of the SELECT statement for the Report.
    This has a related question, but no answer yet:
    open pdf in popup browser window
    The key is target="_blank" for the anchor tag.
    To generate the URL, you should use the APEX_UTIL.prepare_URL() function.
    If that doesn't work, a Dynamic Action that does some magical JavaScript stuff may be needed.
    For #2, I lost the URL that showed how to display a PDF as part of a "form" page.
    From what I remember:
    Start with a blank page with one blank HTML region (all the Items go in the HTML region)
    Add an Item for the PK/Doc_ID
    part I forgot Create a Data Manipulation Process
    - Automated Row Fetch
    - On Load - After Header
    - (stuff for your table/view)
    part I forgot Create an (I believe) "File Browser" item type. For Settings:
    - Storage Type "BLOB column specified in Item Source" (and place the column name of the BLOB there)
    - MIME Type Column: (column name) -- since you have multiple types, this is a MUST HAVE
    - Filename Column: (column name) -- I highly recommend you have this.
    - Content Disposition == INLINE <-- this is the kicker
    Also, you will need a Browser Plugin for each of the MIME Types (otherwise, the browser may try to 'download' the file)
    Browsers can handle Image types internally. Adobe's plugin can handle PDFs. I don't know about Word/Excel.
    Again, I don't remember the exact details, but that should cover most of it.
    MK

  • Displaying Images stored in Database

    Hi, all i am having images stored in Databases as BLOB.
    how i can display that in flex application. suppose i am having the ArrayList of Employees in which employee object also have a field of called empImage, how i can display this data in flex.
    i am using BlazeDS.
    Thanks
    Regards
    Amar Deep Singh

    Hi,
    This will give you the idea of getting the image from you array list.
    http://blog.flexexamples.com/2008/02/15/creating-a-simple-image-gallery-with-the-flex-hori zontallist-control/
    Johnny
    Please rate my answer. Tks

  • PDF stored in database and to view the PDF when clicking on a link

    Is it possible to save a PDF document in the database as a blob column and to retrieve the PDF when clicking on the link
    Example
    Above method is possible for images
    See: http://www.oracle.com/technology/obe/apex/apex31nf/apex31blob.htm.
    But can I reach the same for PDF documents?
    Thanks in advance for your response.
    Kind regards,
    Iloon

    Hello Andy,
    This Upload and Download Files is very useful feature in APEX.
    However, is there a way of displaying PDF files first in the report by clicking the corresponding link
    in the table?
    I mean, is it possible to view PDF files first by clicking the link before deciding to download them?
    As we see, this approach is used by most websites and after opening and viewing a PDF file, we can save them.
    Thanks.
    Shurick.
    Edited by: Shurick on Sep 28, 2009 12:51 PM

  • Display PDF on the browser from BLOB column

    Hi All,
    I have BLOB column in the table where we are storing PDFs.
    I want to display PDF within the browser ( not as a download option) from that BLOB column, like clicking on the "Print" link.
    Please let me know if anyone has any suggestion.
    -Smith

    Create this DB procedure:
    procedure show_webdoc(io_blob    in out nocopy blob
                         ,i_mimetype in varchar2
                         ,i_filename in varchar2)
    is
    begin
       if dbms_lob.getlength(io_blob) >0 then
          owa_util.mime_header(nvl(i_mimetype,'application/octet'),false);
          htp.p('Content-length: ' || dbms_lob.getlength(io_blob));
          htp.p('Content-Disposition:  inline; filename="'||i_filename|| '"');
          owa_util.http_header_close;
          wpg_docload.download_file(io_blob);
       end if;
    end;Get the blob and give it as input to this procedure. For a pdf the mime type will be application/pdf.

  • Displaying PDF file from database BLOB

    I have successfully added a PDF file to a table as a BLOB. Now, I need to display the BLOB. I have created the following package but it does not display anything. Can someone please help?
    SQL> create or replace package image_get
    2 as
    3 procedure pdf( p_id in demo.id%type );
    4 end;
    5 /
    Package created.
    SQL> create or replace package body image_get
    2 as
    3
    4 procedure pdf( p_id in demo.id%type )
    5 is
    6 l_lob blob;
    7 l_amt number default 30;
    8 l_off number default 1;
    9 l_raw raw(4096);
    10 begin
    11 select theBlob into l_lob
    12 from demo
    13 where id = p_id;
    14
    15 owa_util.mime_header( 'image/pdf' );
    16 begin
    17 loop
    18 dbms_lob.read(l_lob,l_amt,l_off,l_raw);
    19 htp.prn(utl_raw.cast_to_varchar2(l_raw));
    20 l_off := l_off+l_amt;
    21 l_amt := 4096;
    22 end loop;
    23 exception
    24 when no_data_found then
    25 NULL;
    26 end;
    27 end;
    28 end;
    29 /
    Package body created.
    SQL> DECLARE
    2 l_pdf int(1);
    3 begin
    4 l_pdf := 1;
    5 image_get.PDF(l_pdf);
    6 end;
    7 /
    PL/SQL procedure successfully completed.
    SQL> DECLARE
    2 Image1 BLOB;
    3 ImageNum NUMBER := 1;
    4 BEGIN
    5 SELECT TheBLOB INTO Image1 FROM demo
    6 WHERE id = ImageNum;
    7 DBMS_OUTPUT.PUT_LINE('Size of the Image is: ' ||
    8 DBMS_LOB.GETLENGTH(Image1));
    9 /* more LOB routines */
    10 END;
    11 /
    Size of the Image is: 14064
    PL/SQL procedure successfully completed.
    SQL> exit
    Am I missing something? I recently discovered that I need to set SERVEROUTPUT on to display the DBMS_OUTPUT. Is their some other environment variable I need to set.
    Thanks!

    *Always post code wrapped in <a href=http://wikis.sun.com/display/Forums/Forums+FAQ#ForumsFAQ-Arethereanyusefulformattingoptionsnotshownonthesidebar?"><tt>\...\</tt> tags</a>:*
      PROCEDURE lf_html_pdf (pv_image IN VARCHAR2, pv_index IN NUMBER) is
         l_mime        VARCHAR2 (255);
         l_length      NUMBER;
         l_file_name   VARCHAR2 (2000);
         lob_loc       BLOB;
      BEGIN
          begin
            selecT OI_BLOB,DBMS_LOB.getlength (OI_BLOB)
            into lob_loc,l_length
            from ord_img
            where  oi_tno= pv_image
              and oi_ti='PDF'
              and oi_idx=pv_index;
          exception
                when others then
                null;
            end;
         OWA_UTIL.mime_header (NVL (l_mime, 'application/pdf'), FALSE);
         HTP.p ('Content-length: ' || l_length);
         OWA_UTIL.http_header_close;
         WPG_DOCLOAD.download_file (lob_loc);
      END lf_html_pdf; Start by getting rid of:
          exception
                when others then
                null;and never using it anywhere ever again.
    If you're not actually going to use the <tt>l_mime</tt> and <tt>l_file_name</tt> variables then remove these as well. (Although I really think you should set a filename.)
    >
    Error report:
    ORA-06502: PL/SQL: numeric or value error
    ORA-06512: at "SYS.OWA_UTIL", line 356
    ORA-06512: at "SYS.OWA_UTIL", line 415
    ORA-06512: at "HCLABPRO.PKG_PDF", line 220
    ORA-06512: at line 2
    06502. 00000 - "PL/SQL: numeric or value error%s"
    >
    The error stack indicates that the exception is being raised in <tt>HCLABPRO.PKG_PDF</tt>: what is <tt>HCLABPRO.PKG_PDF</tt>? Does this actually have anything to do with the procedure above?
    I get the error message as below when i execute the procedure above;How do you execute it?
    What happens when it's executed without the <tt>when others...</tt> built-in bug?

  • How to display pdf-files out of a blob

    Hello,
    we want to use pdf to publish our enterprise-informations (jobs, press release...) in the intranet.
    How can a display a pdf-file with Portal that was saved in blob?
    regards
    Ralf Schmitt

    Not entirely. At least we came to the conclusion it doesn't make (much) sense to block the save option of PDFs if you want to allow printing them
    Anyway; there is of course another possibilty: you could always write your own java bean PDF reader; there are plenty of java PDF libraries available:
    Open Source PDF Libraries in Java
    The easiest way would be to choose one which can open a PDF from a URL and render it; I would retrieve the image via mod_plsql using WPG_DOCLOAD and simply use the PDF library to render the PDF. No tempfiles anyway, and if you don't implement it there is also no save button.
    cheers

  • Problem displaying picture stored in mySQL

    Hi, i just have got problem displaying picture stored in database as BLOB and presented on JSP over servlet. Below is my code i am using to upload file into database, than download it and display again. The result is the picture can not draw inself and there is always only empty picture space on the web page i am displaying. Please help me to find why it is not working, thanx.
    servlet uploading picture to database
                   boolean isMultipart = FileUpload.isMultipartContent(req);
                   DiskFileUpload upload = new DiskFileUpload();
                   List items = upload.parseRequest(req);
                   Hashtable textFields = new Hashtable();
                   byte[] data = new byte[4096];
                   if(isMultipart)
                        Iterator iter = items.iterator();
                        while(iter.hasNext())
                             FileItem item = (FileItem)iter.next();
                             if(item.isFormField())
                                  textFields.put(item.getFieldName(), item.getString());
                             }else{
                                  data = item.get();
                   String sqlStatement = "INSERT INTO cds VALUES('" textFields.get("id")"'," +
                                            "'" textFields.get("album") "','" textFields.get("interpreter") "'," +
                                                      "'" textFields.get("gr1") "','" textFields.get("gr2") "','" textFields.get("price") "')";
                   String sqlStatement2 = "INSERT INTO pics VALUES('" textFields.get("id") "','" data "')";
    servlet to download picture
    String SQL =
         "SELECT Picture " +
         "FROM pics " +
         "WHERE id = '" + request.getParameter("id") + "'";
         ResultSet rs = stmt.executeQuery(SQL);
         rs.next();
         Blob blob = null;
         blob = rs.getBlob(1);
         response.setContentType("image/jpg");
         request.setAttribute("blob", blob);
         System.out.println("just above OutputStream");
         InputStream in = blob.getBinaryStream();
         ServletOutputStream sout = response.getOutputStream();
         int b;
         while ((b = in.read()) != -1) {
         sout.write(b);
         in.close();
         sout.flush();
         sout.close();
    img tag in JSP
    <img src="LoadImageServlet?id=some id>
    plus i am using
    Tomcat 5.0
    mySQL 4.0
    debuging in eclipse
    thanx for help once more, Libor.

    1:
    are there any exceptions throws by the jdbc code
    2:
    is the code in a doGet
    3:
    you should do a if(result.next())
    4:
    Is your mapping code working

  • Hot to display PDF and Word documents as an attachment in OBIEE Reports

    Hi,
    From few of Oracle threads I learnt that we can store the files in a server locaiton and read it thro a URL. What I am trying to do is, PDF or Word document will be stored in database as BLOB fields. This BLOB field needs to be come as an attachment in OBIEE Reports and by clicking that icon, it uses the local applicaiton PDF reader or a word applicaiton and open the attachment, just like how we open an attachment from a E-mail. Can you please help me with the possible methods of that. I can provide you more information incase if you need.
    Thanks
    Augesthi

    As long as you used the paper-clip Attach icon, that should be fine.
    The entire document appears to you because your Mac recognizes the document type, and displays it for you, saving you from having to mouse around and find a Reader for it. You can still use the Save icon to save a copy of only the attachment.
    To avoid problems with other email readers, be sure the checkbox [√] send windows-friendly attachments is checked.
    I addition, some email readers cannot cope with any attachments positioned at any place in the document other than at the very end. So make sure you move the cursor to the absolute end of the document before clicking "Attach".
    If all else fails, send an email that says, "attachment to follow", then send the attachment right away in a separate email, with nothing else in the body of the message. Some use the Subject abbreviation (nt) to indicate "no text", that is, no words typed in the message portion.

  • Displaying PDF files (stored as BLOBs in Database) using Forms 6i

    Hi,
    We have PDF and Word documents stored in Database (Version 8.1.7). We are using Oracle Forms 6i as User Interface. Through Forms we could view word documents which are stored in database, using OLE container.
    But we could not view PDF files.
    It would be more helpful and valuable if I get ideas/suggestions on this.
    Thanks in advance,
    Umasankar

    Frank,
    You are correct, I totally agree with you.
    TOAD software which i suggested was not for user interface but more for testing purpose - To ensure that the documents is uploaded to BLOBS correctly.
    I am not a WEB person, but I believe sugnificant coding is required in forms6i/9i with WEB features to display the respective documents.
    If, the purpose in ONLY for testing, then TOAD can be used which requires no coding.
    -- Shailender Mehta --

  • Display PDF Documents Stored In Database

    Hi
    I apologise that this question has been asked many times, but I just do not seem to be able to find answer to my question in many other posts over the years.
    We have pdf documents stored in database and wish for client to view from forms session.
    I am able to use webutil_file_transfer.DB_To_Client_With_Progress to transfer to client and open using client_host('cmd /c start '||TheFile);
    I am also able to view pdf documents stored on application server using web.show_document.
    What I would prefer to do is:
    1. Transfer file from database to application server (This is bit I cannot figure out)
    2. Display from application server using web.show_document
    3. Delete temporary file from application server (Also unsure how to do this)
    Our users have thin clients and so in many cases do not have access or unsure where can access to store temporary file if use transfer to client method. Wish to keep temporary file activity on application server.

    You can combine the methods in WEBUTIL. Check this Re: Forms 10G - Saving Blob on Application Server using Java.

  • How do you Display a PDF stored as a BLOB in Apex?

    We are trying to use Apex for the first time here in our shop. The project we have selected has PDFs stored on the database as BLOBS that we currently are able to display with our forms application. We want to do this using apex, and have them appear on one of the pages in the application. I want the PDF to display on the page, when the page itself is invoked, without the need to click on a download link on the page itself.
    I've seen certain examples displaying images etc, but I haven't found one that specifically refers to the display of a PDF database BLOB on a page (I assuming a report page) within Apex.
    Also, since I've just set up the Apex environment utilizing Oracle HTTP Server in the middle tier, do I need Oracle's BI Publisher in order to display the PDFs in Apex?
    Thanks in advance. Any advice or links would be much appreciated.
    Phil

    Thanks for the quick response, and you are correct. I've seen examples that include a link to specifically display the PDF, but I don't want them to be able to directly go to the PDF outside the context of the page itself. These are letters of recommendation that we store on our DB, and this application, for our med school admissions screeners, will be looking at up to three letters of recommendation for each applicant to which they have been assigned. We want them to click on an applicant, and then through a series of tabs view data on that applicant, some of which will be his/her letters of recommendation.
    Phil

  • Oracle reports to display PDF/Excel files stored in the Database

    can we use Oracle reports to view/display PDF/Excel files stored in the Database? Thanks Lalitha

    A document stored in the database can be easily retrieved in or via the browser using mod_plsql. Simplified:
    select content, mime_type
    into v_blob, v_mime_type
    from ...
    owa_util.mime_header(nvl(v_mimetype,'application/octet'),false);
    htp.p('Content-length: ' || dbms_lob.getlength(v_blob));
    owa_util.http_header_close;
    wpg_docload.download_file(v_blob);So, the link in your report should point to this database procedure.
    Edited by: InoL on Mar 1, 2011 4:17 PM

  • How to open PDF stored as blob

    Hi,
    How can i open PDF that is stored in the database as BLOB from Forms 10g. Any method to directly open the PDF instead of generating physical PDF file in AS and open in client by webutil.showdocument.
    Thanks in advance

    Hi,
    The second option is not working here.
    I have another solution
    WEB.SHOW_DOCUMENT('http://abc.com/efg.pdf'); this open the pdf file in the browser without displaying
    a blinking command prompt (as like in the option 1).
    But in all the cases we are opening the physical file, I am looking to open directly from the BLOB column.
    If I should first generate the physical file from the BLOB column, then plz help me to get the code
    Thanks to both of you.

Maybe you are looking for

  • Upgrading to SMC 4.0? Clean Slate.....

    Current environment is SMC server 3.6.1, with various agents versions running on clients. Running ver 3.5, 3.6 and some older servers running Solstice Enterprise Agents. As I try to move this environment from the state I inherited from, to something

  • Approval for parked documents in FI

    Hi, I have a requirement to sent approval SAP screen as attachment to external mail address. for parked documents through (FB01) to achive this i need some help . step 1: how to start workflow when document  getting parked standard event (in FIIP) is

  • 5230 apps continuing to run in background! help...

    Hey guys, Ive just got a 5230 and im really pleased with it. One thing I am finding is that when I use something like the Web, or I access settings, it leaves the little icon which says its running even when I exit back to the home screen. I thought

  • Controlling SWF loaded through MovieClipLoader

    Hello AS gurus, I have a two-level site for a portfolio where users can view still images and videos for different projects. The top level SWF file can be considered as the "parent SWF" and within this file, the user navigates by choosing which proje

  • h:messages  question

    Hi, I'm using JFS with RAD V6.0 and I have a form where I used the <h:messages component to display error messages. The problem that I'm having is if I do something on me bean and I display an error it display correct but if after the error displays