This library is a fork of https://github.com/rsc/pdf, which aims to fix some of the outstanding issues.
go get github.com/oxisto/pdf
In order to display a very basic plain text representation of the PDF file, the following snippet can be used:
import (
"fmt"
"os"
"github.com/oxisto/pdf"
)
func main() {
r, err := pdf.Open("test.pdf")
defer r.Close()
if err != nil {
panic(err)
}
for i := 1; i <= r.NumPage(); i++ {
page := r.Page(i)
fmt.Print(page.Content().Plain())
fmt.Println()
}
}
The pdfcat
utility that is also included basically demonstrates the same functionality.
go install github.com/oxisto/pdf/cmd/pdfcat@latest
pdfcat test.pdf