Form fields not appearing after 4 pages - continued

This is Form fields not appearing after 4 pages continued. @Logan I tried 7.1.1 and 7.1.2, it fixed the zoom issue, but the form field issue is back. If you try with the PDF I attached in #294, you can reproduce the issue (the form fields are not coming after page 1 there are form fields in page 3, 5, 7, 9 etc.). Also there is a new bug, when the code tries to assign value to the form field:

TypeError: Cannot read property 'struct' of undefined
at PDFJSDocumentType.js:2278
at PDFJSDocumentType.js:2300
error @ PDFJSDocumentType.js:99

Not sure from where the error occurs, but the form fields are not updating with new values assigned by the application code (in 6.3.2 and 7.1.0, there was no issue for the same code). This is the code that is in the application:

const fillForm = data => {
        docViewer.getAnnotationsLoadedPromise().then(() => {
          const fieldManager = annotManager.getFieldManager();
          fieldManager.forEachField(field => {
            const value = data[field.name] || "";
            field.setValue(value);
          });
        });
      };

So, these are the issues I have faced in each version:

  • 6.3.2 - Form fields not appearing after page 4 for attached PDF
  • 7.1.0 - PDF not appearing (form fields are appearing above it though) for high zoom levels
  • 7.1.1 - Zoom issue fixed, but form fields are not appearing after page 1 for attached PDF. Also, there is a new bug that I mentioned above
  • 7.1.2 - same as 7.1.1

Hi there!

I cannot reproduce any of your issues in 7.1.2 on the document linked in #294 (MAWB8CopiesF.pdf).

When you change version, can you please make sure all files from the old version are deleted and the cache is clear. Sometimes files not getting overwritten can cause issues. We actually recommend changing the folder WebViewer is served from based on the version. So instead of /lib/pdfjsexpress, you would do something like /lib/pdfjsexpress/7.1.2/

You may also run into issues if you try setting the form fields before annotations are done loading. Make sure you wait for the annotationsLoaded event before setting form fields.

  docViewer.one('annotationsLoaded', () => {
    docViewer.getAnnotationsLoadedPromise().then(() => {
      const fieldManager = annotManager.getFieldManager();
      fieldManager.forEachField(field => {
        const value = "Hello world";
        field.setValue(value);
      });
    });
  })

If none of these work, can you please send us a bit more code so we can see the timing of all your API calls.

Thanks!
Logan

@Logan I have added code to reproduce the issue here https://github.com/princejoseph/pdfjs-express-react-sample . These are the changes I made https://github.com/pdfjs-express/pdfjs-express-react-sample/compare/master...princejoseph:master

You have to copy the files for 7.1.2 at public/webviewer/7.1.2 folder and you will be able to see both issues I am saying. If you want I can remove the gitignore and add those files as well.

If you change the path to /webviewer/lib in src/App.js you will be able to see the values being correctly replaced.

1 Like

Hi!

First of all, thank you so much for the repo, that helps us a lot!

There is a couple things going on here. Firstly, Express is getting imported into the project twice, once in public/index.html and once in src/App.js, which can cause issues. Removing the script tag from index.hrml removed some of the errors that were getting thrown.

There’s also another error getting thrown, Cannot read property 'struct' of undefined at certain screen sizes. This is a known issue and will be fixed in the next release. I believe this is what is causing the form fields to not display sometimes.

A decent workaround for now is disabling the FitWidth fit mode, so commenting out this line: instance.setFitMode(FitMode.FitWidth);

Keep an eye out for the next release!

Thanks,
Logan

@Logan I actually forked from pdfjsexpress example react repo https://github.com/pdfjs-express/pdfjs-express-react-sample, so was not aware of the script tag being imported twice. Also, for our users, it is not usable without FitWidth or atleast a good zoom level as the default fit mode is too small to input anything to the form fields

Even without fitmode, there is a lag in the form to render with values.

Yes we will fix the sample to not import WebViewer twice!

As mentioned, we will have a fix for the error you are having in the next release.

Thanks,
Logan

1 Like

We have the same problem. Do you know when this will be fixed.

I attach the PDF with the form that are not working. Do you know why ?Example not working with form pdf