go-pdf-bot

command module
v0.0.0-...-433f4b7 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2018 License: MIT Imports: 22 Imported by: 0

README

Go PDF Bot

Generate PDF files from HTML pages asynchronously. This tool has been implemented with Golang and inspired by the excelent NodeJS tool pdf-bot.

Install

go get -d ./...

Run

go build .
go ./go-pdf-bot

Go PDF Bot opened a port on 8080 (default port) and it is waiting for HTTP requests like :

curl -X POST \
  http://localhost:8080/rpc \
  -H 'content-type: application/json' \
  -d '{
    "jsonrpc" : "2.0",
    "method":"job/create",
    "params":{
        "html" :"Hello <b>World</b>!!"
    },
    "id":"128612876124812"
}'

You can see the parameter "html" with value Hello <b>World</b>!!. Go PDF Bot will generate a PDF file in storage/pdf directory based on this html code.

Webhook

You can tell to Go PDF Bot to post the PDF content on your server through a webhook :

curl -X POST \
  http://localhost:8080/rpc \
  -H 'content-type: application/json' \
  -d '{
    "jsonrpc" : "2.0",
    "method":"job/create",
    "params":{
        "html" :"Hello <b>World</b>!!",
        "webhook" :"https://your.website.com"
    },
    "id":"128612876124812"
}'

Example

  • Run a Go PDF bot instance.
go build .
go ./go-pdf-bot
  • Run a server to collect PDF contents listening on the port 8833.
go run webhook.go
  • Make a curl request to generate a pdf and post the coontent on this.
curl -X POST \
  http://localhost:8080/rpc \
  -H 'content-type: application/json' \
  -d '{
        "jsonrpc" : "2.0",
        "method":"job/create",
        "params":{
                "html" :"Hello <b>World</b>!!",
                "webhook" :"http://localhost:8833/webhook"
        },
        "id":"128612876124812"
}'

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