iOS 27: Removing annotations from a PDFPage.copy() also removes them from the original page

This thread has been locked by a moderator; it no longer accepts new replies.

Since iOS 27.0, PDFPage.copy() seems to share annotations with the original page.
When I remove annotations from the copied page, the annotations on the original page are also removed.

Environment

  • Reproduces: iOS 27.0 (Simulator), iOS 27.2 (Simulator), iPadOS 27.2.1 (iPad 9th generation)
  • Does not reproduce: iOS 26.4, iOS 26.5, iPadOS 26.7.2
  • Xcode ____, Swift 5 mode

Steps to reproduce

  1. Prepare a PDF whose first page already has annotations saved in the file (e.g. ink or stamp annotations).
  2. Load it with PDFDocument(data:).
  3. Without displaying page 0 and without reading page.annotations, call copy() on page 0.
  4. Remove all annotations from the copied page.
  5. Check the annotations of the original page 0.
import PDFKit

func reproduce(pdfData: Data) {
    guard let document = PDFDocument(data: pdfData),
          let original = document.page(at: 0),
          let copied = original.copy() as? PDFPage else { return }

    // Do NOT touch original.annotations before copy()
    for annotation in copied.annotations {
        copied.removeAnnotation(annotation)
    }

    print("original annotations:", original.annotations.count)
    // iOS 26.x : the original count is kept
    // iOS 27.x : 0 (the annotations on the original page are gone)
}

Expected result
The original page keeps its annotations. The copy should be independent of the original.

Actual result
The original page loses its annotations. When the document is saved with dataRepresentation(), the annotations on page 1 are either missing or written with an empty appearance stream (/BBox [0 0 0 0], content q Q).

Additional notes

  • The annotations are not lost if page 0 is rendered, or if original.annotations is read once, before calling copy(). It looks like the copy shares the annotation storage while the annotations are still lazily loaded.
  • The original annotations are removed even if the copied page is never inserted into the document.
  • Workaround: create a separate PDFDocument from the same data and use its page instead of copy().

Is this an intended behavior change in iOS 27, or a bug?

Answered by DTS Engineer in 919460022

Let’s focus this discussion on your other thread.

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Let’s focus this discussion on your other thread.

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"