Post

Replies

Boosts

Views

Activity

Reply to PDF Widget Annotations Disappear After Saving in PDFKit (including with Preview)
The following Swift script reproduces this problem. // PDF Widget Annotations Disappear After Saving in PDFKit (Demo) // Feedback report: FB24866826 import Foundation import PDFKit // PART 1: Creates a new "original" PDF that contains a page with a checkbox. // The PDF syntax in the resulting file (output1.pdf) is properly formatted. let fileURL = URL(fileURLWithPath: "output1.pdf") // Create a new PDF document with a new, blank page in document let pdfDocument = PDFDocument() let pdfPage = PDFPage() pdfDocument.insert(pdfPage, at: 0) // Create new checkbox widget annotation let checkbox = PDFAnnotation( bounds: CGRect(x: 100, y: 500, width: 20, height: 20), forType: .widget, withProperties: nil) checkbox.widgetFieldType = .button checkbox.widgetControlType = .checkBoxControl // Add checkbox to page pdfPage.addAnnotation(checkbox) // Write document to file if pdfDocument.write(to: fileURL) { print("1. PDF successfully saved to \(fileURL.path)") } else { print("1. Failed to save PDF.") exit(1) } // PART 2: Opens file created in Part 1, updates checkbox state, and writes to new file. // The PDF syntax in the resulting file (output2.pdf) is not properly formatted. // Open document from PDF file created in Part 1 guard let openedDocument = PDFDocument(url: fileURL) else { print("Failed to open \(fileURL.path).") exit(1) } // Get the first page guard let firstPage = openedDocument.page(at: 0) else { print("No pages found in \(fileURL.path).") exit(1) } // Get first annotation on page (this should be the checkbox) guard let checkbox = firstPage.annotations.first else { print("No annotations found in \(fileURL.path).") exit(1) } // Update checkbox state to "on" checkbox.buttonWidgetState = .onState // Write document to second file let newFileURL = URL(fileURLWithPath: "output2.pdf") if openedDocument.write(to: newFileURL) { print("2. PDF successfully re-opened, modified, and saved to \(newFileURL.path)") } else { print("2. Failed to save the modified PDF to a new file.") }
Topic: App & System Services SubTopic: General Tags:
Sep ’26
Reply to SwiftUI toolbar in MacOS 15 bug ?
I was having the same (or similar) problem: crashing when more than one tab opens, resulting in the same error described in this discussion. The problem does seem to be related to a bug when the toolbar method is called on the NavigationSplitView view. I also found that the problem does not occur when toolbar is called on a subview within NavigationSplitView. In attempting to resolve this, I found that the problem also only occurs when the toolbar method is provided with a specific id parameter (i.e.: toolbar(id: "toolbar"){...}). If an id is not provided, I don't get an error. Hopefully this helps narrow-down and isolate the specific cause of the problem.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’24
Reply to Incorrect Metadata.appintents with Xcode 14.3?
I had the same (or similar) problem in trying to build a simple app that uses AppIntents to create an App Shortcut -- the same error appearing when running the App Shortcut in macOS. I was using Xcode 14.3 on macOS 13.4. Setting aside the problem, I upgraded to macOS 13.5 (Xcode remaining at 14.3) and now, strangely enough, the App Shortcut began working as expected. I was building a Multiplatform app and the error never appeared when running in iOS.
Topic: App & System Services SubTopic: General Tags:
Aug ’23
Reply to PDF Widget Annotations Disappear After Saving in PDFKit (including with Preview)
The following Swift script reproduces this problem. // PDF Widget Annotations Disappear After Saving in PDFKit (Demo) // Feedback report: FB24866826 import Foundation import PDFKit // PART 1: Creates a new "original" PDF that contains a page with a checkbox. // The PDF syntax in the resulting file (output1.pdf) is properly formatted. let fileURL = URL(fileURLWithPath: "output1.pdf") // Create a new PDF document with a new, blank page in document let pdfDocument = PDFDocument() let pdfPage = PDFPage() pdfDocument.insert(pdfPage, at: 0) // Create new checkbox widget annotation let checkbox = PDFAnnotation( bounds: CGRect(x: 100, y: 500, width: 20, height: 20), forType: .widget, withProperties: nil) checkbox.widgetFieldType = .button checkbox.widgetControlType = .checkBoxControl // Add checkbox to page pdfPage.addAnnotation(checkbox) // Write document to file if pdfDocument.write(to: fileURL) { print("1. PDF successfully saved to \(fileURL.path)") } else { print("1. Failed to save PDF.") exit(1) } // PART 2: Opens file created in Part 1, updates checkbox state, and writes to new file. // The PDF syntax in the resulting file (output2.pdf) is not properly formatted. // Open document from PDF file created in Part 1 guard let openedDocument = PDFDocument(url: fileURL) else { print("Failed to open \(fileURL.path).") exit(1) } // Get the first page guard let firstPage = openedDocument.page(at: 0) else { print("No pages found in \(fileURL.path).") exit(1) } // Get first annotation on page (this should be the checkbox) guard let checkbox = firstPage.annotations.first else { print("No annotations found in \(fileURL.path).") exit(1) } // Update checkbox state to "on" checkbox.buttonWidgetState = .onState // Write document to second file let newFileURL = URL(fileURLWithPath: "output2.pdf") if openedDocument.write(to: newFileURL) { print("2. PDF successfully re-opened, modified, and saved to \(newFileURL.path)") } else { print("2. Failed to save the modified PDF to a new file.") }
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Sep ’26
Reply to PDF Widget Annotations appear Pixelated/Rasterized
Also related to problems with PDFKit rendering widget annotations: when a user toggles radio buttons or checkboxes in a PDF using Preview, the widgets disappear following subsequent interactions after the file is saved and reopened. PDF Widget Annotations Disappear After Saving in PDFKit (including with Preview)
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Sep ’26
Reply to SwiftUI toolbar in MacOS 15 bug ?
I was having the same (or similar) problem: crashing when more than one tab opens, resulting in the same error described in this discussion. The problem does seem to be related to a bug when the toolbar method is called on the NavigationSplitView view. I also found that the problem does not occur when toolbar is called on a subview within NavigationSplitView. In attempting to resolve this, I found that the problem also only occurs when the toolbar method is provided with a specific id parameter (i.e.: toolbar(id: "toolbar"){...}). If an id is not provided, I don't get an error. Hopefully this helps narrow-down and isolate the specific cause of the problem.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’24
Reply to Incorrect Metadata.appintents with Xcode 14.3?
I had the same (or similar) problem in trying to build a simple app that uses AppIntents to create an App Shortcut -- the same error appearing when running the App Shortcut in macOS. I was using Xcode 14.3 on macOS 13.4. Setting aside the problem, I upgraded to macOS 13.5 (Xcode remaining at 14.3) and now, strangely enough, the App Shortcut began working as expected. I was building a Multiplatform app and the error never appeared when running in iOS.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Aug ’23