Embed fonts with PDFDocument class

Hello everyone,

I’m facing an issue with PDF generation in Xojo Desktop and was hoping to get some help from the community.

The Problem

I used to generate PDF invoices by printing from a report to a system-installed PDF printer. This method worked great because the generated PDFs included the fonts. I know this because the files displayed correctly on systems without those fonts installed.

Now, I’m using the PDFDocument class in Xojo to create the PDFs. On my machine, where the fonts are installed, everything looks fine. However, when I open the PDFs on a different computer without the specific fonts, the text is replaced by generic fonts. It seems the PDFDocument class isn’t embedding the fonts.

My Questions

  1. How can I make the PDFDocument class embed fonts? I’ve checked the documentation but haven’t found a clear property or method to do this.
  2. Is it possible to render the text as a canvas or graphic? This would be a workaround if embedding fonts isn’t an option. The idea is to draw the text as a vector graphic instead of editable text, ensuring its appearance doesn’t change.

Any advice, suggestions, or code examples would be greatly appreciated. Thanks!

Have you tried to set PDFDocument.EmbeddedFonts?

PDFDocument.EmbeddedFonts = True

Okay, perfect, thanks. Now I need to know if there’s a method in the same class that I can use to hide myself. :face_with_peeking_eye:

I wonder why I didn’t see it in the documentation before…

Thank you!

1 Like

mHugo.Visible=false

I would proceed with caution regarding the Xojo-supplied PDF classes. The most significant limitation is that they do not support most non-ASCII characters. Search this forum for many, many frustrated discussions concerning this limitation and pointers to alternatives.

3 Likes

If you would like to sign up to the reports, here are a few:
60248 : PDFDocument fonts only encoding as ANSI
73611 : PDFDocument only supports extended ASCII not UTF8

1 Like

You may just get DynaPDF or Björns PDF Plugin to do this if you need this. Both are in OmegaBundle this year.

Also DynaPDF can do font subsetting. So you won’t get a 15 MB font embedded in your PDF, but just the used characters.

1 Like