npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pdf-ivc

v1.0.7

Published

Layout PDF A4 convet to img or pdf buffer

Readme

pdf-ivc

Genera plantillas PDF personalizables en formato A4 con generación de códigos QR. Retorna tanto las imágenes como el documento PDF en formato Buffer. Paginación automática se crea una nueva página por cada 12 ítems registrados.

👁‍🗨 Visualizar Plantilla

Install

npm install pdf-ivc -E

Example

Function image()

import PDFInvoice from "pdf-ivc";
import fs from "node:fs"

//image(scale: number) - return Promise<Buffer[]>;
const images = await PDFInvoice(data).image(3)

images.forEach((image, index) => {
  fs.writeFileSync(`upload/img/qr/${index}.png`, image);
});

Function pdf()

import PDFInvoice from "pdf-ivc";
import fs from "node:fs"

//pdf() - return Promise<Buffer>;
const pdf = await PDFInvoice(data).pdf()

fs.writeFileSync('upload/pdf/qr/pdf.pdf', pdf)

Structure

Header

Enterprise Este objeto contiene los datos corporativos utilizados para personalizar encabezados en documentos PDF generados por la plataforma. Logotipo, nombre comercial, un identificador tributario y un campo aditional para contacto.

const enterprise = {
            logo: 'img/logo.png',
            name: "PDF-IVC, Corp",
            aditional: 'www.pdf-ivc.com',
            indificatorTribute: 'RUC 0222351515',
        }

Type: Enterprise

interface Enterprise {
    logo: PDFKit.Mixins.ImageSrc,
    name: string,
    indificatorTribute: string,
    aditional: string,
}

Type: PDFKit.Mixins.ImageSrc

type ImageSrc = Buffer | ArrayBuffer | string;

Order Este objeto representa los datos asociados a una orden de compra o solicitud de servicio. Se utiliza para generar documentos PDF personalizados con información relevante del pedido.

const order = {
     id: 'N° 0001-2025',
     aditional: 'Av. Angamos Nro. 1805 - 01234567',
     createAt: '01 Enero 2025 - 08:07 PM',
     payment: { text: 'Pendiente - Efectivo', color: 'green' },
      //Optional qr
     qr: 'www.pdf-ivc.com'
}

Type: Order

interface Order {
    id: string,
    payment: {
        color: string,
        text: string
    },
    aditional: string,
    createAt: string,
    qr?: PDFKit.Mixins.ImageSrc
}

Details

ColsOne Este objeto contiene información organizada en bloques numerados, pensados para ser presentados como columnas o secciones visuales dentro de documentos PDF.

const colsOne = {
            title: "Cliente", "1": {
                Nombre: "Emilio Sánchez Pérez Mamani",
                DNI: "DNI 12345678"
            }, "2": {
                Telefono: "+51 912345789",
                "Codigo Postal": "2",
            }, "3": {
                "Email": "emilio@pdf_ivc.com",
                "Nr°": "123"
            }
        }

ColsTwo Este objeto contiene información organizada en bloques numerados, pensados para ser presentados como columnas o secciones visuales dentro de documentos PDF.

const colsTwo = {
            title: "Envio",
            "1": {
                Empresa: "Shalom",
                Clave: "12345"
            },
            "2": {
                Ubicacion: "Peru, Lima, Chorrillos",
                "Codigo Postal": "140105",
            },
            "3": {
                "Dirección de Domicilio": "Jr. Peru 1234",
                "Nr°": "123"
            }
        },

Type: Cols

interface Cols {
    title: string,
    "1": {
        [x: string]: string
    }
    "2"?: {
        [x: string]: string
    }
    "3"?: {
        [x: string]: string
    }
}

Table

Header Este arreglo define los encabezados que se utilizarán en la tabla principal del documento PDF.

const header = [
            "ID",
            "Nombre",
            "Descripcion",
            { relevant: ["Quantity", "Price U.", "Total Price"] },
        ]

Data El sistema de generación de documentos PDF incluye una lógica de paginación integrada. Por cada 12 ítems registrados en el arreglo data, se crea automáticamente una nueva página en el documento.

const data = data: Array.from({ length: 48 }, (_, i) => [
            `U${1000 + i}`,
            `Manzana`,
            `Manzana roja`, 
            { relevant: [`${i + 1}`, `S/${i + 1}.00`, `S/${i + 100}.00`] },
        ]),

Result El último objeto del arreglo Total Importe representa el resultado más importante o relevante, y suele destacarse visualmente como cierre.

const result = [
            { key: "OP. GRAVADA", value: "S/39.33" },
            { key: "IGV -18%", value: "S/7.07" },
            { key: "Total Importe", value: S/"46.40" }
        ]

Type: Table

interface Table {
    header: ({ relevant: string[] } | string)[],
    data: ({ relevant: string[] } | string)[][],
    result: {
        key: string,
        value: string
    }[],
}

Payment

Este objeto contiene información relacionada con los datos de pago que se mostrarán.

const payment = {
        "Nr° Cuenta": "191-23456789-0-12",
        "Empresa": "Enpvase S.A.C",
        logo: 'img/img-3.png'
    }

Type: Payment

export Payment {
    [x: string]: string
}

PaymentDetails

Este objeto contiene los detalles específicos de una operación de pago que serán mostrados.

