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 🙏

© 2024 – Pkg Stats / Ryan Hefner

diplomas-generator

v1.5.1

Published

A versatile tool for generating diplomas and certificates from a list of names, with support for customizable designs and output formats like JPG and PDF.

Downloads

113

Readme

Generate diplomas

tests

A versatile tool for generating diplomas and certificates from a list of names, with support for customizable designs and output formats like JPG and PDF.

Example of generated diploma.

Basic usage

import { generateTitles } from "diplomas-generator";

// Configuration object for generating titles.
const config = {
  inputNames: "src/data/names.txt", // or [ "name1", "name2", ...]
  inputTitlePath: "src/image/title.jpg", // Path to the title image file
};

generateTitles(config)
  .then(() => {
    console.log("Diplomas generated successfully!");
  })
  .catch((error) => {
    console.error("Error generating diplomas:", error);
  });

** Important ** This package uses the package node-canvas to generate the diplomas, so in some cases you need to install the OS dependencies of this package to use it. See the OS specific instructions here

| Parameter | Description | | ---------------- | -------------------------------------------------------------------------------------------- | | inputNames* | Required* File path for the text file containing the names. Can be an array of strings. | | fontSize | Font size for the name on the diplomas. | | color | Text color for the name on the diplomas, in hexadecimal format. | | textAlign | Horizontal alignment for the name on the diplomas. "center", "start", "end", "left", "right" | | positionNameX | X coordinate (in pixels) for the horizontal position of the name on the diplomas. | | positionNameY | Y coordinate (in pixels) for the vertical position of the name on the diplomas. | | imageQuality | Quality of the base image of the title on the diplomas, as a value between 0 and 1. | | fontPath | File path for the text font for the names on the diplomas. | | inputTitlePath | File path for the base image file of the title on the diplomas. | | exportImg | Boolean to enable or disable the export of the diplomas as JPG files. | | outputImgPath | Output path to save the generated diplomas as images. | | exportPDF | Boolean to enable or disable the export of the diplomas as PDF files. | | outputPdfPath | Output path to save the generated diplomas as PDF files. | | enableLogging | Boolean to enable or disable the logging of the process. |

Considerations

  • exportImg is the most expensive operation in the process, so if you don't need the images, set it to false to speed up the process.

  • inputNames, inputTitlePath, outputImgPath, and outputPdfPath should be relative paths to the project root.

  • positionNameX and positionNameY are the coordinates (px) of the name in the diploma. By default, the name is centered in the diploma. Use these parameters to adjust the position of the name in the diploma.

  • Use textAlign to adjust the horizontal alignment of the name relative to the positionNameX.

File names.txt should contain a list of names separated by new line.

Maria Perez
Patrick Smith
Jane Doe

CommonJS usage

const { generateTitles } = require("diplomas-generator");
const config {
  ...
}
generateTitles(config).then().catch();

Advanced usage

import { generateTitles } from "diplomas-generator";

// Configuration object for generating titles.
const config = {
  inputNames: "src/data/names.txt", // or [ "name1", "name2", ...]
  fontPath: "src/fonts/itcedscr.ttf", // Path to the font file
  fontSize: 220, // Font size in pixels
  color: "#000000", // Text color in hexadecimal format
  textAlign: "center", // Text alignment
  positionNameX: 1625, // X-coordinate position for placing the name
  positionNameY: 950, // Y-coordinate position for placing the name
  imageQuality: 0.9, // Image quality (0.1 to 1)
  inputTitlePath: "src/image/title.jpg", // Path to the title image file
  exportImg: true, // Whether to export images (default: true)
  outputImgPath: "output/img",
  exportPDF: true, // Whether to export PDF (default: true)
  outputPdfPath: "output/titles.pdf",
  enableLogging: true, // Whether to enable logging (default: false)
};

generateTitles(config)
  .then(() => {
    console.log("Diplomas generated successfully!");
  })
  .catch((error) => {
    console.error("Error generating diplomas:", error);
  });