среда, 9 марта 2011 г.

How to force pdf2swf to show non-embedded fonts in Windows

PDF2SWF is utility contained in swftools package. It aims to convert pdf documents into swf files in order to allow you viewing your documents in your web site for example. It works perfectly in most situations as me observed. But unfortunately it rejects to show the text in documents if it has non-embedded fonts in Windows. It is due to that documents refers to windows fonts but the fonts are not processed in decent way. It is interesting that XPDF library is responsible for work with it has corresponding code inside it. But it not called in my situation.
I found the way to fix this problem. Simply you need to add a couple of lines in source codes of SWFTOOLS.
First you need to download the sources of SWFTOOLS from here. Then you should compile sources with MinGW and MSYS. I used MinGW 3.1.0 and MSYS 1.0.10. Theese are old versions of it but SWFTOOLS resists to be compiled with newer versions. Instructions on how to compile SWFTOOLS please get there.
But before compiling do some changings in source code.
in file pdf.cc replace lines

if(!globalParams) {
globalParams = new GFXGlobalParams();
//globalparams_count++;
}

to

if(!globalParams) {
globalParams = new GFXGlobalParams();
globalParams->setupBaseFonts(NULL);
//globalparams_count++;
}

Next, in file GlobalParams.cc find and replace lines

if (!fontName ||
!(dfp = (DisplayFontParam *)displayNamedCIDFonts->lookup(fontName))) {
dfp = (DisplayFontParam *)displayCIDFonts->lookup(collection);
}

to

if (!fontName ||
!(dfp = (DisplayFontParam *)displayNamedCIDFonts->lookup(fontName))) {
dfp = (DisplayFontParam *)displayCIDFonts->lookup(collection);
}

if(!dfp)
return (DisplayFontParam *)this->getDisplayFont(fontName);

Now you should compile SWFTOOLS and your generated SWF movie will show you the texts with non-embedded fonts.

Комментариев нет:

Отправить комментарий