intbot / ng2-pdfjs-viewer

An angular component for PDFJS and ViewerJS (Supports all versions of angular)
Apache License 2.0
228 stars 113 forks source link

PDF open but signature not displaying. #112

Open Paul75 opened 4 years ago

Paul75 commented 4 years ago

hello,

I have a PDF it read but not all in document appear. In the document I have a signature that not display. It display good with app Adobe Acrobat Reader. With other (only test one) ng2-pdf-viewer it display good ...

Thanks

codehippie1 commented 3 years ago

Can you try with mozilla's pdf.js directly. This angular component uses pdf.js behind the scenes

codehippie1 commented 3 years ago

@Paul75 Also, can you send me the file you are trying with?

LAlves91 commented 3 years ago

Hi @Paul75 !

This library uses a local copy of PDF.js underneath. Currently, this copy is of PDF.js v2.2.171, which is the cause of your problem: PDF.js didn't display Digital Signature Widgets until v2.9.359 (implemented on pull request #13214).

In order to display digital signatures, you'll have to use your own version of pdf.worker.js (I'm still studying this library's code, so I don't know if there's a simple way of doing it), with a minor modification:

@@ -28213,8 +28213,9 @@ function () {
             case 'Ch':
               return new ChoiceWidgetAnnotation(parameters);
           }
-
-          (0, _util.warn)('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
+          if (fieldType !== 'Sig') {
+            (0, _util.warn)('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
+          }
           return new WidgetAnnotation(parameters);

         case 'Popup':
@@ -28684,7 +28685,7 @@ function (_Annotation) {
     if (data.fieldType === 'Sig') {
       data.fieldValue = null;

-      _this2.setFlags(_util.AnnotationFlag.HIDDEN);
+      // _this2.setFlags(_util.AnnotationFlag.HIDDEN);
     }

     return _this2;

From what I've seen so far, you'll have to assign the path of your worker to PDF.js:

import * as PDFJS from 'path/to/pdfjs/build/pdf';

PDFJS.GlobalWorkerOptions['workerSrc'] = 'path/to/your/worker.js';

Cheers!

clainchoupi commented 2 years ago

Hi guys, I have a similar issue for one of my project.

Do you know if it is related to the use of an old version of PDF.js ? Is there a workaround for this issue ?

Let me know if I can be of any help :P Cheers Pierre