const paymentDetails = {
        "Nr° Operación": "123456",
        "Banco": "Banco de Crédito",
        "Método de pago": "Efectivo",
        "Operacion": "24 de Enero del 2025 - 08:07 PM",
        logo: 'img/img-3.png'
    }

Message Este campo opcional dentro del objeto paymentDetails permite mostrar un mensaje personalizado en el documento PDF, generalmente utilizado para advertencias, condiciones o notas importantes relacionadas con el pago.

const paymentDetails = {
        message: {
          key: 'Mensaje',
          value: "⚠️Importante antes de realizar el pago: Por favor, asegúrese de revisar su pedido cuidadosamente. No se aceptan devoluciones. Una vez confirmado el pago, su pedido llegará en un plazo de 15 días."
        },
    }

Type: PaymentDetails

export interface PaymentDetails {
    logo?: PDFKit.Mixins.ImageSrc,
    message?: {
        key: string, value: string
    },
    [x: string]: string | { key: string, value: string } | PDFKit.Mixins.ImageSrc
}

Footer

Incluye elementos visuales y de contacto que refuerzan el cierre del documento.

const footer = {
        logo: 'img/logo.png',
        text: 'Gracias por la compra',
        contact: 'www.pdf-ivc.com'
    }

Type: Footer

interface Footer {
    logo: string
    text: string,
    contact: string
}

Config

Permite personalizar colores generales, bordes, códigos QR y estilos específicos de la tabla

const config = {
        color: '#4C63ED',
        borderColor: '#E8E8E8',
        qrColor: 'blue',
        table: {
            bgResaltLast: 'white',
            textColor: 'black',
            bgResult: 'blue'
        }
    }

Type: Config

interface Config {
    color?: string;
    borderColor?: string;
    qrColor?: string;
    table?: {
      bgResult?: string;
      textColor?: string;
      bgResaltLast?: string;
    };

Data

La siguiente interfaz define la estructura de datos que debe ser ingresada para generar el documento PDF.

const data: Data = {
    header: {
        enterprise: {
            logo: 'img/logo.png',
            name: "PDF-IVC, Corp",
            aditional: 'www.pdf-ivc.com',
            indificatorTribute: 'RUC 0222351515',
        },
        order: {
            qr: 'www.pdf-ivc.com',
            id: 'N° 0001-2025',
            aditional: 'Av. Angamos Nro. 1805 - 01234567',
            createAt: '01 Enero 2025 - 08:07 PM',
            payment: { text: 'Pendiente - Efectivo', color: 'green' },
        }
    },
    details: {
        colsOne: {
            title: "Cliente", 
            "1": {
                Nombre: "Emilio Sánchez Pérez Mamani",
                DNI: "DNI 12345678"
            }, "2": {
                Telefono: "+51 912345789",
                "Codigo Postal": "2",
            }, "3": {
                "Email": "emilio@pdf_ivc.com",
                "Nr°": "123"
            }
        },
        colsTwo: {
            title: "Envio",
            "1": {
                Empresa: "Shalom",
                Clave: "12345"
            },
            "2": {
                Ubicacion: "Peru, Lima, Chorrillos",
                "Codigo Postal": "140105",
            },
            "3": {
                "Dirección de Domicilio": "Jr. Peru 1234",
                "Nr°": "123"
            }
        },
    },
    table: {
        header: [
            "ID",
            "Name",
            "Description",
            { relevant: ["Quantity", "Price U.", "Total Price"] },
        ],
        data: Array.from({ length: cols }, (_, i) => [
            `U${1000 + i}`, // ID
            `Apple ${1 + i}`,
            `Apple delicous bad english${20 + i}`, // Edad
            { relevant: [`${i + 1}`, `S/${i + 1}.00`, `S/${i + 100}.00`] },
        ]),
        result: [
            { key: "OP. GRAVADA", value: "39.33" },
            { key: "IGV -18%", value: "7.07" },
            { key: "Total Import", value: "46.40" }
        ]
    },
    payment: {
        "Nr° Cuenta": "191-23456789-0-12",
        "Empresa": "PDF-IVC S.A.C",
        logo: 'img/payment-2.png'
    },
    paymentDetails: {
        "Nr° Operación": "123456",
        "Banco": "BBVA",
        "Método de pago": "Cuenta Corriente",
        "Operacion": "24 de Enero del 2025 - 08:07 PM",
        logo: 'img/payment-2.png'
    },
    footer: {
        logo: 'img/logo.png',
        text: 'Gracias por la compra',
        contact: 'www.pdf-ivc.com'
    },
    config: {
        color: '#4C63ED',
        borderColor: '#E8E8E8',
        qrColor: '#4C63ED',
        table: {
            bgResaltLast: 'white',
            textColor: 'black',
            bgResult: 'blue'
        }
    }
}

Type: Data

export interface Data {
  header: {
    enterprise: Enterprise;
    order: Order;
  };
  details: {
    colsOne: Cols;
    colsTwo: Cols;
  };
  table: Table;
  payment: Payment;
  paymentDetails: PaymentDetails;
  footer: Footer;
  config?: {
    color?: string;
    borderColor?: string;
    qrColor?: string;
    table?: {
      bgResult?: string;
      textColor?: string;
      bgResaltLast?: string;
    };
  };
}