This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"github.com/dslipak/pdf"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
func GenerateSessionId(length int) string {
|
||||
@@ -30,6 +30,7 @@ func Pages(reader io.ByteReader) (pages int) {
|
||||
for {
|
||||
b, err := reader.ReadByte()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
check:
|
||||
@@ -51,10 +52,15 @@ func Pages(reader io.ByteReader) (pages int) {
|
||||
// PagesAtPath opens a PDF file at the given file path, returning the number
|
||||
// of pages found.
|
||||
func CountPagesAtPath(path string) (pages int) {
|
||||
if reader, err := os.Open(path); err == nil {
|
||||
reader.Chdir()
|
||||
pages = Pages(bufio.NewReader(reader))
|
||||
reader.Close()
|
||||
r, err := pdf.Open(path)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("LOL")
|
||||
fmt.Println(err)
|
||||
return 0
|
||||
}
|
||||
|
||||
pages = r.NumPage()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user