Click a link to download/show a pdf file in a new browser page

I'm looking for a solution to click a link in table and show a pdf file stored in a defined path.

The idea is to:

  • select the CODIFICA and the ID, combine these two information in order to define the filename (CODIFICA_ID.pdf)
  • click on the link in the table (corrisponding to the ID) to download/open a browser page with the pdf file (which is located in a dedicated path)

Here is my starting flow:

[{"id":"2aed95c5c2a2dfe5","type":"change","z":"4696f6296657fd10","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"fileCOD","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":320,"wires":[["1681be5cf929f522"]]},{"id":"ceaf0efc1c2ae723","type":"debug","z":"4696f6296657fd10","name":"Cod_ID","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":700,"y":280,"wires":[]},{"id":"1681be5cf929f522","type":"join","z":"4696f6296657fd10","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":510,"y":280,"wires":[["ceaf0efc1c2ae723","727e8ff1f65573d2"]]},{"id":"01681638e098d6a5","type":"http response","z":"4696f6296657fd10","name":"","statusCode":"","headers":{},"x":1190,"y":700,"wires":[]},{"id":"6c972f0c38ebb48a","type":"file in","z":"4696f6296657fd10","name":"","filename":"","format":"","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":850,"y":640,"wires":[["01681638e098d6a5","e4f31b48dfb04217"]]},{"id":"6ac16e8cdcd671cb","type":"catch","z":"4696f6296657fd10","name":"","scope":null,"uncaught":false,"x":600,"y":740,"wires":[["64dd436767c7a60b","1d596ca954c0bd40"]]},{"id":"64dd436767c7a60b","type":"function","z":"4696f6296657fd10","name":"Set 404","func":"msg.payload = msg.error;\nmsg.statusCode = 404;//resource not found\nreturn msg;","outputs":1,"noerr":0,"x":860,"y":740,"wires":[["01681638e098d6a5"]]},{"id":"1d596ca954c0bd40","type":"debug","z":"4696f6296657fd10","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":650,"y":780,"wires":[]},{"id":"c305d85b64753a7d","type":"http in","z":"4696f6296657fd10","name":"","url":"/download","method":"get","upload":false,"swaggerDoc":"","x":560,"y":660,"wires":[["727e8ff1f65573d2"]]},{"id":"e4f31b48dfb04217","type":"debug","z":"4696f6296657fd10","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1070,"y":620,"wires":[]},{"id":"750d74ad86fbcd9e","type":"change","z":"4696f6296657fd10","name":"","rules":[{"t":"set","p":"payload.file","pt":"msg","to":"file","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":1040,"y":460,"wires":[["7fcbdb8511edf212"]]},{"id":"727e8ff1f65573d2","type":"function","z":"4696f6296657fd10","name":"","func":"//var path = \"C:\\\\Datamed\\\\DB_Strumentazione\\\\Node-red\\\\\";\nvar path = \"C:\\\\Users\\\\Certificati\\\\\";\n//var filename = msg.payload.fileCOD + \"_\" + msg.payload.IDAll;\nvar filename = \"prova\"\nvar ext = \".pdf\"\n//msg.payload.file = path + filename + ext\nmsg.filename=path + filename + ext\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":780,"y":440,"wires":[["0ba2d2b9d4347b61","6c972f0c38ebb48a","750d74ad86fbcd9e","8f6b12206684f449"]]},{"id":"0ba2d2b9d4347b61","type":"debug","z":"4696f6296657fd10","name":"func out","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1070,"y":400,"wires":[]},{"id":"1d0902f459f58eb6","type":"ui_template","z":"4696f6296657fd10","d":true,"group":"5e9d8a1088595519","name":"Download Button 1","order":0,"width":0,"height":0,"format":"<button>\n    \n <a href=\"/download\" target=\"_blank\">Download Report</a>\n </button>\n","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","className":"","x":1310,"y":640,"wires":[[]]},{"id":"1f3bae200c1a83bc","type":"debug","z":"4696f6296657fd10","name":"template output","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1150,"y":520,"wires":[]},{"id":"7fcbdb8511edf212","type":"debug","z":"4696f6296657fd10","name":"Out File","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1310,"y":440,"wires":[]},{"id":"8f6b12206684f449","type":"ui_template","z":"4696f6296657fd10","group":"5e9d8a1088595519","name":"","order":6,"width":"4","height":"9","format":"\n<br/>\n<table id=\"table\" border=\"1\"  height= 50px >\n\n    <tr>\n       <th>ID_ALLEG</th>\n       <th>ALLEGATO</th>    \n        \n    </tr>\n    <tbody style=\"text-align: center\">\n        <tr ng-repeat=\"x in msg.payload\">\n           \n           <td> {{x.ID_Scad}} </td>\n           <td ng-if=\"x.STATOALLEGATO == 0\"> Not Available </td>\n           <td ng-if=\"x.STATOALLEGATO == 1\"><a href=\"/download/{{x.file}}\">Download</a>\n        </tr>\n    </tbody>\n</table>\n\n","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":940,"y":560,"wires":[["1f3bae200c1a83bc"]]},{"id":"80d637acdeb3b881","type":"ui_dropdown","z":"4696f6296657fd10","name":"","label":"Which ID?","tooltip":"","place":"Select option","group":"5e9d8a1088595519","order":2,"width":6,"height":1,"passthru":false,"multiple":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","x":450,"y":180,"wires":[["1681be5cf929f522","c53209c3c85e0f34"]]},{"id":"27aadc36165c36d4","type":"debug","z":"4696f6296657fd10","name":"After DropDown Selec  ","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":980,"y":140,"wires":[]},{"id":"c53209c3c85e0f34","type":"change","z":"4696f6296657fd10","name":"","rules":[{"t":"set","p":"IDAllegato","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":180,"wires":[["27aadc36165c36d4"]]},{"id":"acb2d14e9176f2ca","type":"ui_dropdown","z":"4696f6296657fd10","name":"","label":"Cerca Strumento","tooltip":"","place":"","group":"69000d76e3060b9b","order":3,"width":4,"height":1,"passthru":true,"multiple":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"options","topicType":"msg","className":"","x":190,"y":220,"wires":[["2aed95c5c2a2dfe5"]]},{"id":"5e9d8a1088595519","type":"ui_group","name":"Carica Certificato Taratura","tab":"21286fd2ee7bdc0c","order":5,"disp":true,"width":"10","collapse":false,"className":""},{"id":"69000d76e3060b9b","type":"ui_group","name":"Ricerca Strumento","tab":"21286fd2ee7bdc0c","order":3,"disp":false,"width":"20","collapse":false,"className":""},{"id":"21286fd2ee7bdc0c","type":"ui_tab","name":"Inserimento Date Controllo","icon":"assignment","order":5,"disabled":false,"hidden":true}]

Could yo help me?

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