Skip to content

Handle Filenames With Spaces#1

Open
jcreager wants to merge 3 commits intoInkognitoo:masterfrom
jcreager:master
Open

Handle Filenames With Spaces#1
jcreager wants to merge 3 commits intoInkognitoo:masterfrom
jcreager:master

Conversation

@jcreager
Copy link

Encapsulate filenames with spaces in double quotes on resp.data (line
58).

was:
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) {

is now:
exec("gs -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -sDEVICE=png16m -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r" + options.quality + " -dFirstPage="+i+" -dLastPage="+i+" -sOutputFile=" + imageFilepath + " " + '"' + resp.data + '"', function (error, stdout, stderr) {

Encapsulate filenames with spaces in double quotes on resp.data (line
58).
@jcreager
Copy link
Author

Unfortunately this change can't be automatically merged. It looks like your current branch is a little newer than what is on npm: https://www.npmjs.com/package/pdf2png-mp. However, the change I made is minor. Line 36 can be updated with:

  • '"' + resp.data + '"'

instead of:

  • resp.data

After some tinkering, this change allowed me to process filenames with whitespace in the name. If you are curious, I am using your npm module for my on project to convert and OCR pdfs:

https://github.com/jcreager/x2y

updated read and package.json.  also removed some console.log
statements that were used for debugging.
@kanalasumant
Copy link

Hello @Inkognitoo . Thank you for this wonderful module. This works just fine with windows with a node app but with Linux on heroku using a node app, it seems to not work. I am not even getting any console.logs to see what's breaking. I installed gs through a buildpack https://github.com/nurveteam/heroku-buildpack-ghostscript which uses ghostscript 9.20 and set the $PATH env too. It still doesn't seem to work. Any advice or inputs o this would be appreciated. Thanks. Sumant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants