New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pdftopic

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pdftopic - npm Package Compare versions

Comparing version 1.0.1-alpha to 1.0.2-alpha

curriculum_vitae.png

59

index.js

@@ -0,1 +1,14 @@

/**
* @typedef {Object} Dimmention
* @property {number | undefined} width - the width of the image
* @property {number | undefined} height - the height of the image
*/
/**
* @typedef {Object} DimmentionsData
* @property {number} outputImgWidth - the maximum width of all the images in the array
* @property {number | undefined} outputImgHeight - the sum total of the heights of all the images in the array
* @property {Dimmention[]} dimmentions - an array containing the dimensions (width and height) of each image in {width, height} format
* @property {number} channels - the number of elements in the dimensions array, corresponding to the number of images processed
*
*/
const imagemagick = require("imagemagick-stream");

@@ -9,2 +22,9 @@ const isstream = require("is-stream");

/**
*
* @param {Buffer} pdf
* @param {number} page
* @param {*} bar
* @returns {Buffer}
*/
const imagemagickconverter = async (pdf, page, bar) => {

@@ -49,2 +69,9 @@ const imagemagickstream = imagemagick()

/**
* Converts PDF to Image/Buffer by supplying a file path
* @param {Buffer} pdf Buffer pdf file
* @param {number | number[] | 'all'} page
* @param {boolean} [progress=false] progress converting. Default `false`
* @returns {Promise<Buffer[] | null>} PDF pages converted to image buffers
*/
const pdftobuffer = async (pdf, page, progress = false) => {

@@ -60,3 +87,3 @@ const pdfcount = await pdftocount(pdf);

assert(page >= 0, `the page must be equal to or greater than 0 in the case of ${page}`);
} else if(Array.isArray(page)) {
} else if (Array.isArray(page)) {
Array.from(page, (_) => assert((pdfcount - 1) >= _, 'the page does not exist please try again'));

@@ -75,2 +102,8 @@ }

/**
* Determine the total number of pages in a PDF document by supplying the PDF to the function.
* The function loads the PDF and returns the page count.
* @param {Buffer} pdf Buffer pdf file
* @returns {number} Total pages from the pdf passed in `pdf`
*/
const pdftocount = async (pdf) => {

@@ -81,2 +114,8 @@ const pdfDoc = await PDFDocument.load(pdf);

/**
* Concatenate multiple buffers into a single buffer by providing an array of buffers to the function.
* The function processes each buffer, appends them together, and returns the combined buffer.
* @param {Buffer[]} buffers Array of buffers images
* @returns {Promise<Buffer>} Combined array of buffer images
*/
const bufferstoappend = async (buffers) => {

@@ -111,7 +150,17 @@ const dimmention = await getDimmentions(buffers);

})
.composite(params)
.png()
.toBuffer();
.composite(params)
.png()
.toBuffer();
}
/**
* Asynchronous function that takes an array of buffers as an argument.
* The function returns an object containing the following information:
* - outputImgWidth: the maximum width of all the images in the array.
* - outputImgHeight: the sum total of the heights of all the images in the array.
* - dimmentions: an array containing the dimensions (width and height) of each image in {width, height} format.
* - channels: the number of elements in the dimensions array, corresponding to the number of images processed.
* @param {Buffer[]} buffers Array of buffers images
* @returns {Promise<DimmentionsData>} Dimmentions from the array of buffers images.
*/
const getDimmentions = async (buffers) => {

@@ -121,3 +170,3 @@ const promises = buffers.map(async (buffer) => {

const metadata = await bufferImage.metadata();
return {

@@ -124,0 +173,0 @@ width: metadata.width,

{
"name": "pdftopic",
"version": "1.0.1-alpha",
"version": "1.0.2-alpha",
"description": "Built for Node.js, this package empowers users to effortlessly convert PDF files into images of exceptional quality, supporting multiple formats including PNG, JPG, GIF, and others. Its streamlined functionality ensures a smooth and reliable conversion process, providing users with the flexibility to obtain top-notch images from their PDF documents",
"main": "index.js",
"types": "./types/index.d.ts",
"funding":{

@@ -11,2 +12,3 @@ "type": "paypal",

"scripts": {
"gen-types": "npx -p typescript tsc --declaration --allowJs --emitDeclarationOnly --outDir types",
"test": "jest"

@@ -72,4 +74,6 @@ },

"devDependencies": {
"@types/stream-to-array": "^2.3.3",
"typescript": "^5.3.3",
"jest": "^29.7.0"
}
}

2

README.md

@@ -7,2 +7,3 @@ <img src="https://repository-images.githubusercontent.com/518815977/e762deba-30c4-45ff-8792-ad6769a7f26e">

![Version-Project](https://img.shields.io/github/package-json/v/Ilyes-El-Majouti/pdftopic?style=flat-square&logo=npm)
[![CodeFactor](https://www.codefactor.io/repository/github/ilyes-el-majouti/pdftopic/badge)](https://www.codefactor.io/repository/github/ilyes-el-majouti/pdftopic)

@@ -15,3 +16,2 @@ [![Donate](https://img.shields.io/badge/donate-PayPal-green?style=flat-square&color=blue)](https://www.paypal.me/IlyesElMajouti)

![Last-Commit](https://img.shields.io/github/last-commit/Ilyes-El-Majouti/pdftopic?style=flat-square)
</center>

@@ -18,0 +18,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc