pdfrw icon indicating copy to clipboard operation
pdfrw copied to clipboard

How to change the font?

Open f1nked opened this issue 3 years ago • 1 comments

I want to make a document using a TrueType font (.ttf). The font is not system, is in a separate file. How can I integrate it into the document? Changing FONT_NAME does not change the font in the resulting document. Any help would be very helpful. Thanks.

page.Resources.Font.F1.Subtype = PdfName.TrueType
page.Resources.Font.F1.BaseFont = PdfName.FONT_NAME

f1nked avatar May 15 '22 15:05 f1nked

There's no simple way to do it in pdfrw as the setting up of fonts in PDF is a rather laborous task. However, see https://github.com/sl2c/pdfrwx/blob/master/pdffont.py for an example of how this can be done in pdfrwx.

sl2c avatar Sep 20 '23 09:09 sl2c