@@ -889,18 +889,23 @@ func (xRefTable *XRefTable) UndeleteObject(objectNumber int) error {
889889 return nil
890890}
891891
892- // IsValid returns true if the object referenced by ir has already been validated .
893- func (xRefTable * XRefTable ) IsValid ( ir types. IndirectRef ) (bool , error ) {
894- entry , found := xRefTable .FindTableEntry (ir . ObjectNumber . Value (), ir . GenerationNumber . Value () )
892+ // IsValidObj returns true if the object with objNr and genNr is valid .
893+ func (xRefTable * XRefTable ) IsValidObj ( objNr , genNr int ) (bool , error ) {
894+ entry , found := xRefTable .FindTableEntry (objNr , genNr )
895895 if ! found {
896- return false , errors .Errorf ("pdfcpu: IsValid: no entry for obj#%d\n " , ir . ObjectNumber . Value () )
896+ return false , errors .Errorf ("pdfcpu: IsValid: no entry for obj#%d\n " , objNr )
897897 }
898898 if entry .Free {
899- return false , errors .Errorf ("pdfcpu: IsValid: unexpected free entry for obj#%d\n " , ir . ObjectNumber . Value () )
899+ return false , errors .Errorf ("pdfcpu: IsValid: unexpected free entry for obj#%d\n " , objNr )
900900 }
901901 return entry .Valid , nil
902902}
903903
904+ // IsValid returns true if the object referenced by ir is valid.
905+ func (xRefTable * XRefTable ) IsValid (ir types.IndirectRef ) (bool , error ) {
906+ return xRefTable .IsValidObj (ir .ObjectNumber .Value (), ir .GenerationNumber .Value ())
907+ }
908+
904909// SetValid marks the xreftable entry of the object referenced by ir as valid.
905910func (xRefTable * XRefTable ) SetValid (ir types.IndirectRef ) error {
906911 entry , found := xRefTable .FindTableEntry (ir .ObjectNumber .Value (), ir .GenerationNumber .Value ())
@@ -2450,6 +2455,7 @@ func (xRefTable *XRefTable) insertBlankPages(parent *types.IndirectRef, pAttrs *
24502455 }
24512456 a = append (a , * indRef )
24522457 i ++
2458+ xRefTable .SetValid (* indRef )
24532459 }
24542460 if before {
24552461 a = append (a , ir )
0 commit comments