Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
pdf-powerpoint
Advanced tools
Converts one or more PDFs into a powerpoint with one pdf page per slide
A NPM module that accepts one or more PDF files and converts them into Powerpoint slides.
Based on the requirements of your application, one rendering engine may be more appropriate than another. This library currently supports three options. In all cases, you must ensure the binaries are installed for your runtime, they are not packaged with this module.
It is recommended you weigh the runtime performance and output quality of each engine for the content you are converting.
apt-get install -y ghostscript
brew install ghostscript
apt-get install -y mupdf-tools
brew install ghostscript
apt-get install -y inkscape
brew install inkscape
Supported Runtimes: Node > 5.10.0
import {Powerpoint} from 'pdf-powerpoint'
const p = new Powerpoint([options])
clean
- set to false if intermediate image files should be left on the filesystem.jobId
- if provided, this will be included in any logging outputcropLastImage
requires ImageMagick convert
to be on the path. Will crop the last pdf image before placing on slide, sometimes a line would show up if the last PDF page was a partial page.dimensions
p.convertPDFToPowerpoint('input.pdf', [options,] (err, result) => {
//Do something with the result (filepath to output)
})
engine
stagingDir
- This is where the pptx file will be generated.
stagingDir/img
and are automatically removed once the powerpoint file is generated.fs.mkdtemp('${os.tmpdir()}/pdf_ppt_')
to generate a random temp directoryconvertOptions
- These are used for Ghostscript conversion
density
- specifies the PPI setting for the output image
Events are emitted for any client wishing to capture timings or react to incremental artifacts.
The EventEmitter2 library is used, which means you can write a single listener for all events if you wish.
Events emit an object that may have the following properties:
error
- if an error occurredtime
- if the event marks the end of a corresponding start eventoutput
- If there is a PNG or PPTX file generated from the eventerr.png.all
done.png.all
- output
is an array of paths to images generated from PDFdone.png.clean
- output
is the image directory that was deleteddone.pptx.creation
- powerpoint is complete in memory, all images added to slidesdone.pptx.saved
- output
is the pptFiledone.pdf.separate
- output
is the command executeddone.inkscape.export
- after each inkscape conversion completes, output
is the command that was executeddone.inkscape.export.all
- after all inkscape conversions are completedone.gs.convert
- output
is the GhostScript command that was executedcropLastImage
option is set
done.im.convert
- after the last image of each PDF is converteddone.im.convert.all
- after all images are croppederr.im.convert
- if any of the image cropping operations failsdone.mupdf.convert
- output
is the MuPDF (mudraw) command that was executedDebug is used for logging and there are three namespaces you can enable.
This can be turned on by setting DEBUG=pdfppt:*
, read more about Debug here
This library originally used ImageMagick but it was discovered that ImageMagick delegates to GhostScript for PDF -> PNG conversion, so GhostScript is used directly
convert -density 72 -quality 100 -verbose '/tmp/output.pdf[4]' '/tmp/img/output-4.png'
'gs' -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' -dFirstPage=5 -dLastPage=5 '-sOutputFile=/tmp/magick-94224ozuZS3iFphAj%d' '-f/tmp/magick-94224zWXBFMw8ZiEA' '-f/tmp/magick-9422413LS3T1dhoL4'
GhostScript Option Documentation
This module uses the following command: gs -q -dQUIET -sDEVICE=pngalpha -r150 -o outputFile-%d.png
-o option
followed by the output file specification as discussed above. The -o option also sets the -dBATCH
and -dNOPAUSE
options.-q
Quiet startup: suppress normal startup messages, and also do the equivalent of -dQUIET.-dQUIET
Suppresses routine information comments on standard output.-sDEVICE=pngalpha
-r[XResxYRes]
Useful for controlling the density of pixels when rasterizing to an image file. It is the requested number of dots (or pixels) per inch. Where the two resolutions are same, as is the common case, you can simply use -rres.FAQs
Converts one or more PDFs into a powerpoint with one pdf page per slide
We found that pdf-powerpoint 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.