-
Notifications
You must be signed in to change notification settings - Fork 298
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
Failed to run pdf2json: ENOENT no such file or directory #349
Comments
Here's the code path in play here: const _pdfjsFiles = [
'shared/util.js',
'shared/colorspace.js',
'shared/pattern.js',
'shared/function.js',
'shared/annotation.js',
'core/core.js',
'core/obj.js',
'core/charsets.js',
'core/crypto.js',
'core/evaluator.js',
'core/fonts.js',
'core/font_renderer.js',
'core/glyphlist.js',
'core/image.js',
'core/metrics.js',
'core/parser.js',
'core/stream.js',
'core/worker.js',
'core/jpx.js',
'core/jbig2.js',
'core/bidi.js',
'core/jpg.js',
'core/chunked_stream.js',
'core/pdf_manager.js',
'core/cmap.js',
'core/cidmaps.js',
'display/canvas.js',
'display/font_loader.js',
'display/metadata.js',
'display/api.js'
];
_pdfjsFiles.forEach( (fieldName, idx, arr) => _fileContent += fs.readFileSync(_basePath + fieldName, 'utf8') );
eval(_fileContent) The main issue with this from an analysis point of view is that it's a new type of analysis to backtrack from a readFileSync statement to try to piece together the whole expression. Furthermore it is followed by an eval so this seems like it may be better handled by a special casing again. |
Would changing the source code solve the problem? - _pdfjsFiles.forEach( (fieldName, idx, arr) => _fileContent += fs.readFileSync(_basePath + fieldName, 'utf8') );
+ _pdfjsFiles.forEach( (fieldName, idx, arr) => _fileContent += fs.readFileSync(__dirname + '/../base/' + fieldName, 'utf8') ); Or is it simply the fact that they went up a directory ( |
The problem is more that we don't know to emit the assets in the list of _pdfjsFiles, or how to relocate their references. This is because of the level of abstraction between _basePath and _pdfjsFiles in the readFileSync expression. |
@styfle if we had something like your example, then the wildcard emission proposal would handle this though, yes, even without the file list analysis. |
@guybedford If "wildcard emission proposal" is referring to #297 then I think we should prioritize #297 and then we could probably submit a PR to |
Actually we know exactly what |
Fixed in #378 |
I'm a bit new to github issues so it's a bit confusing to follow where the solution can be found. But I'm struggling with this issue with pdf2json causing failures on my nextjs app hosted on vercel. |
I am also facing the same issue with my nextjs app hosted on netlify |
Hey @PaulChase, I followed this thread modesty/pdf2json#330 and was able to resolve my issue. Updating the package it was pulling from to a fix from a fellow dev seemed to fix it for me. Hopefully this helps! |
Steps to reproduce
git clone https://github.com/friedhelmensch/node_now_pdf2json_issue cd node_now_pdf2json_issue ncc build index.js node dist
Error
The text was updated successfully, but these errors were encountered: