DocumentGitHub

PDTP Go

Installation

Install the package via go get:

go get github.com/pdtp-workbench/pdtp-go

Usage

Usage of the package is simple. Just import the package and use it as shown below:


package main

import (
	"fmt"
	"log"
	"net/http"
	"os"

	"github.com/pdtp-workbench/pdtp-go"
)


func main() {
	http.HandleFunc("/pdtp", pdtp.NewPDFProtocolHandler(
		pdtp.Config{
			HandleOpenPDF: func(fileName string) (pdtp.IPDFFile, error) {
				file, err := os.Open(fileName)
				return file, err
			},
			CompressionMethod: pdtp.ZstdCompression{},
		},
	))

	fmt.Println("PDF Protocol Server listening on http://localhost:8080")
  log.Fatal(http.ListenAndServe(":8080", nil))
}