Skip to content

Commit 7e2c39d

Browse files
author
Samuel Huylebroeck
committed
Handle NPE when removing floating AcroField
Fix Acrofields present in the document but not linked to the annotations dic throwing and NPE when they are removed SUP-1602
1 parent 5a893d5 commit 7e2c39d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/core/iTextSharp/text/pdf/AcroFields.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,8 +1747,8 @@ virtual public bool RemoveField(String name, int page) {
17471747
continue;
17481748
PdfIndirectReference refi = item.GetWidgetRef(k);
17491749
PdfDictionary wd = item.GetWidget( k );
1750-
PdfDictionary pageDic = reader.GetPageN(pageV);
1751-
PdfArray annots = pageDic.GetAsArray(PdfName.ANNOTS);
1750+
PdfDictionary pageDic = reader.GetPageN(pageV); //Returns null in case of floating, orphaned fields
1751+
PdfArray annots = pageDic != null ? pageDic.GetAsArray(PdfName.ANNOTS): null;//Account for floating, orphaned fields
17521752
if (annots != null) {
17531753
if (RemoveRefFromArray(annots, refi) == 0) {
17541754
pageDic.Remove(PdfName.ANNOTS);

0 commit comments

Comments
 (0)