Just an update on the Flatten() function of PDFsharp.
Even on the latest 1.5 beta Flatten() does not work truly. I hit the issue as described above where output pdf does not open properly in mainstream readers.
When I was checking ABCPDF where it has .Stamp() function similar to Flatten, realized it does remove the fields .
So when I searched forums about this I came across the post from (void)
viewtopic.php?f=2&t=3369 (instruction on how to apply his patch to the main branch)
viewtopic.php?f=3&t=3778 (further updates with link to github)
and downloaded his branch
https://github.com/packdat/PDFsharp/tree/AcroFormsinstalled 4.6.1 net runtime devpack and compiled release
replacing the PdfSharp.dll file with this and re-testing doc.Flatten() does indeed did the trick and truly Flatten the document.
Now I can open the file in ios pdf reader or Acrobat app properly - as expected.
I am not sure why the post and feedback by (void) was not taken into consideration after many years....