summaryrefslogtreecommitdiff
path: root/document/document.go
diff options
context:
space:
mode:
authorScrotadamus <scrotadamus@insiberia.net>2025-03-07 17:09:07 +0100
committerScrotadamus <scrotadamus@insiberia.net>2025-03-07 17:11:10 +0100
commit30417cde4c7353a6c8e960f6be84a6c76c512e60 (patch)
treedec1d0da29db0cbb8226dccc13b94c5f1c8fe2f9 /document/document.go
parent7e25e46a37d39ba546889c7e5056257ba2364c2e (diff)
Feature -- minimal pdf browser
added minimal pdf browser, still experimental (like everything here lol!) Changes to be committed: new file: cmd/browse.go modified: document/document.go modified: go-poppler/page.go
Diffstat (limited to 'document/document.go')
-rw-r--r--document/document.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/document/document.go b/document/document.go
index a036eee..cd84875 100644
--- a/document/document.go
+++ b/document/document.go
@@ -134,6 +134,24 @@ func integrityCheck(tizio *GhlighDoc, caio *GhlighDoc) {
}
+func (d *GhlighDoc) GetNPages() int {
+ return d.doc.GetNPages()
+}
+
+func (d *GhlighDoc) GetPageText(i int) (string, error) {
+ nPages := d.doc.GetNPages()
+
+ if i < 0 || i > nPages {
+ return "", fmt.Errorf("error page %d out of range %d", i, nPages)
+ }
+
+ p := d.doc.GetPage(i)
+ defer p.Close()
+
+ text := p.Text()
+ return text, nil
+}
+
func (d *GhlighDoc) Save() (bool, error) {
d.mu.Lock()
defer d.mu.Unlock()