stephanrauh / ngx-extended-pdf-viewer

A full-blown PDF viewer for Angular 16, 17, and beyond
https://pdfviewer.net
Apache License 2.0
473 stars 181 forks source link

Problem downloading/printing PDF form with values #1887

Closed Sergiobop closed 11 months ago

Sergiobop commented 12 months ago

Describe the bug I think this is a bug (or i'm doing something wrong?). This worked in previous versions. https://pdfviewer.net/extended-pdf-viewer/forms

Try to download or print the PDF, the form is empty even though is filled previously

1: The form is filled:

Captura de pantalla 2023-09-26 a las 10 56 35

2: Print the PDF using the print button:

Captura de pantalla 2023-09-26 a las 10 56 43

3: Download the PDF using the download button:

Captura de pantalla 2023-09-26 a las 10 56 56

Version info

Demo PDF file Just check the DEMO page, the error is there too

stephanrauh commented 12 months ago

What? Oh no! That's unexpected and annoying!

Confused question: How could this bug slip my (and everybody's) attention after such a long a long beta phase?

Sergiobop commented 11 months ago

Hello @stephanrauh

I have been investigating this error. I'll tell you what I've found out:

The "values" of all annotations are empty/undefined even though you passed the formData object with values. (formData is not synced with the annotation values)

It seems that you have to update and synchronize the PDF form values (annotations) with the formData values.

In the DEMO page (https://pdfviewer.net/extended-pdf-viewer/forms)

  1. Update Lucía to Lucías by hand:
Captura de pantalla 2023-10-02 a las 10 52 46
  1. Print the PDF:

    Captura de pantalla 2023-10-02 a las 10 52 57
  2. Only Lucías is filled correctly while printing/downloading.

I suspect the problem is somewhere in here: https://github.com/stephanrauh/ngx-extended-pdf-viewer/blob/main/projects/ngx-extended-pdf-viewer/src/lib/ngx-form-support.ts

Maybe the setFieldValueAndUpdateAnnotationStorage method? Idk

Thanks

stephanrauh commented 11 months ago

I'm afraid that sounds like an exhausting debugging session. I just wonder what went wrong?

At the moment, I'm very busy. I've put your ticket on the top of my pile of work, but even so, it might take a while until I manage to investigate and to solve the issue. Stay tuned!

stephanrauh commented 11 months ago

I've managed to reproduce the issue. Funny thing is that checkboxes still work.

stephanrauh commented 11 months ago

This seems to be an old bug. I need to back-port the solution to version 17, too.

stephanrauh commented 11 months ago

I've observed a weird side-effect: when printing, the document is still visible in the background, but the fields are cleared (even after applying my bugfix).

Sergiobop commented 11 months ago

This seems to be an old bug. I need to back-port the solution to version 17, too.

Yeah, that's what i was about to say. The bug appeared sometime in version 17. I tried to downgrade and still appeared. Can't say when it started though.

Thank you for working on this

stephanrauh commented 11 months ago

The bugfix has landed with version 17.4.8 and 18.1.1.

As far as I can see, I've added the bug six months ago with version 17.0.0-alpha.3. It's astonishing that nobody reported it before. Be that as it may, now it works.

Enjoy! Stephan

Sergiobop commented 11 months ago

Thanks a lot @stephanrauh (Npm is on 18.1.0 though)

Will try it when you do a new release.

stephanrauh commented 11 months ago

@Sergiobop Maybe you've run into a caching problem - either on your side, or maybe npm distributes the new version slowly. I've double-checked it, my browser shows the new version. For some reason, it marks version 17.4.8 to be the current version, but that's just a tiny nuisance. :)

grafik