
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.
@lpgroup/ghostscript
Advanced tools
Flatten and optimize PDF with shell command Ghostscript gsx.
The npm module requires shell command Ghostscript to be installed on the machine.
# OSX
brew install ghostscript
# Alpine
apk update
apk add imagemagick ghostscript-fonts ghostscript
# Debian/ubuntu
apt-get update
apt-get install ghostscript
Installation of the npm
npm install @lpgroup/ghostscript
const { readfilesync, writeFile } = require("fs");
const { resolve } = require("path");
const { optimize } = require("@lpgroup/ghostscript");
const fileIn = resolve("./test/flytt_uppdrag.pdf");
const fileOut = resolve("./test/flytt_uppdrag_optimized.pdf");
const input = readfilesync(fileIn);
optimize({ input }).then((output) => {
writeFile(fileOut, output, "binary");
});
env DEBUGThis package uses the debug npm. Debug messages are printed to stdout if the follwoing is set.
export DEBUG=ghostscript
optimize({options})Following are all values that can be used in options and the default values that are used if none is entered.
optimize({
input,
compressFonts: true,
embedAllFonts: true,
subsetFonts: true,
dpi: 300,
colorConversionStrategy: "RGB",
});
Below is the shell command executed by node, if you'd like to optimize it further yourself. Credit goes to Matt DesLauriers and the repo http://github.com/mattdesl/gsx-pdf-optimize
Removed according to https://stackoverflow.com/questions/49686527/ghostscritpt-converted-file-not-view-able-in-adobe-reader -dPDFSETTINGS=/screen -dCompatibilityLevel=1.5
cat test/large-file.pdf | \
gsx -sDEVICE=pdfwrite \
-dNOPAUSE \
-dQUIET \
-dBATCH \
-dSubsetFonts=true \
-dCompressFonts=true \
-dEmbedAllFonts=true \
-sOutputFile=- - > flytt_uppdrag_optimized.pdf
See contribute
MIT - See licence
FAQs
Wrapping ghostscript cli tool
The npm package @lpgroup/ghostscript receives a total of 99 weekly downloads. As such, @lpgroup/ghostscript popularity was classified as not popular.
We found that @lpgroup/ghostscript demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers 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.