New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected identifier (await/async) using node 6.10.3 64-bit #66
Comments
Hi, thanks for reporting your issue. pdfjs requires Node.js >= 7 (or you have to transpile it with e.g. babel) |
var pdf = doc.render() gives an error of: 'doc.render is not a function'. |
Which example are you following? Since const doc = new pdf.Document({
font: new pdf.Font(require('pdfjs/font/helvetica.json')),
padding: 10
})
doc.pipe(fs.createWriteStream('output.pdf'))
// render something onto the document
await doc.end() Edit: probably http://ma.rkusa.st/pdfjs/ , I have to update this page |
I got it from http://ma.rkusa.st/pdfjs/, I will try the example above. |
I need a buffer, I can't create a file on the server I am on. What would you suggest? |
Depends on what you want to do. If it should be send as a HTTP request, I would directly pipe it into the HTTP response to not have to save the whole document in memory first. Since getting a buffer was not very ergonomic, I've added an API for it, see https://github.com/rkusa/pdfjs/blob/master/docs/document.md#asbuffercallback (requires to install pdfjs from Github until I release a new version to NPM) |
You are awesome. I will download and use. |
here is my code: const doc = new pdf.Document({
font: new pdf.Font(require('pdfjs/font/Helvetica.json'))
});
var text;
text = doc.text({
fontSize: 14, lineSpacing: 1.35
});
text.add('This is to test pdfjs');
doc.asBuffer((err, data) => {
if (err) {
console.error(err);
} else {
fs.writeFileSync('test.pdf', data, { encoding: 'binary' });
}
}); I get error: I'm using node 7.10.0. |
Hm that is strange. Your example works for me. It sounds like it is mixing a never and older version of |
Again, thank you. I have the new version installed and no errors. |
server\node_modules\pdfjs\lib\document.js:268
async _startPage() {
^^^^^^^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (D:\Programming\apps.appliedtechres.com\server\node_modules\pdfjs\lib\index.js:5:20)
The text was updated successfully, but these errors were encountered: