Create PDF with unicode text in Xojo

If you make international applications, you have a need to write PDF documents with unicode characters. Use our MBS Xojo DynaPDF Plugin to create PDFs with full unicode support. The Starter edition is enough to write such a PDF and can be purchased stand alone or as part of OmegaBundle.

As you see we picked some example text with non-latin characters like Chinese and Japanese, Cyrillic characters with Ukrainian, Greek letters and some accented characters with Czech.

If you use a font with unicode characters like Arial Unicode MS with 50377 characters supported. But for most texts you just use built-in fonts in PDF like Helvetica, Courier or Times.

Here is an example on how to use DynaPDF to write a PDF with multi language text:

Dim pdf As New DynapdfMBS

// create PDF on file. Use nil to create in memory.
Dim f As FolderItem = SpecialFolder.Desktop.Child("Create PDF.pdf")
call pdf.CreateNewPDF f

// We want to use top-down coordinates
call pdf.SetPageCoords pdf.kpcTopDown

// Start new page
Call pdf.Append

// set a font with unicode support
Call pdf.SetFont "Arial Unicode MS", pdf.kfsNone, 14.0, True, pdf.kcpUnicode

// write text in multiple languages
Call pdf.WriteText 50.0,  50.0, "English: Xojo is great!"

Call pdf.WriteText 50.0, 100.0, "Chinese: Xojo 非常棒!"
Call pdf.WriteText 50.0, 120.0, "Czech: Xojo je skvělé!"
Call pdf.WriteText 50.0, 140.0, "Greek: Το Xojo είναι υπέροχο!"
Call pdf.WriteText 50.0, 160.0, "Japanese: Xojoは素晴らしい!"
Call pdf.WriteText 50.0, 180.0, "Ukrainan: Xojo - це чудово!"

// end page
Call pdf.EndPage

// close file
Call pdf.CloseFile

// and show it

If you like to create PDF in memory, please pass nil for the folderitem and later query final PDF with GetBuffer() function after calling CloseFile. Also note, that for SetFont, you don’t need to specify true and kcpUnicode as that is the default.
Please let us know if you have questions about this.