PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

Exception in PdfPage.HasAnnotations when no annotations on p
http://forum.pdfsharp.com/viewtopic.php?f=3&t=3658
Page 1 of 1

Author:  PeterEm [ Fri Sep 08, 2017 9:12 pm ]
Post subject:  Exception in PdfPage.HasAnnotations when no annotations on p

This is from https://github.com/empira/PDFsharp/ which I just pulled down today. In PdfPage.cs line 383

The code throws an exception if the page does not have annotations because it tries to assign `this` when it have already established that _annotations is null, and GetValue doesn't create a new object.

Code:
public bool HasAnnotations
 {
        get
        {
            if (_annotations == null)
            {
                // Get annotations array if exists.
                _annotations = (PdfAnnotations)Elements.GetValue(Keys.Annots);
                _annotations.Page = this;
            }
            return _annotations != null;
        }
  }

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/