add invoice view
All checks were successful
Go / build (push) Successful in 12m14s

This commit is contained in:
2025-07-01 15:30:06 +02:00
parent 992b9c17c3
commit 7025f526c1
11 changed files with 257 additions and 83 deletions

View File

@@ -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
}