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

Ability to set NeedAppearances value through config #740

Closed
vedantmamgain opened this issue Nov 24, 2023 · 11 comments
Closed

Ability to set NeedAppearances value through config #740

vedantmamgain opened this issue Nov 24, 2023 · 11 comments
Assignees

Comments

@vedantmamgain
Copy link

vedantmamgain commented Nov 24, 2023

Similar to pymupdf it would be great if we can have the ability to set NeedAppearances flag through pdfcpu. Currently I've to set this field in all of my pdf templates beforehand since I've faced issues with fields not rendering properly on some pdf viewers. Having the ability to set this field through pdfcpu would solve a major use case.

@hhrutter
Copy link
Collaborator

hhrutter commented Nov 24, 2023

OK - The necessity of setting this to true really depends on the PDF form you are dealing with.
Eg forms created by pdfcpu also create corresponding appearance streams.
Which use case are you exactly referring to and more to the point which pdfcpu operations are involved in your scenario?

@vedantmamgain
Copy link
Author

vedantmamgain commented Nov 24, 2023

@hhrutter These are pdfs created without pdfcpu, currently I use pymupdf for adding this flag since I've faced issue post filling fields in such pdfs but after adding the flag that issue was resolved. IIRC unipdf also supports adding the NeedsAppearence field as part of a config that you can pass pre filling or performing form operations. This is the only thing missing in pdfcpu right now other than it covering all my use cases, so would be greatful if it can be added as well.

@hhrutter
Copy link
Collaborator

hhrutter commented Nov 27, 2023

What PDF viewers do you use for looking at your filled PDF forms?
I am asking because the support for NeedAppearances varies.
Since pdfcpu is taking care of the appearance streams while generating as well as filling PDF forms
I recommend to turn this off which may already be the justification for a config flag.

It looks like you have a need to turn this on after filling with pdfcpu..
Please elaborate since the idea is that pdfcpu takes care of the appearance of fields across the board and
if there is an issue I'd like to get to the bottom of this.

Thank you for using pdfcpu 💚

@vedantmamgain
Copy link
Author

@hhrutter I've faced this issue with Adobe Reader as well as browsers such as Arc and Chrome. I noticed the following ->

  1. I filled a pdf using pdfcpu. This pdf is public I added some form fields in it.
  2. I'm able to view most of the fields without any issue but for some I saw that some fields aren't visible till they were clicked on. I had raised an issue about this here.
  3. After looking in the internet I found that if I were to add the NeedsAppearence flag in the original pdf then this issue should be resolved which actually happened. Post adding the flag on pdfs I saw that the issue of fields not rendering was resolved. I've faced this issue on multiple devices and on multiple pdfs.
  4. Hence my suggestion was similar to other pdf filling libraries if we can have the option of adding this field to pdfs through config to ensure that rendering issues aren't repeated.

@hhrutter
Copy link
Collaborator

My point is that any form filled by pdfcpu should have NeedAppearances turned off.
Also as of PDF 2.0 NeedAppearances is deprecated and any PDFWriter filling forms is expected to take care of all appearance streams.

It would be awesome if you could share a simple file before and after filling for a thorough analysis and possibly a fix.
Setting NeedAppearances to true can only be a last resort, but like I said that can't be an option in the long term.

@vedantmamgain
Copy link
Author

@hhrutter Yes ideally we want to resolve the appearance issues to be resolved before PDF 2.0 is adopted by PDFCPU. Sharing the files on email

@hhrutter
Copy link
Collaborator

hhrutter commented Dec 1, 2023

Did you send me anything, because I haven't gotten anything..

@vedantmamgain
Copy link
Author

@hhrutter Shared the updated files

@hhrutter
Copy link
Collaborator

Your input file is suspicious, because it was already filled by some PDFWriter yet the included appearance streams don't get picked up by PDF Viewers. So definitely something strange about this file..

Anyhow, this is part of https://github.com/pdfcpu/pdfcpu/releases/tag/v0.6.0

@vedantmamgain
Copy link
Author

@hhrutter Thanks a lot for resolving this. Curious to know what was the bug and how was it resolved.

@hhrutter
Copy link
Collaborator

Hey,

Like I said the file you were sharing is troublesome, because viewers did not render the form field values (the form was already filled) even before trying to fill with pdfcpu, eg. that must be a subtle problem with the provided appearance streams.

.. So I just added needAppearances to the configuration as per your request.
This is only a last resort if appearance streams don't get picked up by Viewers after filling.
It's default is: false and that would also be my recommendation generally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants