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

pdf2png

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pdf2png - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

79

lib/pdf2png.js
var exec = require('child_process').exec;
var tmp = require('tmp');
var fs = require('fs');
var http = require('http');
var tmp = require('tmp');
var filesource = require('filesource');

@@ -43,5 +43,11 @@ var initialized = false;

var execute = function() {
filesource.getDataPath(filepathOrData, function(resp){
if(!resp.success)
{
callback(resp);
return;
}
// get temporary filepath
tmp.file({ postfix: ".png" }, function (err, imageFilepath, fd) {
tmp.file({ postfix: ".png" }, function(err, imageFilepath, fd) {
if(err)

@@ -53,5 +59,5 @@ {

exec("gs -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r" + options.quality + " -dFirstPage=1 -dLastPage=1 -sOutputFile=" + imageFilepath + " " + filepathOrData, function (error, stdout, stderr) {
// Remove temp file
if(tmpFileCreated) fs.unlink(filepathOrData);
exec("gs -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r" + options.quality + " -dFirstPage=1 -dLastPage=1 -sOutputFile=" + imageFilepath + " " + resp.data, function (error, stdout, stderr) {
// Remove temp files
resp.clean();

@@ -78,60 +84,3 @@ if(error !== null)

});
};
if(typeof(filepathOrData) == "object")
{
tmpFileCreated = true;
var fileData = filepathOrData;
// get temporary filepath
tmp.file({ postfix: ".pdf" }, function (err, path, fd) {
if(err)
{
callback({ success: false, error: "Error getting first temporary filepath: " + err });
return;
}
fs.writeFile(path, fileData, function(err) {
if(err)
{
callback({ success: false, error: "Error saving given binary filedata to file: " + err });
return;
}
// set filepath
filepathOrData = path;
// Execute
execute();
});
});
}
else if(filepathOrData.substr(0, 7) == "http://" || filepathOrData.substr(0, 8) == "https://")
{
tmpFileCreated = true;
// get temporary filepath
tmp.file({ postfix: ".pdf" }, function (err, path, fd) {
if(err)
{
callback({ success: false, error: "Error getting first temporary filepath: " + err });
return;
}
var file = fs.createWriteStream(path);
var request = http.get(filepathOrData, function(response) {
response.pipe(file);
response.on('end', function () {
// set filepath
filepathOrData = path;
// Execute
execute();
});
});
});
}
else execute();
});
};

5

package.json
{
"name": "pdf2png",
"version": "1.0.3",
"version": "1.0.4",
"description": "Takes a PDF-document and converts and delivers a PNG",

@@ -8,3 +8,4 @@ "engine": "node >= 0.6.0",

"devDependencies": {
"tmp": "0.0.23"
"tmp": "0.0.23",
"filesource": "latest"
},

@@ -11,0 +12,0 @@ "repository" :

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