{"_id":"@apandresipm/pdf-invoice","_rev":"4-b0156e0e86ed652e0194614926608e64","name":"@apandresipm/pdf-invoice","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.0":{"name":"@apandresipm/pdf-invoice","version":"1.0.0","author":{"name":"h1dd3nsn1p3r"},"description":"Simple yet powerful node JS library that generates PDF invoice on the fly.","license":"MIT","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","scripts":{"dev":"tsup ./src --watch","build":"tsup ./src","test":"node ./examples/example.ts"},"repository":{"type":"git","url":"git+ssh://git@github.com/h1dd3nsn1p3r/pdf-invoice.git"},"homepage":"https://github.com/h1dd3nsn1p3r/pdf-invoice","keywords":["pdf","invoice","estimate","receipt","generator","nodejs","pdfmake"],"devDependencies":{"@types/node":"^20.10.5","@types/pdfmake":"^0.2.8","ts-node":"^10.9.2","tsup":"^8.0.1","typescript":"^5.3.3"},"dependencies":{"pdfmake":"^0.2.8"},"bugs":{"url":"https://github.com/h1dd3nsn1p3r/pdf-invoice/issues"},"directories":{"example":"examples"},"_id":"@apandresipm/pdf-invoice@1.0.0","gitHead":"2a87a09474811f27933168164dde6970ad812005","_nodeVersion":"20.9.0","_npmVersion":"10.1.0","dist":{"integrity":"sha512-nhtNkwDBQC9h4pBKEQeT7mvEdnfIh+RYeRk5kmcMKc1UneX6zGn8jSAZkVSfYOJf4yB8oGLPTGIQ1fhWYoLWHw==","shasum":"5c785ddbc675c4d5d05efaf2fc185d4b7d781246","tarball":"https://registry.npmjs.org/@apandresipm/pdf-invoice/-/pdf-invoice-1.0.0.tgz","fileCount":28,"unpackedSize":139764,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDIk4D5lIkRj3A32SDtcG3fRd2zZYUMjKCYZLZ1poT07wIhAIDawCz1Yaj4GXMEGrBkV3D+FlvfpAIvBEMzeah/1lf5"}]},"_npmUser":{"name":"apandresipm","email":"apandresipm@gmail.com"},"maintainers":[{"name":"apandresipm","email":"apandresipm@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pdf-invoice_1.0.0_1710981790071_0.3728553012399498"},"_hasShrinkwrap":false},"1.0.1":{"name":"@apandresipm/pdf-invoice","version":"1.0.1","author":{"name":"h1dd3nsn1p3r"},"description":"Simple yet powerful node JS library that generates PDF invoice on the fly.","license":"MIT","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","scripts":{"dev":"tsup ./src --watch","build":"tsup ./src","test":"node ./examples/example.ts"},"repository":{"type":"git","url":"git+ssh://git@github.com/h1dd3nsn1p3r/pdf-invoice.git"},"homepage":"https://github.com/h1dd3nsn1p3r/pdf-invoice","keywords":["pdf","invoice","estimate","receipt","generator","nodejs","pdfmake"],"devDependencies":{"@types/node":"^20.10.5","@types/pdfmake":"^0.2.8","ts-node":"^10.9.2","tsup":"^8.0.1","typescript":"^5.3.3"},"dependencies":{"pdfmake":"^0.2.8"},"bugs":{"url":"https://github.com/h1dd3nsn1p3r/pdf-invoice/issues"},"directories":{"example":"examples"},"_id":"@apandresipm/pdf-invoice@1.0.1","gitHead":"2a87a09474811f27933168164dde6970ad812005","_nodeVersion":"20.9.0","_npmVersion":"10.1.0","dist":{"integrity":"sha512-4LkF+3cDl2ETtk1fhdlcAV1mpKDocMSqy9iQklzeAGTrMZ7agupuZpu6K1fy3fefNvCt57a1Ka0bqQmtaZJorw==","shasum":"d748985f31bbb8c5f4b726933d994cc2f71eca18","tarball":"https://registry.npmjs.org/@apandresipm/pdf-invoice/-/pdf-invoice-1.0.1.tgz","fileCount":28,"unpackedSize":139576,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDIro9sjCWcij1UCjd+yKqok1PchMkjcZNTF/5o1aE+GwIgdT8BIfx4h5dsEPKVDpFoMfkFNthn5w0EkTFgoW6WJ/A="}]},"_npmUser":{"name":"apandresipm","email":"apandresipm@gmail.com"},"maintainers":[{"name":"apandresipm","email":"apandresipm@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pdf-invoice_1.0.1_1710982604217_0.13174135335026937"},"_hasShrinkwrap":false},"1.0.2":{"name":"@apandresipm/pdf-invoice","version":"1.0.2","author":{"name":"h1dd3nsn1p3r"},"description":"Simple yet powerful node JS library that generates PDF invoice on the fly.","license":"MIT","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","scripts":{"dev":"tsup ./src --watch","build":"tsup ./src","test":"node ./examples/example.ts"},"repository":{"type":"git","url":"git+ssh://git@github.com/h1dd3nsn1p3r/pdf-invoice.git"},"homepage":"https://github.com/h1dd3nsn1p3r/pdf-invoice","keywords":["pdf","invoice","estimate","receipt","generator","nodejs","pdfmake"],"devDependencies":{"@types/node":"^20.10.5","@types/pdfmake":"^0.2.8","ts-node":"^10.9.2","tsup":"^8.0.1","typescript":"^5.3.3"},"dependencies":{"pdfmake":"^0.2.8"},"bugs":{"url":"https://github.com/h1dd3nsn1p3r/pdf-invoice/issues"},"directories":{"example":"examples"},"_id":"@apandresipm/pdf-invoice@1.0.2","gitHead":"2a87a09474811f27933168164dde6970ad812005","_nodeVersion":"20.9.0","_npmVersion":"10.1.0","dist":{"integrity":"sha512-pfqb/Q5u6BIxqiiw/RcRumjIwTf4zY01Ru5LUTnFxoxXVKyTEYRfVN//ZxQmhKePiHu1B5TO7cXYag33xrpzvg==","shasum":"68ef135424af8e02b78187999f082e68189e173d","tarball":"https://registry.npmjs.org/@apandresipm/pdf-invoice/-/pdf-invoice-1.0.2.tgz","fileCount":28,"unpackedSize":141836,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEEPk3SeTUyvQ3kxvlcxalEygj3gJP/ZKx/LOJmp4U1qAiEA0WvRcBEeMB33C6FFZ55lnh6AyH4bjBbY8btMoEPU6uk="}]},"_npmUser":{"name":"apandresipm","email":"apandresipm@gmail.com"},"maintainers":[{"name":"apandresipm","email":"apandresipm@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pdf-invoice_1.0.2_1711070451762_0.7604394447047469"},"_hasShrinkwrap":false},"1.0.3":{"name":"@apandresipm/pdf-invoice","version":"1.0.3","author":{"name":"h1dd3nsn1p3r"},"description":"Simple yet powerful node JS library that generates PDF invoice on the fly.","license":"MIT","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","scripts":{"dev":"tsup ./src --watch","build":"tsup ./src","test":"node ./examples/example.ts"},"repository":{"type":"git","url":"git+ssh://git@github.com/h1dd3nsn1p3r/pdf-invoice.git"},"homepage":"https://github.com/h1dd3nsn1p3r/pdf-invoice","keywords":["pdf","invoice","estimate","receipt","generator","nodejs","pdfmake"],"devDependencies":{"@types/node":"^20.10.5","@types/pdfmake":"^0.2.8","ts-node":"^10.9.2","tsup":"^8.0.1","typescript":"^5.3.3"},"dependencies":{"pdfmake":"^0.2.8"},"bugs":{"url":"https://github.com/h1dd3nsn1p3r/pdf-invoice/issues"},"directories":{"example":"examples"},"_id":"@apandresipm/pdf-invoice@1.0.3","gitHead":"2a87a09474811f27933168164dde6970ad812005","_nodeVersion":"20.9.0","_npmVersion":"10.1.0","dist":{"integrity":"sha512-LSk1wY01azif5mHzXmTGAOwEOP0B/4kqosvGhxDTbMSw4TsR9jxf6PTj9c4UYDv39nQUqi5vBzAXQE70Y6RA5A==","shasum":"c4566c412c639967906fcd4fb7e96bd65bfe3563","tarball":"https://registry.npmjs.org/@apandresipm/pdf-invoice/-/pdf-invoice-1.0.3.tgz","fileCount":29,"unpackedSize":145183,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGg0pYCiM1LX3wT4FFclhqwdklBQerOX4Oi9MBRFJUPMAiEA57DBlBMf8s3X7lAsidQB365cvnsaz6A0L/n5jhn+yw0="}]},"_npmUser":{"name":"apandresipm","email":"apandresipm@gmail.com"},"maintainers":[{"name":"apandresipm","email":"apandresipm@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pdf-invoice_1.0.3_1711071985052_0.8773800670856551"},"_hasShrinkwrap":false},"1.0.4":{"name":"@apandresipm/pdf-invoice","version":"1.0.4","author":{"name":"h1dd3nsn1p3r"},"description":"Simple yet powerful node JS library that generates PDF invoice on the fly.","license":"MIT","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","scripts":{"dev":"tsup ./src --watch","build":"tsup ./src","test":"node ./examples/example.ts"},"repository":{"type":"git","url":"git+ssh://git@github.com/h1dd3nsn1p3r/pdf-invoice.git"},"homepage":"https://github.com/h1dd3nsn1p3r/pdf-invoice","keywords":["pdf","invoice","estimate","receipt","generator","nodejs","pdfmake"],"devDependencies":{"@types/node":"^20.10.5","@types/pdfmake":"^0.2.8","ts-node":"^10.9.2","tsup":"^8.0.1","typescript":"^5.3.3"},"dependencies":{"pdfmake":"^0.2.8"},"bugs":{"url":"https://github.com/h1dd3nsn1p3r/pdf-invoice/issues"},"directories":{"example":"examples"},"_id":"@apandresipm/pdf-invoice@1.0.4","gitHead":"2a87a09474811f27933168164dde6970ad812005","_nodeVersion":"20.9.0","_npmVersion":"10.1.0","dist":{"integrity":"sha512-nd2eLZllsXcg8DMGc+UhdAWpRR04pTdqhnw6zuzooUcrL9RInSA2C1ex/azkQwcsYtsuW1tgyj32Vqrx4E7u9g==","shasum":"58d504010885ae15029217bd58da61f926d270c9","tarball":"https://registry.npmjs.org/@apandresipm/pdf-invoice/-/pdf-invoice-1.0.4.tgz","fileCount":30,"unpackedSize":165002,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCKvNSwdbfkiPItC5LmxrkQX3h8nRhKAyjf/jZwcNBLhgIhAI1zu64pXNa09141b9fK+WgG8lZiEgY9O6RrDzXI1gUg"}]},"_npmUser":{"name":"apandresipm","email":"apandresipm@gmail.com"},"maintainers":[{"name":"apandresipm","email":"apandresipm@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pdf-invoice_1.0.4_1711073381608_0.01211515115464934"},"_hasShrinkwrap":false}},"time":{"created":"2024-03-21T00:43:09.953Z","1.0.0":"2024-03-21T00:43:10.282Z","modified":"2024-03-22T02:09:42.224Z","1.0.1":"2024-03-21T00:56:44.396Z","1.0.2":"2024-03-22T01:20:51.923Z","1.0.3":"2024-03-22T01:46:25.210Z","1.0.4":"2024-03-22T02:09:41.808Z"},"maintainers":[{"name":"apandresipm","email":"apandresipm@gmail.com"}],"description":"Simple yet powerful node JS library that generates PDF invoice on the fly.","homepage":"https://github.com/h1dd3nsn1p3r/pdf-invoice","keywords":["pdf","invoice","estimate","receipt","generator","nodejs","pdfmake"],"repository":{"type":"git","url":"git+ssh://git@github.com/h1dd3nsn1p3r/pdf-invoice.git"},"author":{"name":"h1dd3nsn1p3r"},"bugs":{"url":"https://github.com/h1dd3nsn1p3r/pdf-invoice/issues"},"license":"MIT","readme":"![PDF Invoice](https://github.com/h1dd3nsn1p3r/pdf-invoice/blob/development/examples/hero.png)\n\n📑 Simple yet powerful JavaScript library that generates PDF invoice, estimates & payment receipts from a JSON data. It can be used in any Node JS/Bun JS environment. \n\n## Installation\n\nvia npm:\n\n```bash\nnpm install @h1dd3nsn1p3r/pdf-invoice\n```\n\nvia yarn:\n\n```bash\nyarn add @h1dd3nsn1p3r/pdf-invoice\n```\n\nvia pnpm:\n\n```bash\npnpm add @h1dd3nsn1p3r/pdf-invoice\n```\n\n## Use\n\nOnce installed, you can import either using `require` or `import`:\n\n```js\nconst { PDFInvoice } = require('@h1dd3nsn1p3r/pdf-invoice');\n```\n\nor ES6 import:\n\n```js\nimport { PDFInvoice } from '@h1dd3nsn1p3r/pdf-invoice';\n```\n\n`PDFInvoice` is a class that takes the payload as an argument. The payload is the data that you want to show on the invoice. For more information check the [Payload data](https://github.com/h1dd3nsn1p3r/pdf-invoice/blob/stable/examples/example.ts) example. \n\n## Payload Data\n\nThe payload is the data that you want to show on the invoice. It is an object with the following structure:\n\n```js\nconst payload = {\n    company: {\n        logo: \"<svg>...</svg>\", // Optional. SVG logo of your company.\n        name: \"Festrol Corp.\",\n        address: \"1711 W. El Segundo Blvd, Hawthorne, Canada - 90250\",\n        phone: \"Tel: (+11) 245 543 903\",\n        email: \"Mail: hello@festrol.io\",\n        website: \"Web: https://www.festrolcorp.io\",\n        taxId: \"Tax ID: 1234567890\", // Optional.\n    },\n    customer: {\n        name: \"John Doe\",\n        company: \"Xero Inc.\", // Optional.\n        address: \"1234 Main Street, New York, NY 10001\",\n        phone: \"Tel: (555) 555-5555\",\n        email: \"Mail: joe@example.com\",\n        taxId: \"Tax ID: 1234567890\", // Optional.\n    },\n    invoice: {\n        number: 1721, // String or number.\n        date: \"25/12/2023\", // Default is current date.\n        dueDate: \"25/12/2023\", // Default is current date.\n        status: \"Paid!\",\n        currency: \"€\", // Default is \"$\",\n        path: \"./invoice.pdf\", // Required. Path where you would like to generate the PDF file. \n    },\n    items: [\n        {\n            name: \"Cloud VPS Server - Starter Plan\",\n            quantity: 1,\n            price: 400,\n            tax: 0, // Specify tax in percentage. Default is 0.\n        },\n        {\n            name: \"Domain Registration - example.com\",\n            quantity: 1,\n            price: 20,\n            tax: 0, // Specify tax in percentage. Default is 0.\n        },\n        {\n            name: \"Maintenance Charge - Yearly\",\n            quantity: 1,\n            price: 300,\n            tax: 0, // Specify tax in percentage. Default is 0.\n        },\n    ],\n    qr: {\n        data: \"https://www.festrolcorp.io\",\n        width: 100, // Default is 50.\n    },\n    note: {\n        text: \"Thank you for your business.\",\n        italic: false, // Default is true.\n    }\n};\n```\n\n**Note:** If the string is long, then you can use `\\n` to break the line. For example:\n\n```js\nconst payload = {\n    company: {\n        name: \"Festrol Corp.\",\n        address: \"1711 W. El Segundo Blvd, Hawthorne, \\n Canada - 90250\",\n        phone: \"Tel: (+11) 245 543 903\",\n        email: \"Mail: email@yourcompany.com\"\n    },\n};\n```\n\nLet's understand each of the fields in the payload.\n\n### Company\n\nThis is the information about your company. It is an object with the following structure:\n\n```js\nconst company = {\n    logo: \"<svg>...</svg>\", // Optional. SVG logo of your company.\n    name: \"Festrol Corp.\", // Optional or required if logo is not supplied.\n    address: \"1711 W. El Segundo Blvd, Hawthorne, \\n Canada - 90250\", // Optional.\n    phone: \"Tel: (+11) 245 543 903\", // Optional.\n    email: \"hello@company.com\", // Optional.\n    website: \"Web: https://www.festrolcorp.io\" // Optional.\n    taxId: \"Tax ID: 1234567890\", // Optional.\n}\n```\n\nFor now, only **svg logo** can be used. If you wish to use logo & do not want the company name, then do not pass the `name` field. Rest of the fields are optional.\n\n```js\n\n### Invoice\n\nThis is the information about the invoice. It is an object with the following structure:\n\n```js\nconst invoice = {\n    number: 1721, // Required.\n    date: \"25/12/2023\", // Optional. Default is current date.\n    dueDate: \"25/12/2023\", // Optional. Default is current date.\n    status: \"Paid!\", // Optional. Default is \"Due pending!\".\n    currency: \"€\", // Optional. Default is \"$\".\n}\n```\n\nThe invoice number is required. It might be a `integer` that you use to track your invoices. In most cases, it is a unique number that reference the `order ID` or invoice sequence number in your database. Rest of the fields are optional.\n\nIf path is supplied in the payload, then the PDF will be generated at that location. For example:\n\n```js\nconst file = \"invoice\" + \"-#\" + 1729 + \"-\" + new Date().getTime(); // invoice-#1729-1630480000000\nconst location = path.join(__dirname, \"/invoices/\" + file + \".pdf\"); \nconst invoice = {\n    path: location, // Required.\n}\n```\n\nIf path is not supplied in the payload, then the PDF will be generated in current working directory with the name `invoice.pdf`. \n\n### Customer\n\nThis is the information about your customer. It is an object with the following structure:\n\n```js\nconst customer = {\n    name: \"John Doe\", // Required.\n    company: \"Xero Inc.\", // Optional.\n    address: \"1234 Main Street, New York, \\n NY 10001\", // Optional.\n    phone: \"Tel: (555) 555-5555\", // Optional.\n    email: \"joedeo@example.com\", // Optional.\n    taxId: \"Tax ID: 1234567890\", // Optional.\n}\n```\n\nThe name of the customer is required. Rest of the fields are optional.\n\n### Items\n\nItems are the products or services that you are selling. It is an `array` of objects with the following structure:\n\n```js\nconst items = [\n    {\n        name: \"Cloud VPS Server - Starter Plan\", // Required.\n        quantity: 1, // Required.\n        price: 400, // Required.\n        tax: 0, // Optional. Specify tax in percentage. Default is 0.\n    },\n    {\n        name: \"Domain Registration - example.com\", // Required.\n        quantity: 1, // Required.\n        price: 20, // Required.\n        tax: 0, // Optional. Specify tax in percentage. Default is 0.\n    },\n    {\n        name: \"Maintenance Charge - Yearly\", // Required.\n        quantity: 1, // Required.\n        price: 300, // Required.\n        tax: 0, // Optional. Specify tax in percentage. Default is 0.\n    },\n];\n```\n\nThe `name`, `quantity` and `price` of the item is required. Rest of the fields are optional. Although if you have single item in the invoice, you need to pass it as an object. For example:\n\n```js\nconst items = [\n    {\n        name: \"Cloud VPS Server - Starter Plan\", // Required.\n        quantity: 1, // Required.\n        price: 400, // Required.\n        tax: 0, // Optional. Specify tax in percentage. Default is 0.\n    },\n];\n```\n\n### QR Code\n\nIf you want to add a QR code to the invoice, then you can use this field. It is an object with the following structure:\n\n```js\nconst qr = {\n    data: \"https://www.festrolcorp.io/\", // Required. The data that you want to encode in the QR code.\n    width: \"100\", // Optional. Default is 50. \n}\n```\n\nThe `data` field is required. It is the data that you want to encode in the QR code. The `width` field is optional. It is the width of the QR code in pixels. Default is `50`. The recommended width of QR is 30 - 100.\n\n### Note\n\nUse this field if you want to add a note to the invoice. It is an string with the following structure:\n\n```js\nconst note = \"Thank you for your business.\"; \n```\n\n## Generate PDF\n\nOnce you have the payload ready, you can generate the PDF using the following code:\n\n```js\nconst { PDFInvoice } = require('@h1dd3nsn1p3r/pdf-invoice');\n\nconst handleInvoice = async(): Promise<void> => {\n    \n    const payload = {\n        // Prepare payload.\n    };\n\n    /**\n    * Create the invoice.\n    */\n    const invoice = new PDFInvoice(payload);\n    const pdf = await invoice.create(); // Returns promise, await it.\n\n    console.log(pdf); // Full path to the PDF file.\n}\n\nhandleInvoice();\n```\n\nOnce you call the `create` method, it will return a promise. You can either use `async/await` or `.then()` to handle the promise. The `create` method will return the path to the PDF file if the PDF is generated successfully. Otherwise, it will throw an error.\n\n## Configuration\n\nIf required you can change the configuration of the invoice. It is an object with the following structure:\n\n```js\nconst { PDFInvoice } = require('@h1dd3nsn1p3r/pdf-invoice');\n\nconst create = async(): Promise<void> => {\n    \n    const payload = {\n        // ....\n    };\n\n    const config = {\n        // Custom labels.\n        string: {\n            invoice: \"F A C T U A\",\n            refNumber: \"Referencia\",\n            date: \"Fecha\",\n            dueDate: \"Fecha de vencimiento\",\n            status: \"Estado\",\n            billTo: \"Facturar a\",\n            item: \"Artículo\",\n            quantity: \"Cantidad\",\n            price: \"Precio\",\n            tax: \"Impuesto\",\n            total: \"Total\",\n            subTotal: \"Subtotal\",\n            totalTax: \"Total Impuesto\",\n        },\n    };\n\n    // Create the invoice.\n    const invoice = new PDFInvoice(payload, config);\n    const pdf = await invoice.create();\n\n    console.log(pdf);\n}\n```\n\n### Config limitations: \n\nFor now only `latin` characters are supported. It seems like a limitation of `Helvetica` font. I'll be adding support for other languages soon.\n\n## Types\n\nThis library is written in TypeScript. If you need to import the types, then you can import them from `global.d.ts` file. Refer to [Global types](https://github.com/h1dd3nsn1p3r/pdf-invoice/blob/stable/global.d.ts) file for more information.\n\nImport example:\n\n```js\nimport type { CompanyInfo, CustomerInfo, InvoiceInfo, ItemInfo, QRInfo, InvoicePayLoad } from '@h1dd3nsn1p3r/pdf-invoice/global.d.ts';\n```\n\n## Changelog: \n\nRefer to [releases](https://github.com/h1dd3nsn1p3r/pdf-invoice/releases) section for more information.\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\n## Todo\n\n- [ ] Add design/style options.\n- [ ] Add configuration options - (Strings, Fonts, Styles, etc.)\n- [ ] Add support for multi-language.\n","readmeFilename":"README.md"}