can i save embedded font to font file?


i'm parsing pdf magazines and need to separate text from images.
all ok for now but i have a problem.

i want to save the embedded that comes withing the pdf to be separated file

with not much documentation about this i managed to do something but it doesn't quite work:

if (font.IsEmbedded()&&font.GetEmbeddedFontBufSize()>0)
  Obj fObj = ereader.GetFont(font.GetName());
  if (fObj!=NULL)
    Filter filter = fObj.GetDecodedStream();
    FilterReader reader(filter);
    unsigned char fontStream[1024];
    int counter=0;
    while (reader.Read(fontStream,1024)>=1024)

i could use some help with this.

You can extract the embedded font (is any) using the code along the
following lines:

// C# pseudocode (C++ & JAVA is essentailly the same, apart from minor
syntax differences).
pdftron.PDF.Font font = // ... e.g. new pdftron.PDF.Font(fObj);
Obj font_stm = font.GetEmbeddedFont();
if (font_stm != null) {
  Filter flt = font_stm.GetDecodedStream();
  FilterReader reader = new FilterReader(flt);
  StdFile out_file = new StdFile("out.dat",
  FilterWriter writer = new FilterWriter(out_file);

What extension shall i use? ttf? how can i know?

Hello Fraga,

If the font is TrueType, you should be able to use the TTF file extension.

There are third-party tools which may help you identify information about the font after you extract it: