How to draw Japanese in PDFgraphic

Hi Menendez, this is the simple code I use to test the pdf output function.

Var f As FolderItem = SpecialFolder.Desktop.Child(“PDFtest.PDF”)
Var doc As New PDFDocument(PDFDocument.PageSizes.A4)
Var g As PDFGraphics = doc.Graphics
g.DrawingColor = &c000000
Var t As String = “点検作業報告書”
Var Pic As New Picture(200,100)
Pic.Graphics.FontSize = 16
Pic.Graphics.Bold = True
Var w As Double = Pic.Graphics.TextWidth(t)
Var p As New Picture(w,16)
p.Graphics.Bold = True
p.Graphics.FontSize = 16
p.Graphics.DrawingColor = &cff0000
p.Graphics.DrawText(t, 0, 14)
g.DrawPicture(p, 300,200)
doc.Save(f)
f.Open

@NANQI_WU Ok, this is what I’m getting here using two font sizes (16 / 32) and two font styles (Bold / Regular), using the Helvetica type, and with the resulting PDF document displayed at 100% it’s size:

Some tech details:

When drawing text as pictures in PDFDocument, these “objects” are saved using DCT compression. That is the same kind of compression used by the JPEG image format. That means some loss in quality due to the compression, and also color dithering. These effects will be more evident when using small text sizes + styles like bold, because of the color dithering.

Because these are bitmaps and not vectorial text, as you scale the document beyond 100% in the PDF document viewer (as for example Preview on macOS), then the pixels/compression/dithering will be more visible; not so when the document is printed at 100% it’s size.

2 Likes

Hi Menendez,
Thank you for the help.
It is acceptable when setting bold to false and zoom at 100%. Though its not perfect.
Hopefully the future releases will solve this problem.

1 Like