w3nl / ppt-png

Convert ppt to png
MIT License
45 stars 7 forks source link

Windows Server 2019 issue #18

Closed vacu closed 4 years ago

vacu commented 4 years ago

Trying to run it under a Windows server but I'm getting "SyntaxError: Invalid Unicode escape sequence".

Tried running it like: "C:\Program Files\LibreOffice\program\soffice.exe" --headless --invisible --convert-to pdf:writer_pdf_Export --outdir 'C:\inetpub\xxx\public\uploads\courses\' 'C:\inetpub\xxx\public\uploads\courses\5f452ad9db613d2490cf0ea0.pptx' and & 'C:\Program Files\LibreOffice\program\soffice.exe' --headless --invisible --convert-to pdf:writer_pdf_Export --outdir 'C:\inetpub\xxx\public\uploads\courses\' 'C:\inetpub\xxx\public\uploads\courses\5f452ad9db613d2490cf0ea0.pptx'

The first command ran under cmd works and the second under PowerShell as well.

Here's the stack trace: SyntaxError: Invalid Unicode escape sequence at new Function (<anonymous>) at generateOutputFormatFunction (C:\inetpub\xxx\node_modules\ppt-png\js\pdf2image.js:285:12) at processOptions (C:\inetpub\xxx\node_modules\ppt-png\js\pdf2image.js:331:32) at new Converter (C:\inetpub\xxx\node_modules\ppt-png\js\pdf2image.js:16:24) at Object.module.exports.compileConverter (C:\inetpub\xxx\node_modules\ppt-png\js\pdf2image.js:31:12) at Converter.convertedToPdf (C:\inetpub\xxx\node_modules\ppt-png\js\convert.js:245:37) at ChildProcess.exithandler (child_process.js:315:5) at ChildProcess.emit (events.js:314:20) at maybeClose (internal/child_process.js:1051:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)

vacu commented 4 years ago

In converter.js at LOC 225 you are using single quotes and Windows is running child_processes under cmd which accepts only double quotes.

w3nl commented 4 years ago

Thanks, I'll check the pull request

vacu commented 4 years ago

I will close the PR since it's not working, the issue is with the pathing in windows. More exactly he is expecting a double \ in the paths not a single one.

0|elearning | powershell soffice --headless --invisible --convert-to pdf:writer_pdf_Export --outdir 'C:\\inetpub\\ithelearning\\public\\uploads\\courses\\' 'C:\\inetpub\\ithelearning\\public\\uploads\\courses\\5f455a010a303a06883077aa.pptx' 0|elearning | Converted to pdf 0|elearning | Error on converting to pdf 0|elearning | Total time: 541ms for 1 files 0|elearning | ................. { 0|elearning | success: Arr(0) [], 0|elearning | failed: Arr(1) [ 0|elearning | { 0|elearning | file: 'C:\\\\inetpub\\\\ithelearning\\\\public\\\\uploads\\\\courses\\\\5f455a010a303a06883077aa.pptx', 0|elearning | failure: 'Document convert', 0|elearning | error: [Error] 0|elearning | } 0|elearning | ], 0|elearning | files: Arr(1) [ 0|elearning | 'C:\\\\inetpub\\\\ithelearning\\\\public\\\\uploads\\\\courses\\\\5f455a010a303a06883077aa.pptx' 0|elearning | ], 0|elearning | time: 541 0|elearning | }

But I got this after i used:

files: [newPath.replace(/\\/g, '\\\\').toString()], output: config.UPLOAD_FILE_PATH.replace(/\\/g, '\\\\').toString(),

I will try and fix it tomorrow since it's been 12 hrs since i'm trying to figure it out.

Cheers for the fast response.

vacu commented 4 years ago

Check the PR and close this after the merge or if you found a better way. Cheers!

w3nl commented 4 years ago

You can use version 0.7.0 If you have some issues, let me know.