
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Npm package for using pdfjam utilities.
This project for now mainly implements the 'nup' capabilities. It can merge multiple pdfs into one, and also merge pages of pdfs so 4 pages would appear in one for example. More info here
Here is a demonstration
/* We are using await / async syntax here from node 8+, you can also use Promise syntax instead */
const pdfjam = require('pdfjam');
async function main() {
/* Standard conversion of pdf with pages in a 2x2 layout */
await pdfjam.nup('file.pdf', 2, 2, {
/* Suffix the new pdf file will have, `${originalName}-{suffix}.pdf`, by default is 'nup' */
suffix: '2x2'
});
/* Just merge files, no page layout. Suffix is "pdfjam" in this case */
await pdfjam(['file1.pdf', 'file2.pdf', 'file3.pdf'], {
// nup : "2x2" <- nup can be used through options
// default suffix is "pdfjam" here
// In fact the options argument is never mandatory
});
/* Conversion of pdf with pages in a 1x2 layout */
await pdfjam.nup('file.pdf', 1, 2, {
/* Destination file, overrides suffix */
outfile: 'file-converted.pdf'
});
/* Output in landscape mode, with paper size specified (by default A4) */
await pdfjam.nup('file.pdf', 2, 1, {
orientation: 'landscape',
papersize: '{1920px,1080px}' /* Can also use cm as unit */
scale: 0.9 /* Reduce input page sizes a bit */
});
/* Merge multiple files in one, with the output a layout of 2x2 */
await pdfjam.nup(['file1.pdf', 'file2.pdf', 'file3.pdf'], 2, 2, {
scale: 0.9 /* Reduce input page sizes a bit */
});
/* Merge multiple slides and adjust margins */
await pdfjam(['slide1.pdf', 'slide2.pdf', 'slide3.pdf', 'slide4.pdf', 'slide5.pdf'], {
outfile: "slides.pdf",
trim: "-6cm -1cm 13cm 8cm",
scale: 0.4
});
}
main().then(() => {
console.log("All done!");
})
Pdfjam is needed. On debian systems, you can get it like that:
sudo apt install texlive-extra-utils
Note that this installs 600MB of software if you don't already have a LaTeX infrastructure.
Node version 8+ is expected. If you want to update your node version, you can do:
sudo npm install -g n
sudo n stable
Run this in your project directory:
npm i pdfjam #add --save if your npm is < 5.0
All functions return promises. The output directory of pdfjam is the working directory of your program (process.cwd()),
but you can specify an absolute path in the outfile option.
Invokes pdfjam with the input given. If an array of strings is given as input, then the input files will be merged
in the output, unless the batch options is provided, in which case there will be as many output files as input files.
Here are the valid values for options:
outfile option. Default
value is "pdfjam". The output file name will look like basename-suffix.pdf.suffix if supplied.Helper for page layout. Calls pdfjam with the nup option, as well as the provided options, and if no suffix or outfile is provided, will set the suffix to "nup".
There are many more options that can easily be added to the module, such as paper type (paper: 'a4paper') or page color.
I very welcome contributions or even taking over of the project. This project was made in order to fill one
of my particular needs, the use of pdfnup, so I welcome any contribution adding more of pdjam's features.
I also welcome any contribution in the form of tests, travis integration, using a build script to make the project compatible with older node versions and so on.
FAQs
Pdf manipulation using pdfjam
We found that pdfjam demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.