{"_id":"pdf-qr","_rev":"1-12a0e2301c35cc802dcdb85b0a3cdb2f","name":"pdf-qr","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"pdf-qr","version":"1.0.0","description":"PDF QR Code scanner entirely written in JavaScript.","main":"pdf-qr.js","keywords":["pdf-qr","pdf","qr","qr code reader","qr scanner","pdf qr reader","pdf qr scanner"],"repository":{"type":"git","url":"git+https://github.com/rexshijaku/pdf-qr.js.git"},"author":{"name":"Rexhep Shijaku"},"license":"ISC","dependencies":{"canvas":"^2.8.0","jsqr":"^1.4.0","pdfjs-dist":"^2.9.359"},"bugs":{"url":"https://github.com/rexshijaku/pdf-qr.js/issues"},"homepage":"https://github.com/rexshijaku/pdf-qr.js#readme","_id":"pdf-qr@1.0.0","_nodeVersion":"12.5.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-jQkkX11rGDL25EtoozhkmPS8zvvsZA4AViWjxBr+tzH1mYuhG+ESF0r2pGdrb604SCO/uwSCvEVG75YyytgdsA==","shasum":"60ecf37c2a60f27593edeab717de16b37525282e","tarball":"https://registry.npmjs.org/pdf-qr/-/pdf-qr-1.0.0.tgz","fileCount":4,"unpackedSize":26623,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhCV9ICRA9TVsSAnZWagAALgQP/j92gPlh+c55teXWEZYm\nkACeg1h4wzw5GI9q7KG5aSbKpbjy4kyvc3iNqH6eS21DQA3jjn38du6PNVLp\nBV2napQJcqwcnEyAEoT5UbD3gt3rREpMvWcqRf+W3sz8EpPjVlMuA5LRSvcI\nGktHSrmiI+HmuYhMEVv9NEwuAmOuOC2FV6NQIDFCrv21VJ8V49nxCAlb89R3\nQs9vR3gPkCUFELODXwLfOrjbOi4YnpP9wv0kZiv4xAAxcDI1T+jHbJyh1mK7\neHse7tOJUD4wnG7CXJVp116QsVr1+QeEGjwJ2d/rasc3epX1Gf46jEeYwIW5\nTbIrPNocyOue9fONhYO4Q9RWaykR4VJJs6NN97K6C2IhvstbjQM/sSyk70cQ\nWBlE9Q0aVO4irH3rBdkfBRL+OeGsqkQGnqnB2aPO40F2VFzYrXqwNmC29qEo\nWt5AHoBh27E7zelHfcGhoSDxWR/nnrM2DP877eFt31rWV6CsNFtIKobvHuPD\nEu9zPXrEA4W+o+663w1diK8AB+ZD5LE1DODaD6fWZOLssqThidezns2PKbDw\no16zsAj3MhB7OR39CX+VLbcZqHX7s77rtwCGNLhREaK7mh/sIJ/aiXceF7K0\nF4Xo2rE8Yvt3UqLpgxhmMm/bDoCqo8hMybHOG+vkCTZIj3v0XANtzPEscdld\nl5mW\r\n=CuEs\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIE2bYBkVO+Nu4BGUoJPmXb7oLYsm22Tt1HFuhWXi7EtMAiEAvWaxhlTi6Z4wH48ZFZ46REfSU51xpqCynaHWBef2890="}]},"_npmUser":{"name":"rexshijaku","email":"rexhepshijakuch@gmail.com"},"directories":{},"maintainers":[{"name":"rexshijaku","email":"rexhepshijakuch@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pdf-qr_1.0.0_1628004168262_0.24411074955852619"},"_hasShrinkwrap":false}},"time":{"created":"2021-08-03T15:22:48.262Z","1.0.0":"2021-08-03T15:22:48.408Z","modified":"2022-05-12T18:03:46.466Z"},"maintainers":[{"name":"rexshijaku","email":"rexhepshijakuch@gmail.com"}],"description":"PDF QR Code scanner entirely written in JavaScript.","homepage":"https://github.com/rexshijaku/pdf-qr.js#readme","keywords":["pdf-qr","pdf","qr","qr code reader","qr scanner","pdf qr reader","pdf qr scanner"],"repository":{"type":"git","url":"git+https://github.com/rexshijaku/pdf-qr.js.git"},"author":{"name":"Rexhep Shijaku"},"bugs":{"url":"https://github.com/rexshijaku/pdf-qr.js/issues"},"license":"ISC","readme":"# PDF-QR.js\r\nPDF QR Code scanner entirely written in JavaScript.\r\n\r\n### Features\r\nFull-document scan <br />\r\nSingle page scan\r\n\r\n### Demo\r\n\r\n##### Online demo\r\nLive demo will be available <a href=\"https://github.com/rexshijaku/pdf-qr.js\" target=\"_blank\">here</a>.\r\n\r\n##### Web server\r\nClone or download this repository and run demo/ws_demo.html. This demo uses two files: (1) dist/pdf-qr.js and (2) worker file (pdf.worker.min.js) which should be placed in the projects output folder. You must run this file (ws_demo.html) using a web server in order to take the advantage of http:// or https:// protocols to load workers, otherwise using file:// won't load the essential worker. If you don't have any web server installed, you may take a look at the alternative demo version.\r\n\r\n##### Alternative\r\nAfter you clone this repository, on your local machine run demo/file_demo.html. This example uses minified versions of dependent libraries and its files. This offers you a version which can be tested with zero configurations compared to the previous one.\r\n\r\n### Get Started\r\n##### Install by manual download:\r\nDownload pdf-qr.js which is located in dist folder and load it as follows :\r\n```html\r\n <script type=\"text/javascript\" src=\"pdf-qr.js\"> </script>\r\n```\r\n**Important** : Make sure that the **pdf.worker.min.js** file is copied to your project's output folder.\r\nNote that if you don't want to take care of pdf.worker.min.js separately as it was explained, follow the alternative install by manual download.\r\n\r\n##### Alternative install by manual download:\r\nDownload minified files located in demo/js/file_demo_only and include them just in your assets directory which is targeted by your scripts as it was described in file_demo.html.\r\n\r\n##### NPM\r\nYou can also install it from npm by running the following command:\r\n```html\r\nnpm install pdf-qr\r\n```\r\ninclude it as:\r\n```js\r\nimport { PDF_QR_JS }  from 'pdf-qr';  // ES6\r\n\r\nconst { PDF_QR_JS } = require('pdf-qr'); // Common JS\r\n```\r\n\r\n##### Webpack and other building tools\r\nIf you use Webpack or other bundling tools, you will have to make sure on your own that pdf.worker.min.js file from pdfjs-dist/build is copied to your project's output folder.\r\n\r\nAlternatively, you can use pdf.worker.min.js from an external CDN:\r\n##\r\n```javascript\r\nimport { PDF_JS } from 'pdf-qr';\r\nPDF_JS.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${PDF_JS.version}/pdf.worker.min.js`;\r\n```\r\n### Usage\r\n\r\n#### Set up the optimal configuration\r\nThe efficiency and the accuracy of this library totally depends on the given configuration. By default it uses a configuration which worked best during development and testing. You should modify and optimize this configuration to fit to your QR Code sizes. Use any of provided demos above to construct configuration parameters or write them manually. There are four steps you need to undertake to decode a pdf:\r\n##### JavaScript code:\r\n### \r\n```js\r\n\r\nvar configs = { // create and populate configs variable\r\n    scale: {\r\n        once: true,\r\n        value: 1\r\n    },\r\n    resultOpts: {\r\n        singleCodeInPage: true\r\n    },\r\n    improve: true,\r\n    jsQR: {}\r\n};\r\n```\r\n```js\r\n // select the input file\r\n var input_file = document.getElementById('pdfentryfile');\r\n\r\n // create callback which handles the result \r\n var callback =  function(result) {\r\n    if(result.success)\r\n        console.log(result.codes)\r\n    else \r\n        console.log(result.message);\r\n }\r\n```\r\n\r\n\r\n##### Full-Document decode:\r\n##\r\n```js\r\n //decode document (all pages)\r\n PDF_QR_JS.decodeDocument(input_file, configs, callback);\r\n```\r\n\r\n##### Single page decode:\r\n##\r\n```js\r\n // or decode a single page\r\n var pageNr = 1;\r\n PDF_QR_JS.decodeSinglePage(input_file, pageNr, configs, callback);\r\n```\r\n\r\n##### Html code:\r\n##\r\n```html\r\n <input id=\"pdfentryfile\" type=\"file\" accept=\"application/pdf\">\r\n```\r\n#### Node usage\r\nCurrently, the full functionality is only available through the browser. Only the pdf-file-based decoding is available. See an example for node <a href=\"https://github.com/rexshijaku/pdf-qr.js/blob/master/demo/node_demo/\">here</a>.\r\n\r\n### How does it works?\r\nPDF-QR.js combines and extends the functionality of <a href=\"https://github.com/mozilla/pdf.js/\">pdf.js</a> and <a href=\"https://github.com/cozmo/jsQR\">jsQR</a> to introduce a tool which is able scan QR Codes which are placed on PDFs. It fetches and reads pages via <a href=\"https://github.com/mozilla/pdf.js/\">pdf.js</a> methods subsequently adds few processing steps and lastly passes them to <a href=\"https://github.com/cozmo/jsQR\">jsQR</a> which decodes the codes which are present in pages.\r\nThis library supports all QR Code versions which are supported by <a href=\"https://github.com/cozmo/jsQR\">jsQR</a>.\r\nDepending on the number of pages you want to decode and the QR Code sizes you have in your PDFs, you should find the optimal configuration for your PDF decoder which can be done using one of the demo version offered in this repo. After you find the neccessary configuration, just copy it and you are ready to paste it in your code and to start decode QR Codes in PDFs.\r\n\r\n#### Config arguments\r\n\r\n##### scale\r\nThis parameter specifies how much a page should be enlarged (scaled) before it reaches to the decoder. If it is given as *once* then it scales pages one time by the given value, otherwise if you specify start, step and stop parameters, page will be scaled iteratively until requested QR Codes are found, if decoder can't find any QR Code this process will continue until the maximum number of steps is reached. If you have different QR Code sizes throughout the pages you should use the latter way, if your QR Codes have a fixed size the former way is ideal. Note that this is an important parameter for the performance of the decoder, fewer steps will offer higher performance.\r\n\r\n##### resultOpts\r\nDepending on how many QR Codes you need to extract from a page, \r\nyou should specify this parameter. \r\nIf you need just one QR Code per page then turn singleCodeInPage on. Currently, scanning multiple codes in a page (multiCodesInPage) is not supported.\r\n\r\n##### improve\r\nPDF-QR.js improves itself continuously with an intention to minimize resources in following pages. When it finds a QR Code in a page, it will use that configuration on the next page as a first step.\r\n\r\n#### jsQR options\r\nYou may specify jsQR options (such as inversionAttempts) directly.\r\nIn order to get a more insightful knowledge on how jsQR options work, please check its repository <a href=\"https://github.com/cozmo/jsQR\">here</a>.\r\n\r\n#### result object\r\nThe most important property of result object is *codes* property which stores all codes found in a document or requested page. Alongside this field are grouped *codes by pages*, *codes by QR Code versions* and *statistics*. In development, these stats should be analyzed in order to conclude which parameters should be to excluded, included or adjusted more accurately, in order to reach a satisfying performance and accuracy.\r\n##\r\n```js\r\n{\r\n    \"codes\": [\r\n        \"code_1\",\r\n        \"code_2\"\r\n    ],\r\n        \"codesByPage\": [\r\n        1: [\"code_1\"],\r\n        2: [\"code_2\"]\r\n],\r\n    \"codesByPageAndVersion\": [\r\n        1: {\r\n        \"6\": [\"code_1\"]\r\n    },\r\n    2: {\r\n        \"7\": [\"code_2\"]\r\n    }\r\n],\r\n    \"codesByVersion\": [\r\n        \"6\": [\r\n        \"code_1\"\r\n    ],\r\n        \"7\": [\r\n        \"code_2\"\r\n    ]\r\n],\r\n    \"codesDetailed\": [{\r\n        \"code\": \"code_1\",\r\n        \"version\": \"6\",\r\n        \"page\": 1,\r\n        \"scale\": 1\r\n    },\r\n        {\r\n            \"code\": \"code_2\",\r\n            \"version\": \"7\",\r\n            \"page\": 2,\r\n            \"scale\": 1\r\n        }\r\n    ],\r\n        \"stats\": {\r\n        \"totalOnScale\": [\r\n            3: 2\r\n    ]\r\n    },\r\n    \"statsByPage\": [\r\n        1: {\r\n        \"totalOnScale\": [\r\n            3: 1\r\n    ]\r\n    },\r\n    2: {\r\n        \"totalOnScale\": [\r\n            3: 1\r\n    ]\r\n    }\r\n],\r\n    \"success\": true\r\n}\r\n```\r\n\r\n### Support\r\nFor general questions about PDF-QR.js, tweet at @rexshijaku or write me an email on rexhepshijaku@gmail.com.\r\nTo have a quick tutorial check the examples folder provided in the repository.\r\n\r\n### Author\r\n##### Rexhep Shijaku\r\n- Email : rexhepshijaku@gmail.com\r\n- Twitter : https://twitter.com/rexshijaku\r\n\r\n### Thank you\r\nMozilla as the author of the <a href=\"https://github.com/mozilla/pdf.js/\">pdf.js</a>, Cosmo Wolfe <a href=\"mailto:cosmo.wolfe@gmail.com\">cosmo.wolfe@gmail.com</a> for initiating <a href=\"https://github.com/cozmo/jsQR\">jsQR</a> alongside with other contributors who are continually improving it.\r\n\r\n### License\r\nMIT License\r\n\r\nCopyright (c) 2021 | Rexhep Shijaku\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r\n","readmeFilename":"README.md"}