Skip to content

Commit

Permalink
Fix #796
Browse files Browse the repository at this point in the history
  • Loading branch information
hhrutter committed Feb 1, 2024
1 parent 6ae90db commit 222cf6c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion pkg/pdfcpu/annotation.go
Expand Up @@ -494,14 +494,15 @@ func removeAllAnnotations(
return false, err
}
objNr := ir.ObjectNumber.Value()
if err := ctx.DeleteObject(ir); err != nil {
if err = ctx.FreeObject(objNr); err != nil {
return false, err
}
if incr {
// Modify Annots array obj for incremental writing.
ctx.Write.IncrementWithObjNr(objNr)
}
}

annots, _ := obj.(types.Array)

for _, o := range annots {
Expand Down Expand Up @@ -930,5 +931,12 @@ func RemoveAnnotations(ctx *model.Context, selectedPages types.IntSet, idsAndTyp
}
}

if removeAll {
// Hacky, actually we only want to remove struct tree elements using removed annotations
// but this is most probably what we want anyway.
root, _ := ctx.Catalog()
root.Delete("StructTreeRoot")
}

return removed, nil
}
2 changes: 1 addition & 1 deletion pkg/pdfcpu/validate/structTree.go
Expand Up @@ -90,7 +90,7 @@ func validateObjectReferenceDict(xRefTable *model.XRefTable, d types.Dict) error
}

if obj == nil {
return errors.New("pdfcpu: validateObjectReferenceDict: missing required entry \"Obj\"")
return errors.Errorf("pdfcpu: validateObjectReferenceDict: missing obj#%s", ir.ObjectNumber)
}

return nil
Expand Down

0 comments on commit 222cf6c

Please sign in to comment.