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

Data in filled forms is shown as blank when you print the pdf, but filled when you view on computer #1903

Closed
Crowdedlight opened this issue Jul 7, 2023 · 6 comments
Labels
feature New feature that should be supported
Milestone

Comments

@Crowdedlight
Copy link

When generating PDF having form fields with weasyprint and then filled using Adobe Reader DC (optionally signed), the filled data is saved and shown when viewing the document on the computer, but when printing it all form fields are blank as if they have never been filled.

Taking the same document and making a new form field in PDF Suite or Acrobat Pro, then filling it, and that one field then works. It feels like weasyprint need to set an attribute or something on the generated form fields, to allow the data in them to be printed.

I have tried to print both "as image" and normally and none of them includes the form data. I have selected the print option to include "document and form data".

The pdf on the computer show:
billede

And the output when saved, signed and printed to file with "Microsoft print to file":
billede

Reading the adobe documentation it seems like there are some options for form fields:
billede

But I am not sure what the option is coded to at this point and didn't see any obvious way to tell weasyprint what setting to use?
I am trying to make a custom finisher to see if I could detect fields that were form inputs and explicitly set that configuration to visible, but I am not well versed in the PDF specification, so I am not sure how to detect form fields and set this specific option from the given pydyf.PDF object.

@liZe
Copy link
Member

liZe commented Jul 7, 2023

Hi!

Thanks for this bug report.

Reading the adobe documentation it seems like there are some options for form fields:

Where did you find this option? I can’t find this sentence in the specification.

@Crowdedlight
Copy link
Author

I read it on the adobe website: https://helpx.adobe.com/acrobat/using/pdf-form-field-properties.html
A bit down on that page under "General tab for form field properties".

In hindsight this might be acrobat specific? I didn't find it when searching in the specification: https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf

I did find this in Table 22. It mentions some flags needed to be allowed for print.
billede

Table 165 in the specification does mention bits/flags set for annotations and it seems like they have the print flags option. But unsure if that also applies to widgets?
billede

Is there a way to see the raw data of a pdf to compare it? As I got one manually created in PDF Suite that can print with the entered form data, and one from weasyprint that makes them blank on print. But haven't found an easy way to compare the raw data between them to see what the difference is in those fields.

@liZe
Copy link
Member

liZe commented Jul 8, 2023

Is there a way to see the raw data of a pdf to compare it? As I got one manually created in PDF Suite that can print with the entered form data, and one from weasyprint that makes them blank on print. But haven't found an easy way to compare the raw data between them to see what the difference is in those fields.

It’s a bit complex to read PDF because some parts are compressed, but if you can generate and share a very small and simple document that includes a printable field, we can probably find the flag we need to set.

@Crowdedlight
Copy link
Author

Crowdedlight commented Jul 8, 2023

I made a blank pdf that only has a single text field as form input. One made with PDF Suite that shows the data when printing, and one made with weasyprint that doesn't show the data when printing. Both used Adobe Reader on Windows 11 to fill in the data and save the pdf with data.

PDF Suite, that works:
form_debug_pdfsuite_printing.pdf

Weasyprint:
form_debug_weasyprint_not_printing.pdf

@liZe
Copy link
Member

liZe commented Jul 9, 2023

Thanks!

You were right, that’s fixed by setting the "Print" flag.

@liZe liZe closed this as completed in 75dd745 Jul 9, 2023
@liZe liZe added the feature New feature that should be supported label Jul 9, 2023
@liZe liZe added this to the 60.0 milestone Jul 9, 2023
@Crowdedlight
Copy link
Author

Ah, perfect. Thank you very much for the very rapid fix and response! :)

netbsd-srcmastr referenced this issue in NetBSD/pkgsrc Oct 15, 2023
Version 60.1
------------

Released on 2023-09-29.

Bug fixes:

* `#1973 <https://github.com/Kozea/WeasyPrint/issues/1973>`_:
  Fix crash caused by wrong UTF-8 indices


Version 60.0
------------

Released on 2023-09-25.

New features:

* `#1903 <https://github.com/Kozea/WeasyPrint/issues/1903>`_:
  Print form fields
* `#1922 <https://github.com/Kozea/WeasyPrint/pull/1922>`_:
  Add support for textLength and lengthAdjust in SVG text elements
* `#1965 <https://github.com/Kozea/WeasyPrint/issues/1965>`_:
  Handle <wbr> tag
* `#1970 <https://github.com/Kozea/WeasyPrint/pull/1970>`_:
  Handle y offset of glyphs
* `#1909 <https://github.com/Kozea/WeasyPrint/issues/1909>`_:
  Add a --timeout option

Bug fixes:

* `#1887 <https://github.com/Kozea/WeasyPrint/pull/1887>`_:
  Fix footnote-call displayed incorrectly for some fonts
* `#1890 <https://github.com/Kozea/WeasyPrint/pull/1890>`_:
  Fix page-margin boxes layout algorithm
* `#1908 <https://github.com/Kozea/WeasyPrint/pull/1908>`_:
  Fix IndexError when rendering PDF version 1.4
* `#1906 <https://github.com/Kozea/WeasyPrint/issues/1906>`_:
  Apply text transformations to first-letter pseudo elements
* `#1915 <https://github.com/Kozea/WeasyPrint/pull/1915>`_:
  Avoid footnote appearing before its call
* `#1934 <https://github.com/Kozea/WeasyPrint/pull/1934>`_:
  Fix balance before "column-span: all"
* `#1935 <https://github.com/Kozea/WeasyPrint/issues/1935>`_:
  Only draw required glyph with OpenType-SVG fonts
* `#1595 <https://github.com/Kozea/WeasyPrint/issues/1595>`_:
  Don’t draw clipPath when defined after reference
* `#1895 <https://github.com/Kozea/WeasyPrint/pull/1895>`_:
  Don’t ignore min-width when computing cell size
* `#1899 <https://github.com/Kozea/WeasyPrint/pull/1899>`_:
  Fix named pages inheritance
* `#1936 <https://github.com/Kozea/WeasyPrint/pull/1936>`_:
  Avoid page breaks caused by children of overflow hidden boxes
* `#1943 <https://github.com/Kozea/WeasyPrint/issues/1943>`_:
  Use bleed area for page’s painting area
* `#1946 <https://github.com/Kozea/WeasyPrint/issues/1946>`_:
  Use margin box of children to define available width for leaders
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature that should be supported
Projects
None yet
Development

No branches or pull requests

2 participants