More PDF Issues

I seem to be running into encoding issues with the new PDF class in 2022r2.

I open a file using a TextInputStream and set each ReadLine to DefineEncodings(Encodings.UTF8). When loading a ListBox with the lines, the Unicode characters are displayed properly:

However, the same lines sent to the PDF class’ DrawText method results in ??? instead of the Unicode characters:

I’m using:

CatLine = fTis.ReadLine.DefineEncoding(Encodings.UTF8)

and then processing CatLine.

@Javier_Menendez ?

PDFDocument doesn’t support Unicode at the moment.

1 Like



Well, there are plugins from MBS and Einhugur to do PDF with unicode characters…

Yep, I know… :pensive: Working at that now (is the only main feature to implement from the initial list… some other pieces were needed first, so…).

In the meantime, and I know is far far away from being the right solution, you can render utf-8 / utf-16 to a Picture and add it to the PDF page (remember to create the picture at double the size you are going to include it in the PDF; for example 200 x 200 if you are going to add it at 100 x 100).

For example:

Var d As New PDFDocument
Var g As Graphics = d.Graphics
Var s As String = "ぐ 園ヅ尉ュゟ"

Var p As New Picture(500, 500)
p.Graphics.FontSize = 24
p.Graphics.DrawText(s, 0, p.Graphics.FontAscent)

g.DrawPicture(p, 20, 20, 250, 250, 0, 0, p.Width, p.Height)



Thanks, but this is generated from a list that could have 100,000’s of entries, so that would be economically disastrous. For now, I’ve returned to using the Windows and macOS Print methods and letting the user choose the “PDF” dropdown on the Print dialog. For Linux, the user just ends up with question marks unil the Linux PrinterSetup issue is sorted.