Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
A utility for converting pdf to image and base64 format.
IMPORTANT NOTE: Please support this library by donating via PayPal, your help is much appreciated. Contributors are also welcome!
Follow this guide to install the required dependencies.
npm install -S pdf2pic
import { fromPath } from "pdf2pic";
const options = {
density: 100,
saveFilename: "untitled",
savePath: "./images",
format: "png",
width: 600,
height: 600
};
const storeAsImage = fromPath("/path/to/pdf/sample.pdf", options);
const pageToConvertAsImage = 1;
storeAsImage(pageToConvertAsImage).then((resolve) => {
console.log("Page 1 is now converted as image");
return resolve;
});
More usage example can be found here.
Initialize PDF to image conversion by supplying a file path
Convert a specific page of the PDF to Image/Base64 by supplying a file path
fromPath(filePath, options)(page, isBase64)
convert()
will return base64 output insteadConverts PDF to Image/Base64 by supplying a file path
fromPath(filePath, options).bulk(pages, isBase64)
pages
to -1
to convert all pagespages
also accepts an array indicating the page number e.g. [1,2,3]
1
bulk()
will return an array of base64 output insteadSet GraphicsMagick's subclass or path
fromPath(filePath, options).setGMClass(subClass)
NOTE: should be called before calling convert()
or bulk()
.
subClass
to true to use imagemagicksubClass
to locate gm path specifiedInitialize PDF to image conversion by supplying a PDF buffer
Convert a specific page of the PDF to Image/Base64 by supplying a buffer
fromBuffer(buffer, options)(page, isBase64)
Functions same as fromPath(filePath, options)(page, isBase64)
only input is changed
Converts PDF to Image/Base64 by supplying a buffer
fromBuffer(buffer, options).bulk(pages, isBase64)
Functions same as fromPath(filePath, options).bulk(pages, isBase64)
only input is changed
Set GraphicsMagick's subclass or path
fromBuffer(buffer, options).setGMClass(subClass)
Functions same as fromPath(filePath, options).setGMClass(subClass)
only input is changed
Initialize PDF to image conversion by supplying a PDF base64 string
Convert a specific page of the PDF to Image/Base64 by supplying a base64 string
fromBase64(b64string, options)(page, isBase64)
Functions same as fromPath(filePath, options)(page, isBase64)
only input is changed
Converts PDF to Image/Base64 by supplying a base64 string
fromBase64(b64string, options).bulk(pages, isBase64)
Functions same as fromPath(filePath, options).bulk(pages, isBase64)
only input is changed
Set GraphicsMagick's subclass or path
fromBase64(b64string, options).setGMClass(subClass)
Functions same as fromPath(filePath, options).setGMClass(subClass)
only input is changed.
Following are the options that can be passed on the pdf2pic api:
option | default value | description |
---|---|---|
quality | 0 | Image compression level. Value depends on format , usually from 0 to 100 (more info) |
format | 'png' | Formatted image characteristics / image format (image characteristics, image format) |
width | 768 | Output width |
height | 512 | Output height |
density | 72 | Output DPI (dots per inch) (more info) |
savePath | './' | Path where to save the output |
saveFilename | 'untitled' | Output filename |
compression | 'jpeg' | Compression method (more info) |
pdf2pic is MIT licensed.
FAQs
A utility for converting pdf to image formats. Supports different outputs: directly to file, base64 or buffer.
The npm package pdf2pic receives a total of 0 weekly downloads. As such, pdf2pic popularity was classified as not popular.
We found that pdf2pic demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.