The following situation is given:
In your code you have a PDFDocument object. This contains a PDF file with form fields that are filled with text.
If you call the dataRepresentation() method on this PDFDocument object, you get back a data object:
let myDocumentData: Data = pdfDocument.dataRepresentation()!
If you now want to initialize a new PDFDocument object with this data object, the contents of the form fields are duplicated within the PDF.
let newPDF: PDFDocument = PDFDocument(data: myDocumentData)
If you now want to print the newPDF PDFDocument object by creating a new print job, you will get the following result:
What you actually expect to see:
You only see this behavior when you want to print or share the PDF. You won't see this behaviour inside a PDF View in your application.
This behaviour only appears since iOS/iPadOS 17.2
Steps to reproduce:
Get a PDF file with form fields, especially text fields
fill out these text fields with text
create a PDFDocument object with this PDF file
call the dataRepresentation() method on this PDFDocument object and store the result in a new variable
create a new PDFDocument object with the data object created in the previous step:PDFDocument(data: <data>)
Print the new created PDFDocument within iOS/iPadOS 17.2 or share it for example via email
I hope Apple will fix this bug soon!