Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: XML and PDF...

Re: XML and PDF...

From: Romin Irani <romin.k.irani_at_gmail.com>
Date: 25 Mar 2005 19:30:31 -0800
Message-ID: <95f6cc08.0503251930.11605019@posting.google.com>


ptjm_at_interlog.com (Patrick TJ McPhee) wrote in message news:<3aj0npF67ube5U1_at_uni-berlin.de>...
> In article <TQT0e.107429$Vf.4063527_at_news000.worldonline.dk>,
> Verner Jensen, Ålborg <java_at_ofir.dk> wrote:
>
> % Is it possible to store a PDF doc, as part of an XML? Should the PDF-part be
> % encoded/wrapped or something, cause I can't figure out how the XML text
> % format is able to hold binary data?
>
> It's typical to use MIME base-64 encoding to encode binary data in XML
> files.

Since the PDF file is a binary format -- you have to encode it in a fashion that is compatible with text while inserting it into the XML instance. As correctly mentioned here, you should be base64 encoding for the same.

The process would roughly be the following: a) To encode the PDF

  1. Take the PDF content as bytes
  2. Run it through a program / method which goes something like: PDFInBase64Bytes = convertToBase64(PDFBytes)
  3. Insert it into a XML instance after converting to string. <MyXMLDoc> <!-- other elements --> <PDFSegment>Base64 representation of PDF</PDFSegment> </MyXMLDoc>
  4. To decode the PDF
  5. Extract out the value of the XML element <PDFSegment>.
  6. Do the reverse i.e. PDFBytes = decodeFromBase64(<PDFSegment> value...)
  7. Provide the PDFBytes to a PDF-aware application e.g. Adobe PDF Reader.

There are several free base64 encoding/decoding libraries available on the net in a variety of languages. Pick up and try it out quickly.

We have used the above process as mentioned and it works fine. Received on Fri Mar 25 2005 - 21:30:31 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US