Categorygithub.com/lampnick/doctron-client-go
modulepackage
0.2.0
Repository: https://github.com/lampnick/doctron-client-go.git
Documentation: pkg.go.dev

# README

doctron-client-go

install

go get -u github.com/lampnick/doctron-client-go

full demo

package main

import (
	"context"
	"log"
	"github.com/lampnick/doctron-client-go"
)

const domain = "http://47.52.25.206:8080"
const defaultUsername = "doctron"
const defaultPassword = "lampnick"

func main() {
	client := doctron.NewClient(context.Background(), domain, defaultUsername, defaultPassword)
	req := doctron.NewDefaultHTML2PdfRequestDTO()
	req.ConvertURL = "http://doctron.lampnick.com/doctron.html"
	response, err := client.HTML2Pdf(req)
	if err != nil {
		log.Fatal(err)
	}
	log.Println(len(response.Data))
}

html2pdf

client := doctron.NewClient(context.Background(), domain, defaultUsername, defaultPassword)
req := doctron.NewDefaultHTML2PdfRequestDTO()
req.ConvertURL = "http://doctron.lampnick.com/doctron.html"
response, err := client.HTML2Pdf(req)
...

html2pdf and upload

client := doctron.NewClient(context.Background(), domain, defaultUsername, defaultPassword)
req := doctron.NewDefaultHTML2PdfRequestDTO()
req.ConvertURL = "http://doctron.lampnick.com/doctron.html"
req.UploadKey = "test.pdf" // add this
response, err := client.HTML2PdfAndUpload(req)

html2image

client := doctron.NewClient(context.Background(), domain, defaultUsername, defaultPassword)
req := doctron.NewDefaultHTML2ImageRequestDTO()
req.ConvertURL = "http://doctron.lampnick.com/doctron.html"
response, err := client.HTML2Image(req)

html2image and upload

client := doctron.NewClient(context.Background(), domain, defaultUsername, defaultPassword)
req := doctron.NewDefaultHTML2ImageRequestDTO()
req.ConvertURL = "http://doctron.lampnick.com/doctron.html"
req.UploadKey = "test.png"
response, err := client.HTML2ImageAndUpload(req)

pdf add watermark

client := doctron.NewClient(context.Background(), domain, defaultUsername, defaultPassword)
req := doctron.NewDefaultPdfWatermarkRequestDTO()
req.ConvertURL = "https://qjhdqx-prod.oss-cn-zhangjiakou.aliyuncs.com/test.pdf"
req.ImageURL = "https://www.baidu.com/img/flexible/logo/pc/result.png"
response, err := client.PdfAddWatermark(req)

pdf add watermark and upload

client := doctron.NewClient(context.Background(), domain, defaultUsername, defaultPassword)
req := doctron.NewDefaultPdfWatermarkRequestDTO()
req.ConvertURL = "https://qjhdqx-prod.oss-cn-zhangjiakou.aliyuncs.com/test.pdf"
req.ImageURL = "https://www.baidu.com/img/flexible/logo/pc/result.png"
req.UploadKey = "PdfAddWatermarkAndUpload.pdf"
response, err := client.PdfAddWatermarkAndUpload(req)

# Packages

No description provided by the author

# Functions

NewClient NewClient.
NewDefaultHTML2ImageRequestDTO NewDefaultHTML2ImageRequestDTO.
NewDefaultHTML2PdfRequestDTO NewDefaultHTML2PdfRequestDTO.
NewDefaultPdfWatermarkRequestDTO NewDefaultPdfWatermarkRequestDTO.

# Constants

Display header and footer.
HTML template for the print footer.
Capture the screenshot from the surface, rather than the view.
HTML template for the print header.
Whether to silently ignore invalid but successfully parsed page ranges, such as '3-2'.
Paper orientation.
Bottom margin in inches.
Left margin in inches.
Right margin in inches.
Top margin in inches.
Paper ranges to print, e.g., '1-5, 8, 11-13'.
Paper height in inches.
Paper width in inches.
Whether or not to prefer page size as defined by css.
Print background graphics.
Compression quality from range [0..100] (jpeg only).
Scale of the webpage rendering.
Rectangle height in device independent pixels (dip).
Page scale factor.
Rectangle width in device independent pixels (dip).
Capture the screenshot of a given region only.
Y offset in device independent pixels (dip).
DefaultWaitingTime Waiting time after the page loaded.
No description provided by the author
Image compression format (defaults to png).

# Structs

Client Client.
CommonRequestDTO CommonRequestDTO.
CommonResponse CommonResponse.
ConvertResponse ConvertResponse.
HTML2ImageRequestDTO HTML2ImageRequestDTO.
HTML2PdfRequestDTO HTML2PdfRequestDTO.
PdfWatermarkRequestDTO PdfWatermarkRequestDTO.
UploadResponse UploadResponse.

# Interfaces

RequestI RequestI.