We have already covered pdf generation to some degree, by using
wkhtmltopdf on AWS’ Lambda service. This post is about generating pdfs without needing wkhtml - by building the pdf from Go itself. To do this we use a library called
gofpdf to build the pdf.
It quite straightforward for simple documents, but gets more complicated the more you add to it. In our example we add some text as a title and an image just beneath it. Finally call
OutputFileAndClose() to save the pdf to file - a screenshot of our example is shown below.
For more information and available methods, see the library’s documentation.