Maroto is a great and easy tool to generate pdfs with Go. It is very easy to achieve quickly outstanding results:
Of course, you can add your fonts, which is particularly important if you want to use UTF8-compliant fonts:
m.SetFontLocation("/PathToMyFonts/") m.AddUTF8Font(“CustomArial”, consts.Normal, “far.ttf”) m.AddUTF8Font(“CustomArial”, consts.Italic, “fai.ttf”) m.AddUTF8Font(“CustomArial”, consts.Bold, “fab.ttf”) m.AddUTF8Font(“CustomArial”, consts.BoldItalic, “fabi.ttf”) m.SetDefaultFontFamily(“CustomArial”)
Now there is one challenge though! For some strange reasons, it seems that the name of the font files has to me short (8 characters?) and should not contain any special characters.
I’ve been looking for a solution for several hours. On macOS, I had no problems, but on Ubuntu, the solution was simply to use shorter filenames.
If anyone has had a different experience, please feel free to leave a note in the comments. Thank you!