details:"Error: PDFDocument: stream must have data"
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- javascript, node.js
- Domain
- backend
Research direction
Reproduce the upload flow through the parse entry point and the referenced script.pdfParser call, checking when the write stream finishes relative to parsing. Use the reported error and the provided file path handling to define the fix; done means an uploaded PDF is parsed without the “stream must have data” error.
Written by the indexing model from the issue text.
Description
I am uploading the pdf file first and then trying to parse it using pdf.js but I get this error " details:"Error: PDFDocument: stream must have data". on console I am getting the file and file size is also fine after uploading it.
Code I Used :
var parse = function(payload,callback){
var data = payload;
if(data.file){
var name = data.file.hapi.filename;
var ext = name.split('.');
var extension = ext[1];
if(extension == "pdf"){
var path = __dirname + "/uploads/" + name;
checkFileExist();
var file = fs.createWriteStream(path);
file.on('error', function (err) {
console.error(err)
});
data.file.pipe(file);
var fileName = data.file.hapi.filename;
console.log(fileName);
var fileAbsolutepath = __dirname + "/uploads/" + fileName ;
console.log(fileAbsolutepath);
var parser = script.pdfParser(fileAbsolutepath,function(err,resp){
if(err){
callback(err);
}
else {
callback(resp);
}
})
callback(JSON.stringify(fileName));
}
else{
console.log("Invalid fileType");
callback(JSON.stringify("Invalid FileType"));
}
}
}
var checkFileExist = function() {
var path = __dirname + '/uploads';
fs.exists(path, function(exists) {
if (exists === false) fs.mkdirSync(path);
});
};
module.exports = {
parse: parse
}
- Dominant language
- Java
- Stars
- 2.2k
- Forks
- 396
- Avg merge
- 9d 19h
- Merged PRs (30d)
- 3
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from modesty/pdf2json
-
getRawTextContent() returns the lines of every page in reverse order (bottom to top) since 4.0.3Open
Difficulty 1/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 3/5 1-2 days Newbie friendliness 38/100
-
`getRawTextContent` does not returns words' pieces in proper coordinate orderPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
All issues in modesty/pdf2json
Similar issues
-
Area-UIUX Issue-Bug Issue-Easy (good first issue)
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
TeamAmaze/AmazeFileManager#4769 ·
Maintainers usually reply within 7 days
-
Expose SManga.memo & SChapter.memo fields in GraphQL APIs to support source-specific client featuresOpenenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Suwayomi/Suwayomi-Server#2551 ·
Maintainers usually reply within 9 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
ShaftHQ/SHAFT_ENGINE#7861 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
MetricsHub/metricshub-community#1532 ·
Maintainers usually reply within 1 day