mirror of
https://github.com/hanzoai/pdf.git
synced 2026-10-30 18:25:03 +00:00
29 lines
384 B
Go
29 lines
384 B
Go
package examples
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/hanzoai/pdf"
|
|
)
|
|
|
|
func TestGetPlainText(t *testing.T) {
|
|
pdf.DebugOn = true
|
|
|
|
f, r, err := pdf.Open("./pdf_test.pdf")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer f.Close()
|
|
|
|
var buf bytes.Buffer
|
|
b, err := r.GetPlainText()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
buf.ReadFrom(b)
|
|
content := buf.String()
|
|
fmt.Println(content)
|
|
}
|