Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PdfDocument::Flatten() improperly named; doesn't flatten form fields #71

Open
LittleBoxOfSunshine opened this issue Oct 18, 2018 · 2 comments
Labels
enhancement suggestion Suggestion or feature request

Comments

@LittleBoxOfSunshine
Copy link

Reporting an Issue Here

https://github.com/empira/PDFsharp/blob/5aa7afeb13270aaca36ad21edcf3cc62d6c5446c/src/PdfSharp/Pdf/PdfDocument.cs#L854-L863

Form flattening has a specific meaning in PDFs where the form fields will be removed as a result of the process. In many circumstances, flattening is just used to disable editing but it has other side effects such as changing the document structure and reducing file size that specific use cases are dependent on. Form flattening is non-trivial to implement, and while this workaround accomplishes the desired effect in some use cases it introduces confusing bugs when the user is performing actions dependent on the form being truly "flattened". In my opinion this function is useful but should be given a different name such as MakeReadOnly, ReadOnly, DisableEditing, etc. that doesn't conflict with the common meaning of flatten.

Expected Behavior

The form fields will be removed and replaced with their contents as regular markup objects

Actual Behavior

The form fields are set to read only mode.

This is a great project that has been extremely useful for me, and I'm definitely nitpicking here but I think it's worth considering so that other consumers of the library don't end up down the same confusing debugging road I did. Thanks for the great work!

@MoishyS
Copy link

MoishyS commented Dec 25, 2018

Would be great if you can add real flattening (basically all "print to PDF" are doing it)
http://forum.pdfsharp.com/viewtopic.php?f=3&t=3783&view=next#p11641

@derekdevv
Copy link

I tried forked version :
https://github.com/packdat/PDFsharp/tree/AcroForms

and its flatten method is flattening my text fields properly (except there's a slight alignment issue).
Hope this info will help future implementation of the flatten method.

@ThomasHoevel ThomasHoevel added enhancement suggestion Suggestion or feature request labels Apr 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement suggestion Suggestion or feature request
Projects
None yet
Development

No branches or pull requests

4 participants