Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1.  
  2. if (!error) {
  3. try {
  4. var result = JSON.parse(fs.readFileSync(phantomJsExecPath + '/result' + objectId + '.json').toString());
  5. fs.unlinkSync(phantomJsExecPath + '/result' + objectId + '.json');
  6.  
  7. if ( fs.existsSync(phantomJsExecPath + "/devis" + objectId + ".pdf") ) {
  8. var original_data = fs.readFileSync(phantomJsExecPath + "/devis" + objectId + ".pdf");
  9. result.devis = new Buffer(original_data, 'binary').toString('base64');
  10. fs.unlinkSync(phantomJsExecPath + '/devis' + objectId + '.pdf');
  11. }
  12.  
  13. if (fs.existsSync(phantomJsExecPath + "/specimen" + objectId + ".pdf")) {
  14. pdfToImage("specimen" + objectId + ".pdf", "devis" + objectId + ".jpg", function (base64) {
  15. result.image = base64;
  16.  
  17. res.json({ error: false, result: result });
  18. });
  19. }
  20. else
  21. res.json({ error: false, result: result });
  22. } catch (e) {
  23. console.log(e);
  24. var bitmap = fs.readFileSync(capturePath);
  25. res.json({
  26. error: true,
  27. error_message: e,
  28. screenshot: new Buffer(bitmap).toString('base64')
  29. });
  30. }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement