user501687
user501687

Reputation:

embedding fonts in flex for generating pdf file?

I am trying to embed arial bold font but getting run time error

font ARIALBD.TTF with Identity-H is not recognized

i am embedding the font in purepdf library for generating the pdf file via flex app.

here in the code.

    [Embed( source="ARIALBD.TTF", mimeType="application/octet-stream" )]

    public static const arialb:Class;


if ((style & Font.BOLD) == Font.BOLD)
f = BaseFont.createFont(arialb, BaseFont.IDENTITY_H);

Upvotes: 1

Views: 1800

Answers (2)

Badr
Badr

Reputation: 10648

PurePDF will accept only UNICODE Fonts

check your font is a Unicode font or not

try with a Unicode font and also write the extension *.TTF in lowercase *.ttf as the check for extension in PurePDF BaseFont class is as follows.

else if ( StringUtils.endsWith( nameBase, ".ttf" ) || StringUtils.endsWith( nameBase, ".otf" ) || nameBase.toLowerCase()
                .indexOf( ".ttc," ) > 0 )           {
                if( encoding == IDENTITY_H || encoding == IDENTITY_V)
                {
                    fontBuilt = new TrueTypeFontUnicode();
                    TrueTypeFontUnicode(fontBuilt).init( name, encoding, embedded, ttfAfm, false, forceRead );
                } else {
                    fontBuilt = new TrueTypeFont();
                    TrueTypeFont(fontBuilt).init( name, encoding, embedded, ttfAfm, false, forceRead );
                    TrueTypeFont(fontBuilt).fastWinansi
= encoding == CP1252;
                }           }

Upvotes: 1

shaunhusain
shaunhusain

Reputation: 19748

You need to put it at the root of the project if you reference it this way, if it's in the same package as the class you need to add the package path to the Embed path. The Embed path is relative to the build path not the class which is referencing it, that class is also being referenced from the build path during compilation but it doesn't use paths relative to the class when resolving the Embeds.

Upvotes: 0

Related Questions