# Node-red-contrib-pdfjs, no output

**URL:** <https://discourse.nodered.org/t/node-red-contrib-pdfjs-no-output/31969>\
**Category:** General\
**Created:** [25 August 2020 07:00 UTC](https://discourse.nodered.org/t/node-red-contrib-pdfjs-no-output/31969 "2020-08-25T07:00:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArneR](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/arner/32/95658_2.png) [@ArneR](https://discourse.nodered.org/u/ArneR)\
**Post date:** [25 August 2020 07:00 UTC](https://discourse.nodered.org/t/node-red-contrib-pdfjs-no-output/31969/1 "2020-08-25T07:00:04Z")

</div>

Hey

I am trying to convert a pdf to text.  
I can already set up the PDf filename. However, I am not able to convert the PDF to text.  
I am using "node-red-contrib-pdfjs" but I am not getting any output.  
What am I doing wrong?

I create several PDFs according to the given username. At a later time I would like to read the most recent PDF from the specified user. The path to the file is correct.

I am using an NR server on Windows.

Thank you!

**Example flow:**

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/2/f28ea173a57c7537aae676cbd59919527fdb9737.png)

**Flow:**

```auto
[{"id":"a32031c0.1e4e6","type":"function","z":"90af3ff8.12c38","name":"Combine data","func":"var combined = [];\n\nfor (var i = 0; i < msg.files.length; i++) {\n var file = msg.files[i];\n var stat = msg.stats[i];\n \n combined.push({\n path: msg.payload,\n file,\n ...stat\n })\n}\n\ncombined.sort((a, b) => b.birthtimeMs - a.birthtimeMs);\n\nmsg.combined = combined;\n\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2540,"y":1980,"wires":[["cb7bfed7.2054a"]]},{"id":"cb7bfed7.2054a","type":"change","z":"90af3ff8.12c38","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"combined[0]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2720,"y":1980,"wires":[["e2d8e2c0.ac175"]]},{"id":"708a4632.32f038","type":"comment","z":"90af3ff8.12c38","name":"Load last session","info":"","x":1800,"y":1940,"wires":[]},{"id":"a35ab831.b35fa8","type":"fs-ops-stats","z":"90af3ff8.12c38","name":"","path":"payload","pathType":"msg","filename":"files","filenameType":"msg","stats":"stats","sizeType":"msg","x":2380,"y":1980,"wires":[["a32031c0.1e4e6"]]},{"id":"875210a9.7dbcc","type":"fs-ops-dir","z":"90af3ff8.12c38","name":"","path":"payload","pathType":"msg","filter":"*.pdf","filterType":"str","dir":"files","dirType":"msg","x":2240,"y":1980,"wires":[["a35ab831.b35fa8"]]},{"id":"e6e9cd85.dc04a","type":"ui_button","z":"90af3ff8.12c38","name":"","group":"53c90cc8.980784","order":11,"width":0,"height":0,"passthru":false,"label":"Import last session","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":1810,"y":1980,"wires":[["6476160c.378168"]]},{"id":"6476160c.378168","type":"function","z":"90af3ff8.12c38","name":"Generate filepath user","func":"var voornaam = flow.get(\"rapportdata.voornaam\");\nvar achternaam = flow.get(\"rapportdata.achternaam\");\n\nvar bestand = \"C:/Users/Arne/Desktop/Rapport/\" + achternaam + \"_\" + voornaam + \"/\";\nmsg.payload = bestand;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2060,"y":1980,"wires":[["875210a9.7dbcc"]]},{"id":"e2d8e2c0.ac175","type":"function","z":"90af3ff8.12c38","name":"Total filepath","func":"var path = msg.payload.path\nvar file = msg.payload.file\n\nvar filepath = path + file; \nmsg.payload = filepath;\n\nreturn msg;\n\n\n// msg.payload = {file: filepath};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2030,"y":2040,"wires":[["973141e9.2019b"]]},{"id":"87182c66.4a1d3","type":"debug","z":"90af3ff8.12c38","name":"Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2370,"y":2040,"wires":[]},{"id":"973141e9.2019b","type":"pdf","z":"90af3ff8.12c38","name":"","filename":"","sortByY":false,"sortByX":false,"combineColumn":false,"combineRow":false,"x":2230,"y":2040,"wires":[["87182c66.4a1d3"],["87182c66.4a1d3"]],"outputLabels":["msg.payload",""]},{"id":"53c90cc8.980784","type":"ui_group","z":"","name":"Overzicht","tab":"8a5a79f8.19dec8","order":3,"disp":true,"width":"6","collapse":false},{"id":"8a5a79f8.19dec8","type":"ui_tab","z":"","name":"Automatische Mode","icon":"loop","order":3,"disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [25 August 2020 10:25 UTC](https://discourse.nodered.org/t/node-red-contrib-pdfjs-no-output/31969/2 "2020-08-25T10:25:29Z")

</div>

I 'think' (not realy clear in the documentation) that you need to send `msg.filename` into the node.

the experiment with this, create a flow `inject` -\> `pdfjs` -\> `debug` (set to display the complete msg object) and in the `inject` set 'msg.fileame' to the full path to the file

> #### filename
> 
> If a file path/object is not provided in the payload, A file path to a pdf file should be provided here to be decoded.

seems to me that this option should be called `filepath` not `filename`

---

<div class="post-metadata">

**Author:** ![ArneR](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/arner/32/95658_2.png) [@ArneR](https://discourse.nodered.org/u/ArneR)\
**Post date:** [25 August 2020 11:05 UTC](https://discourse.nodered.org/t/node-red-contrib-pdfjs-no-output/31969/3 "2020-08-25T11:05:35Z")

</div>

Hey  
Thanks for your reply.

I have already tried several things. I just tried the following again:

`inject`-\> `PDFjs` -\> `Debug msg`

If `msg.payload` points to the full pdf-path, I don't get a pulse on the debug node. In all other cases, I get an "error" in `msg.payload`. (Unless I enter the path in the option 'filename')

**Error:**  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/c/5cb21947fb5a58f3e43163f31bda1d2cec9dd919.png)

This is the correct path and the pdf exists.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [25 August 2020 11:32 UTC](https://discourse.nodered.org/t/node-red-contrib-pdfjs-no-output/31969/4 "2020-08-25T11:32:18Z")

</div>

I just tried the node and am hitting the same issue. If you put a `catch` node in th flow you will see an error cropping up.

You should raise an issue with the node developer in GitHub. I'd ask for better documentation as how to pass the path to the file into the node. I can't even get it to work with the path to the file hard coded into the node.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [25 August 2020 11:53 UTC](https://discourse.nodered.org/t/node-red-contrib-pdfjs-no-output/31969/5 "2020-08-25T11:53:14Z")

</div>

Check the NR log. I just noticed I'm seeing errors in it from the node

```auto
25 Aug 07:30:02 - [info] Started modified flows
(node:96628) UnhandledPromiseRejectionWarning: ReferenceError: ReadableStream is not defined
    at MessageHandler.sendWithStream (/Users/Paul/.node-red/node_modules/pdfjs-dist/build/pdf.worker.js:45460:5)
    at new PDFWorkerStreamReader (/Users/Paul/.node-red/node_modules/pdfjs-dist/build/pdf.worker.js:45833:45)
    at PDFWorkerStream.getFullReader (/Users/Paul/.node-red/node_modules/pdfjs-dist/build/pdf.worker.js:45797:31)
    at getPdfManager (/Users/Paul/.node-red/node_modules/pdfjs-dist/build/pdf.worker.js:306:35)
    at setupDoc (/Users/Paul/.node-red/node_modules/pdfjs-dist/build/pdf.worker.js:457:7)
    at wphReady (/Users/Paul/.node-red/node_modules/pdfjs-dist/build/pdf.worker.js:646:7)
    at LoopbackPort.MessageHandler._onComObjOnMessage (/Users/Paul/.node-red/node_modules/pdfjs-dist/build/pdf.worker.js:45410:7)
    at /Users/Paul/.node-red/node_modules/pdfjs-dist/build/pdf.js:2062:18
    at Array.forEach (<anonymous>)
    at /Users/Paul/.node-red/node_modules/pdfjs-dist/build/pdf.js:2061:23
    at runNextTicks (internal/process/task_queues.js:58:5)
    at processImmediate (internal/timers.js:412:9)
(node:96628) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)

```

[EDIT] I've opened a GitHub issue: [https://github.com/RedBackSpider/node-red-contrib-pdfjs/issues/2](https://github.com/RedBackSpider/node-red-contrib-pdfjs/issues/2)

---

<div class="post-metadata">

**Author:** ![ArneR](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/arner/32/95658_2.png) [@ArneR](https://discourse.nodered.org/u/ArneR)\
**Post date:** [25 August 2020 12:01 UTC](https://discourse.nodered.org/t/node-red-contrib-pdfjs-no-output/31969/6 "2020-08-25T12:01:49Z")

</div>

Hello, thank you very much for your time and effort!  
In the meantime, I'll get in touch via GitHub as you suggested.

Edit: oeps, you have already done this. Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [24 October 2020 12:01 UTC](https://discourse.nodered.org/t/node-red-contrib-pdfjs-no-output/31969/7 "2020-10-24T12:01:52Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
