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

@hostaqui/pdf-maker

v1.1.0

Published

[![build](https://github.com/HOSTAQUI/pdf.maker/actions/workflows/build.yml/badge.svg)](https://github.com/HOSTAQUI/pdf.maker/actions/workflows/build.yml) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e

Readme

pdf.maker

build semantic-release npm version License: MIT

Uma biblioteca robusta para gerar PDFs a partir de conteúdo web (HTML, URL, Handlebars) de forma programática, utilizando o poder do Puppeteer.

✨ Tecnologias

  • TypeScript: Para um código mais seguro e manutenível.
  • Puppeteer: Para controle do browser e geração do PDF.
  • Handlebars: Para geração de PDFs a partir de templates.
  • Jest: Para garantir a qualidade e o funcionamento dos testes.
  • ESLint & Prettier: Para manter o código limpo e padronizado.

📦 Instalação

Para instalar o pacote, utilize o seguinte comando:

npm install @hostaqui/pdf-maker
# ou
yarn add @hostaqui/pdf-maker

Se você for utilizar o handler de Handlebars, precisará instalar a dependência manualmente:

npm install handlebars
# ou
yarn add handlebars

🚀 Como Usar

A função principal da biblioteca é a render. Ela é flexível e permite gerar um PDF de diferentes fontes.

Gerando PDF a partir de um HTML

Você pode fornecer o conteúdo HTML diretamente como uma string.

import { render } from '@hostaqui/pdf-maker';
import { writeFileSync } from 'fs';

async function generatePdfFromHtml() {
  const htmlContent =
    '<h1>Olá, Mundo!</h1><p>Este é um PDF gerado a partir de um HTML.</p>';

  const pdfBuffer = await render({
    handler: 'html',
    options: {
      content: htmlContent,
      // Opcional: passe as opções do Puppeteer aqui
      pdf: {
        format: 'A4',
        printBackground: true,
      },
    },
  });

  writeFileSync('meu-pdf.pdf', pdfBuffer);
}

generatePdfFromHtml();

Gerando PDF a partir de uma URL

Basta fornecer a URL da página que você deseja converter para PDF.

import { render } from '@hostaqui/pdf-maker';
import { writeFileSync } from 'fs';

async function generatePdfFromUrl() {
  const pdfBuffer = await render({
    handler: 'url',
    options: {
      url: 'https://google.com',
      // Opcional: passe as opções do Puppeteer aqui
      pdf: {
        landscape: true,
      },
    },
  });

  writeFileSync('meu-pdf-da-url.pdf', pdfBuffer);
}

generatePdfFromUrl();

Gerando PDF a partir de um template Handlebars

Você pode usar templates Handlebars para gerar PDFs dinâmicos.

import { render } from '@hostaqui/pdf-maker';
import { writeFileSync } from 'fs';

async function generatePdfFromHandlebars() {
  const template =
    '<h1>Olá, {{nome}}!</h1><p>Seu pedido de número {{pedidoId}} foi confirmado.</p>';
  const data = {
    nome: 'Gabriel',
    pedidoId: '12345',
  };

  const pdfBuffer = await render({
    handler: 'handlebars',
    options: {
      content: template,
      data: data,
      // Opcional: passe as opções do Puppeteer aqui
      pdf: {
        format: 'Letter',
      },
    },
  });

  writeFileSync('meu-pdf-dinamico.pdf', pdfBuffer);
}

generatePdfFromHandlebars();

⚙️ API de Métodos

render(options: RenderOptions): Promise<Buffer>

Esta é a função principal e exportada. Ela recebe um objeto de opções e retorna uma Promise que resolve com o Buffer do PDF gerado.

RenderOptions

🤝 Como Contribuir

Contribuições são sempre bem-vindas! Siga os passos abaixo para contribuir:

  1. Fork este repositório: Crie uma cópia do projeto na sua conta do GitHub.
  2. Clone o seu fork: git clone https://github.com/hostaqui/pdf.maker.git
  3. Crie uma branch para sua feature: git checkout -b minha-nova-feature
  4. Instale as dependências: npm install
  5. Faça suas alterações: Implemente sua nova funcionalidade ou correção.
  6. Execute os testes: npm run test
  7. Faça o commit das suas alterações: Utilize o padrão de Conventional Commits. Ex: feat: Adiciona suporte para EJS ou fix: Corrige problema de renderização de imagens.
  8. Envie para a sua branch: git push origin minha-nova-feature
  9. Abra um Pull Request: Crie um Pull Request para a branch main do repositório original.

📜 Licença

Este projeto está licenciado sob a licença MIT. Veja o arquivo LICENSE para mais detalhes.

✨ Créditos

Este projeto é mantido pela HOSTAQUI e foi desenvolvido por Gabriel Hijazi.