PDFDocument.Font Issues

Hello guys,

Is there a way to be able to choose and embed a specific font on PDF ?

I have on my side set the Font as following :

Var d As New PDFDocument(PDFDocument.PageSizes.A4)
d.AddFonts(SpecialFolder.Resource("Fonts"))
d.EmbeddedFonts = True

g.DrawingColor = Color.Black
g.FontName = "Al Tarikh"
g.DrawText(titleAr, 105, 330, 350)

But unfortunately I have either “???” as text or nothing is showing .

I did tried to copy and embed the fonts on the app as well and nothing happens.

Any other ideas ?

Thanks

Language to be written is Arabic

Could be the issue: PDFDocument currently don’t support Unicode.

Have you checked this Tutorial?

Well does not seem to work what is shown in the video and it seems that the copy script does not copy the fonts in the Resources side.

I do need those for Windows and MacOS but I see that unfortunately, again, does not work.

And I guess in the blog it was saying " Published in Cross-Platform, Learning and Tips" so I assumed that it does work on all.

Any other ideas ?

Thanks Martin.

@Javier_Menendez - Looks like PDFDocument’s font parser is not able to read the font correctly.

You already had the answer.

Lovely, I guess I cannot use this feature currently.

@Xojo Any chance to support unicode and Arabic in the next release ?

At least I know if I tell the customer to wait for the next release or look again for another platform that does support all this .

Thanks .

There are plugins from Einhugur and MBS that support PDF by making use of libraries that implemented things correctly. Xojo just made the format up as they went along in Xojo code, making their PDF engine weak, unreliable, and slow.

Unfortunately I cannot use plugins, so I guess I’ll have to look for another platform for this customer.

Thanks Tim.

Don’t think so, see:
#60248 - PDFDocument fonts only encoding as ANSI

Created 2 years ago, nominated for Bug Bash 2022 and still has not been assigned to anyone or to any future release (I see other issues assigned to 2023r1 and 2023r2).

That’s only half of the answer, too. Does (or will) PDFDocument support scripts that are not left-to-right, like Arabic?

Unicode & complex script support in PDF is not trivial. Xojo may be working on it as we speak but I imagine they won’t be able to get close to the functionality of a dedicated PDF library.

Your best bet is to use a plugin or declare into a 3rd party library (the MBS & Einhuger plugins are mainly wrappers for two of the libraries out there). If you switch to another development environment you may find that it is just using one of the libraries that you seem to be trying to avoid.

@Eric_Williams
How is a user of Xojo supposed to know what you are asking?

No

Only after Xojo has finished all of the required development work.

The original poster knows, and anyone working in certain non-Latin languages will know what I’m talking about. Arabic is written right-to-left – opposite of most scripts – and specific support for this has to be built in to any system that images text. It doesn’t just happen.

LOL. OK, let me rephrase the question, since I can’t find this information anywhere: WILL Xojo’s PDFDocument support include right-to-left script support? Is that in the development plan/on the roadmap?

I don’t expect you to answer if you don’t know, but it’s a good question to ask.

Right-to-left writing is highly tied with Unicode support. Once we add that to the PDF bag, then right-to-left would be possible too.

Possible, yes. Planned?

Hello Javier, thanks for the reply. I know you don’t give timelines or details but a rought time when we could expect unicode ? working in Middle East area where we need those like air in order to have functional apps is quite hard for us to keep the pace if we don’t have what we need.

Thanks.

And in Far East (Japan for example), there are also top to bottom and bottom to top (not only left to right or right to left…) writing.

I believe we are all aware about all the unicode types, in my case the question was due to the fact that i need to know what i can tell to the customer, wait, change platform, change company, so it could be in my advantage or not.

Thanks