pdfgenerator

package module
v0.0.0-...-bf4ddae Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2020 License: MIT Imports: 5 Imported by: 0

README

Golang HTML to PDF Converter

For reading any document, one prefers PDF format over any other formats as it is considered as a standard format for any document in our day to day life. We often come across converting any form details or previews on the website in the form of HTML to PDF. For GoLang, understanding such usability, Developers at Mindinventory made an effort for making one HTML to PDF Converter which can be used for converting HTML content to PDF.

What it is?

It is a repository, integrating which one can offer HTML to PDF Conversion to their customers.

Prerequisite

Install wkhtmltopdf using below command

  • sudo apt install wkhtmltopdf - for Ubuntu
  • brew install Caskroom/cask/wkhtmltopdf - For Mac

Steps to Follow

  1. Create a sample HTML file inside of your project.

  2. Get go package using the below command for parsing the HTMl template.

    • go get github.com/SebastiaanKlippert/go-wkhtmltopdf
  3. Get another go package for converting this html parse data to pdf using the below command.

    • go get html/template
  4. Run below command

    • go run main.go

After finish above steps, You can generate pdf file from html.

NOTES: Don't forget to mention your html and pdf path details inside your code. If you want to generate pdf for static data then it is not mandatory to generate another html for clone data. Use that same sample html inside the code.

LICENSE!

Golang HTML to PDF Converter is MIT-licensed

Let us know!

We’d be really happy if you sent us links to your projects where you use our component. Just send an email to sales@mindinventory.com And do let us know if you have any questions or suggestion regarding our work.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RequestPdf

type RequestPdf struct {
	Body string
	// contains filtered or unexported fields
}

RequestPdf contains the html data

func NewRequestPdf

func NewRequestPdf(body string) *RequestPdf

NewRequestPdf creates a new RequestPdf from body

func (*RequestPdf) GeneratePDF

func (r *RequestPdf) GeneratePDF(pdfPath string) error

GeneratePDF generates the pdf from the request

func (*RequestPdf) LocalFileAccess

func (r *RequestPdf) LocalFileAccess(b bool)

LocalFileAccess enables or disables local file access

func (*RequestPdf) ParseTemplate

func (r *RequestPdf) ParseTemplate(templateFileName string, data interface{}) error

ParseTemplate to template data

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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