getRawTextContent() method not consistent in multiple sequential calls
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
Start at getRawTextContent() and the pdfParser_dataReady handlers in compareGeneratedReportContent, then reproduce the reported behavior with sequential calls using different PDF arguments. Verify that each call returns and writes the raw content for its own input rather than retaining content from an earlier call.
Written by the indexing model from the issue text.
Description
This code parses two pdf files and converts to rawtext and removes the line starting with 'Generated' and then compares those two text files.This method is called more than once sequentially and for each call the arguments to the method changes, but the raw content is not getting replaced for the last call.
function compareGeneratedReportContent(samplePDFFile, sampleXLSXText) {
const pdfParser = new PDFParser(this, true)
const pdfParser2 = new PDFParser(this, true)
const pdfExportPath = path.join(__dirname, '../../resources/report-test/PDFExportedFile.pdf')
const xlsxExportPath = path.join(__dirname, '../../resources/report-test/XLSXExportedFile.xlsx')
let content1 = ''
let content2 = ''
let result = false
pdfParser2.on('pdfParser_dataError', errData => console.log(errData))
pdfParser2.on('pdfParser_dataReady', () => {
content2 = pdfParser2.getRawTextContent().replace(/^.*(Generated).+$/mg, '')
// console.log('content2 ', content2)
fs.writeFileSync(path.join(__dirname, '../../resources/report-test/sample.txt'), content2, 'utf-8')
})
pdfParser2.loadPDF(path.join(__dirname, `../../resources/report-test/${samplePDFFile}.pdf`))
pdfParser.on('pdfParser_dataError', errData => console.log(errData))
pdfParser.on('pdfParser_dataReady', () => {
content1 = pdfParser.getRawTextContent().replace(/^.*(Generated).+$/mg, '')
// console.log('content1 ', content1)
fs.writeFileSync(path.join(__dirname, '../../resources/report-test/generated.txt'), content2, 'utf-8')
})
pdfParser.loadPDF(pdfExportPath)
let readContent2 = fs.readFileSync(path.join(__dirname, '../../resources/report-test/sample.txt'), 'utf-8')
let readContent1 = fs.readFileSync(path.join(__dirname, '../../resources/report-test/generated.txt'), 'utf-8')
if (readContent2 === readContent1) {
console.log('Report pdf file content matches')
result = true
} else {
console.log('Error in matching contents of report pdf')
result = false
}
}
```Can anybody help?
Regards,
Fazi
- 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
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
weaviate/java-client#631 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days