png-to-pdf-cli
v1.0.0
Published
A CLI tool to combine multiple PNG files into a single PDF
Maintainers
Readme
png-to-pdf-cli
A command-line tool to combine multiple PNG files into a single PDF document.
Features
- Combines multiple PNG files into a single PDF document
- Automatically sorts files by numerical order in filenames
- Each PNG is placed on its own page in the PDF
- The PDF page size matches the dimensions of each PNG image
- Simple and intuitive command-line interface
Installation
Global Installation (Recommended)
Install the package globally to use it as a command-line tool from anywhere:
npm install -g png-to-pdf-cliLocal Installation
Install as a dependency in your project:
npm install png-to-pdf-cliUsage
Command Line
If installed globally:
png-to-pdf <input-pattern> <output-pdf>If installed locally:
npx png-to-pdf <input-pattern> <output-pdf>Examples
# Combine all PNG files in the current directory
png-to-pdf "./*.png" output.pdf
# Combine all PNG files in a specific directory
png-to-pdf "./images/*.png" output.pdf
# Combine specific PNG files
png-to-pdf "./images/page*.png" combined.pdf
# Use verbose mode for detailed output
png-to-pdf --verbose "./images/*.png" output.pdfAs a Module
You can also use this utility as a module in your own Node.js projects:
const { combinePngToPdf } = require('png-to-pdf-cli');
combinePngToPdf('./path/to/images/*.png', './path/to/output.pdf', true) // true enables verbose mode
.then(() => console.log('PDF created successfully!'))
.catch(err => console.error('Error:', err));Publishing to npm
To publish this package to npm, follow these steps:
Create an npm account if you don't have one already:
npm adduserUpdate the package.json file with your information:
- Set your name as the author
- Add a repository field if you have a GitHub repository
- Consider adding a description and keywords
Make sure your package name is unique:
npm search png-to-pdf-cliTest your package locally:
npm link png-to-pdf --versionPublish to npm:
npm publishTo update the package later:
- Update the version in package.json (follow semantic versioning)
- Run
npm publishagain
License
ISC
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
