Thank you TH-Soft.
The update from beta 4 to beta 5 solved this issue!
Edit:
Sorry to open this issue up again, but I have to specify that the issue is only solved when generating new PDFs. However if I open an existing protrected PDF and add a watermark and a footer and try to save it by using the same code
Code:
pdfSharpDoc.SecuritySettings.DocumentSecurityLevel = PdfSharp.Pdf.Security.PdfDocumentSecurityLevel.Encrypted128Bit;
pdfSharpDoc.SecuritySettings.UserPassword = txtbPassword.Text;
pdfSharpDoc.SecuritySettings.OwnerPassword = txtbOwnerPassword.Text;
pdfSharpDoc.SecuritySettings.PermitAccessibilityExtractContent = false;
pdfSharpDoc.SecuritySettings.PermitAnnotations = false;
pdfSharpDoc.SecuritySettings.PermitAssembleDocument = false;
pdfSharpDoc.SecuritySettings.PermitExtractContent = false;
pdfSharpDoc.SecuritySettings.PermitFormsFill = false;
pdfSharpDoc.SecuritySettings.PermitFullQualityPrint = false;
pdfSharpDoc.SecuritySettings.PermitModifyDocument = false;
pdfSharpDoc.SecuritySettings.PermitPrint = false;
pdfSharpDoc.Save(filename);
the outlines again are messed up the same way.
To add a watermark I used the code found in the wiki.
When I leave out the protection of a watermarked I get:
Quote:
PrepareForSave: Number of deleted unreachable objects: 1
I think this is because the protected object is now no longer needed, and there for unreachable.
However in this case the outlines are fine.
Also if I create a not protected PDF, then watermark it and protect it, the outlines are fine too.
Ok I have found a workaround.
1) Open and read the file (IO) file with OwnerPassword.
2) Save the file immeadiately (Doc2)
3) Open this new Doc2 and watermark it
4) Save this file with UserPassword and OwnerPassword.
Now the outlines are fine. However I don't like the fact that the file is unprotected for a moment. Which means it is at some point vulnerable.
I try to solve this issue.