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 🙏

© 2025 – Pkg Stats / Ryan Hefner

source2pdf

v1.2.3

Published

Auto generate a PDF notebook from your source codes (improved version of codes2pdf, useful for ACM-ICPC cheatsheet)

Readme

source2pdf

Auto-generate a PDF notebook from your source codes (useful for ACM-ICPC cheatsheets)

This project is a fork of codes2pdf, which itself was a fork of notebook-generator.
Over the years, the project had accumulated some bugs that I fixed, and and I also added several useful features to improve functionality and usability.


Features

  • Works on Linux and Windows.
  • Generates a PDF notebook with syntax-highlighted source codes.
  • Supports .c, .cpp, .cc, .java, .py, .tex files.
  • Renders LaTeX .tex files directly.
  • Three-column layout per page (improved from original two-column layout).
  • Customizable title, author/team info, and date in the notebook header.

Dependencies

You need TeX Live installed to compile PDFs.

Linux:

sudo apt install texlive

Windows:

Download and install from: TeX Live Windows Installer


Install

npm install -g source2pdf

Usage

source2pdf <source_dir> [options]

Options:

-V, --version               output the version number
-o, --output [filename]     output file for the notebook. Default: ./notebook.pdf
-t, --title [title]         title to be displayed on the first page (default: "Competitive Programming Cheat Sheet")
-u, --university [name]     university name to be added in the notebook
-i, --initials [initials]   initials of the university/team to be placed in the upper-right corner of all pages
-n, --team [name]           name of the team to be displayed in the notebook
-m, --members [names]       names of team members to be added in the header
-d, --date [date]           date to be displayed in the notebook (default: today)
-h, --help                  output usage information

Examples:

# Generate a PDF notebook from the current directory (default filename: notebook.pdf)
source2pdf ./

# Generate a PDF notebook with university and team information
source2pdf ./ --title "ICPC Asia Regional 2025" --university "Sharif University of Technology" --initials SUT --team "Init to win it" --members "Ali Ghanbari, Zahra Ghalvenave" --output ./team_notebook.pdf

The second command will create a PDF file named team_notebook.pdf in the current directory, with three columns per page, a table of contents, and the provided title/university/team info in the header.


Example PDF

See an example notebook here: notebook.pdf

Note: The original project used two columns per page; in this version, the generated PDF has three columns per page, allowing you to fit more source code in fewer pages while keeping the layout clean.


Sample PDF Screenshots

Here are a few screenshots of the generated PDF notebook:

Sample Notebook

Sample Notebook

Sample Notebook


Notes

  • Directory Structure: For a clean and organized table of contents, it is recommended to use up to 3 levels of nested folders in your source code directory. Excessive nesting may make the TOC cluttered.
  • Filenames: Use spaces instead of underscores in filenames to produce a prettier and more readable table of contents.
  • Supported File Types: The generator supports .c, .cpp, .cc, .java, .py, and .tex files. LaTeX (.tex) files are rendered as-is in the notebook.
  • PDF Layout: The generated PDF uses a three-column layout per page (unlike the original two-column version), allowing more source code to fit in fewer pages.
  • Syntax Highlighting: Source code files are automatically syntax-highlighted using LaTeX’s listings package, so your code is easier to read.
  • Customizable Header: You can include a title, university/team information, and initials in the header of every page using the command-line options.
  • Adding Examples: You can include .tex files as examples, formulas, or explanations, which will be rendered directly in the PDF.
  • Performance Tip: Avoid extremely large files in a single directory to keep PDF compilation fast and smooth.

License

MIT License © AliBinary