artaxerxe
artaxerxe

Reputation: 6411

Writing special characters with purepdf in AS3

I'm working with flex 4 and need to export some pdf files. I'm useing purePDF library for this. Can anyone explain me how to make possible to write romanian characters in pdf files with purePDF -> I need to write characters like ăîşţ, etc.

I look in the wiki documentation of that library but cannot understand enough what I need. Appreciate any help.

Thanks

Upvotes: 1

Views: 865

Answers (1)

artaxerxe
artaxerxe

Reputation: 6411

I'll ask my own question, taking in consideration that it'll be useful for other one.

Note: Taking in account that purepdf is the iText library equivalent from Java, when you encounter any problems and need documentation, you can consult iText documentation for inspiration with purePDF.

So this is what you need to do:

  • find a suitable "True Type" font that contains your special characters (with "ttf" extension). For me, I found that in the /usr/share/fonts/truetype/*.
  • copy the *.ttf font file in a directory for use in your application (in my case "assets" directory)
  • after you find that, you can try it if matches your needs by the following code :

  public static const SERIF_NORMAL : String = "FreeSerif.ttf";

  //"assets/fonts/FreeSerif.ttf" is the directory where I copied my *.ttf files
  [Embed(source="assets/fonts/FreeSerif.ttf", mimeType="application/octet-stream")]
  private var serifNormalCls : Class;
  private var normalFont : Font;

  var bfNormal : BaseFont;
//...
  //in youre initialization function :
  FontsResourceFactory.getInstance().registerFont(SERIF_NORMAL, new this.serifNormalCls());
  bfNormal = BaseFont.createFont(SERIF_NORMAL, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

  //and when you need to use your the special characters, you will use that font
  this.normalFont = new Font(Font.UNDEFINED, 10, Font.UNDEFINED, null, bfNormal);

Cheers!

Upvotes: 1

Related Questions