Skip to content

Fix: Ensure PdfForm is returned even when acroForm has no fields #2333

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

Conversation

tungthanh1497
Copy link

Summary

This pull request fixes an issue in the PdfDocument.form getter where the form would not be returned if the acroForm existed in the catalog but contained no fields (fields.count == 0).

As a result, _form would remain null, leading to inconsistent behavior or potential null access elsewhere in the code.

What was changed

  • Moved the return statement outside the if (_form!.fields.count != 0) condition.
  • Ensured _form is always returned once initialized, regardless of the number of fields.

Why is this needed?

In some PDF documents, the acroForm dictionary exists but does not yet have any form fields (e.g., newly created or partially filled forms). Without this fix, attempting to access form would result in a null, which may cause exceptions or unexpected behavior in consumer code.

How to test

  • Open a PDF document with an empty acroForm dictionary.
  • Call document.form and ensure it returns a valid PdfForm instance, not null.
  • Ensure no exceptions are thrown during the access.

@VijayakumarMariappan VijayakumarMariappan added pdf PDF component open Open labels Apr 16, 2025
@SF2381
Copy link

SF2381 commented Apr 22, 2025

Hi @tungthanh1497 ,

Thank you for the information. We are currently working on this issue and plan to include the fix in our upcoming release, which is expected to be available on April 29, 2025.

With regards,
Anand P

@LavanyaGowtham2021 LavanyaGowtham2021 added follow-up scheduled Follow-up scheduled and removed open Open labels May 20, 2025
@chinnumuniyappan
Copy link
Collaborator

Hi @tungthanh1497 ,

Thank you for your patience. The fix has been included in our weekly release dated April 29, 2025, with version 29.1.40. You can access the updated package using the following link:
https://pub.dev/packages/syncfusion_flutter_pdf

This source will be updated only as part of our main releases. Our upcoming Volume 2 main release is scheduled for the end of June 2025.

Regards,
Chinnu M

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
follow-up scheduled Follow-up scheduled pdf PDF component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants