pdfcpu
pdfcpu copied to clipboard
bookmarks.go : unnecessary check pagefrom
https://github.com/pdfcpu/pdfcpu/blob/master/pkg/pdfcpu/bookmarks.go
line:245~247
if i == 0 && parentPageNr != nil && bm.PageFrom < *parentPageNr {
return nil, nil, 0, errCorruptedBookmarks
}
if i > 0 && bm.PageFrom < bms[i-1].PageFrom {
return nil, nil, 0, errCorruptedBookmarks
}
in some case, current bookmark pagefrom num maybe larger than the last bookmark pagefrom num, the last bookmark do not must point the last page
Hello!
Can you please provide a small sample file in order to reproduce this. Thank you
f := "4wd-opt.pdf"
bms := []pdfcpu.Bookmark{{Title: "t1", PageFrom: 2}, {Title: "t2", PageFrom: 1}}
err := api.AddBookmarksFile(f, "o.pdf", bms, pdfcpu.NewDefaultConfiguration())
if err != nil {
fmt.Println("add bookmark", err)
}
[root@10 test]# go run main.go add bookmark pdfcpu: corrupt bookmark