gohtmltopdf

package module
v0.0.0-...-01d1612 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2021 License: MIT Imports: 2 Imported by: 0

README

GoHTMLtoPDF Converter

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

  • Download - for Windows 64bit

  • Download - for Windows 32bit

  • sudo apt install wkhtmltopdf - for Ubuntu

  • brew install Caskroom/cask/wkhtmltopdf - For Mac

URL to PDF steps to follow

Create go file - main.go

package main

import (
	"github.com/shamim4s/gohtmltopdf"
)

func main() {
	err := gohtmltopdf.UrltoPdf("https://google.com", "google.pdf")
	if err != nil {
		log.Fatal(err)
	}
}

Run below command - go run main.go

Parse HTML to PDF 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/shamim4s/gohtmltopdf
  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

###The previous version of golang was deprecated and not supporting the converter library so dependencies are updated with the new updates.

#Steps by step:

  • Install golang (1.16)
  • Check go version (Make Sure it is latest = 1.16)

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

NOTES: The pdf will be generated in the storage directory. 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 me@shamim.app 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

func HtmltoPdf

func HtmltoPdf(htmlpath string, pdfPath string) error

func UrltoPdf

func UrltoPdf(urlpath string, pdfPath string) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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