PDF.js Express Custom annotations

We are trying to get the PDF js annotations to work. I tried downloading the sourcecode at https://github.com/pdfjs-express/custom-annotation-samples but I keep getting below error.
I may be missing some steps or doing something wrong, I followed the steps on the readme file. I would really appreciate if someone can help me with more detailed steps or help troubleshooting.

custom-annotation-samples@1.0.0 copy C:\Users\xxxx\Downloads\custom-annotation-samples-master\custom-annotation-samples-master
cross-env rm -rf static/lib && cp -a node_modules/@pdftron/pdfjs-express/public/. static/lib && cp -a node_modules/@pdftron/pdfjs-express/webviewer.min.js static/lib/webviewer.min.js

‘rm’ is not recognized as an internal or external command,
operable program or batch file.
events.js:291
throw er; // Unhandled ‘error’ event
^

Error: spawn rm ENOENT
at notFoundError (C:\Users\xxxx\Downloads\custom-annotation-samples-master\custom-annotation-samples-master\node_modules\cross-spawn\lib\enoent.js:6:26)
at verifyENOENT (C:\Users\xxxx\Downloads\custom-annotation-samples-master\custom-annotation-samples-master\node_modules\cross-spawn\lib\enoent.js:40:16)
at ChildProcess.cp.emit (C:\Users\xxxx\Downloads\custom-annotation-samples-master\custom-annotation-samples-master\node_modules\cross-spawn\lib\enoent.js:27:25)
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
Emitted ‘error’ event on ChildProcess instance at:
at ChildProcess.cp.emit (C:\Users\xxxx\Downloads\custom-annotation-samples-master\custom-annotation-samples-master\node_modules\cross-spawn\lib\enoent.js:30:37)
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12) {
code: ‘ENOENT’,
errno: ‘ENOENT’,
syscall: ‘spawn rm’,
path: ‘rm’,
spawnargs: [ ‘-rf’, ‘static/lib’ ]
}

Hey there!

Thanks for trying out PDF.js Express.

I just pushed a fix to the repo that should fix that issue! Please pull the latest and try again.

Thanks,
Logan

1 Like

Wow, that was quick, I pulled the latest and it worked !! Thank you very much!

1 Like

Trying to push my luck here :grinning:
Can someone help me find the example code for signature field?
I am trying to get the functionality shown here https://pdfjs.express/documentation/signature/signature-field.

Hey there!

This should happen automatically without any code (if the document has a signature field).

If it doesn’t work on a document you have, let us know (and send us the document in question if possible).

Thanks!

Hello Logan,
I was trying the “createSignHereElement” code snippet. I copied it on one of the index.js files, but i dont see the “SignHere” element on my page. Am I missing something?

Code:
const createSignHereElement = Annotations.SignatureWidgetAnnotation.prototype.createSignHereElement;

Annotations.SignatureWidgetAnnotation.prototype.createSignHereElement = () => {
// signHereElement is the default one with dark blue background
const signHereElement = createSignHereElement.apply(this, arguments);

signHereElement.style.background = ‘red’;
return signHereElement;
}

Since custom annotations is working, we can close this one. I will create a new one for createSignHereElement . Thanks for the help!

1 Like