How do I extract Embedded Font

Q: I need your help to extract embedded fonts from PDF file (attached
publication.pdf). I am using the following code

               Obj fontObj =
pdfView.getDoc().getSDFDoc().getObj(vdpTxtFieldInfo.m_SDFObjNum);
               // or fontObj.getEmbeddedFont();
               //Filter filter = fontObj.getDecodedStream();
               Filter filter = fontObj.getRawStream(true);
               pdftron.Filters.FilterReader reader = new
pdftron.Filters.FilterReader(filter);
               byte[] fontStream =
reader.read(fontObj.getRawStreamLength());
I get the Byte Stream. To test if I have done it correct. I output
this stream to a file. This is a True Type Font and subset is set to
false when extracting the PDF so all the Glyps are available. Firstly
when I click on the File, the Windows complain that the font is not
recoginzed. And also I tried with the following code

               if (fontFile != null)
               {
                  pdftron.PDF.Font pdfFont = null;
                  pdfFont =
pdftron.PDF.Font.createTrueTypeFont(pdfView.getDoc().getSDFDoc(),
fontFile, true);
                  PDFPageInfo.m_InfoLog.info("\n---PDF FONT OBJECT IS
CREATED.------" + pdfFont.getName() + "\n");
               }
This throws following Exception
Message: The font file could not be opened or read
-------
A: You should use 'fontObj.getDecodedStream()' instead of
'fontObj.getRawStream(true)'. Calling getRawStream() would will return
a raw PDF data stream for a given stream which can be compressed and/
or encrypted.

Q: Your email was helpful. I was trying with
'fontObj.getDecodedStream()' but was setting the wrong buf size. I was
setting it to getRawSteamLength(). I realized from your email that Raw
Stream length will be much smaller then the Decodded Stream Length. I
could not find any function to get the Decodded Stream Length which I
can pass to Reader.read function. Please do let me know how can I get
this Buffer Size.

I did try using Cos Edit and was able to extract the Font Stream into
a Font File. The program I send to you yesterday also works if buffer
size is set properly (which I am now setting to an arbitary large
number).
-------
A: The size of decompressed data stream is not known in advance.
Instead you can call FilterReader.Read() method many times using a
fixed size buffer (e.g. reader.Read(1024)). You have reached the end
of the data stream when Read() returns a buffer that is smaller than
the given number (i.e. 1024 in this case).