go-goji-templating-pdf-generation

command module
v0.0.0-...-3c7c33e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2021 License: MIT Imports: 5 Imported by: 0

README

ko-fi

Go Goji Templating/PDF Generation

This repo is used to experiment with Go's templating engine and use it to generate PDFs. One of the goals is to get a fully accessible PDF, in the least amount of time and memory/CPU footprint. The API uses HTML templates that are combined with data, then converted to PDFs and optimized.

The tools used are:

  • Goji: https://github.com/goji/goji - Goji was selected for its minimal footprint.
  • Go text/template package: https://golang.org/pkg/text/template/ - text/template was used over html/template since the final output is a PDF. text/template is faster than html/template. We are not concerned with generating "safe" HTML, since we do not serve this to a browser.
  • WKHTMLTOPDF: https://wkhtmltopdf.org/ - This is used to perform the HTML to PDF conversion.
  • Ghostscript: https://www.ghostscript.com/ - This is used to optimize and apply PDF metadata. It is also used to apply pdfmarks to support accessibility.

Accessibility

I tried hard to create a fully accessible PDF, however I'm sure there is a lot of work left to do here. The following online checkers were utilized during the development of this code:

Resources

The following blogs, Stack Overflow posts, etc were used to help solve a lot of problems.

License

The MIT License (MIT)

Copyright (c) 2021 Brandon Atkinson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL