Changing page variable to in-memory stream #102
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe the change
A reference to the "data" variable caused issues with pdfminer while attempting to extract text from a PDF. This error would only occur when the user sets "extract_text" to True from the ScanPdf options in backend.yml. To fix this, we are instead replacing "data" with "pdf_io", an in-memory stream of the data object. This is readable by pdfminer, whereas the data object was not.
Describe testing procedures
Change was made on a local instance. No errors were observed after making the change, and the error that appeared previously was removed. Logging was used to examine the output, which displays proper text extraction.
Sample output
Text extraction noted in header.header:
"scan": { "entropy": { "elapsed": 0.000155, "entropy": 4.953766942682617 }, "hash": { "elapsed": 0.000296, "md5": "039f829a06d43589415673da5ec04431", "sha1": "05b0afac91db59a9de83a2d8b9886586dd76e383", "sha256": "d42488f5ff2444ce075f19c89751ab8f092d9d31c6bae7643b10f3a9550fd5ac", "ssdeep": "192:8lsOIwGOp0/KydxQYBfluX/NtVuvpAyO0aAszFVtLuWNg:8lsOIwGdXDubylzaAs1Lucg" }, "header": { "elapsed": 0.000124, "header": "he pdf995 suite of products - Pdf995, PdfEdit995, " }, "url": { "elapsed": 0.003095, "urls": [ "www.pdf995.com", "http://www.wired.com/\",whichisnothuman-centereddata.In" ] }, "yara": { "elapsed": 0.000207, "flags": [ "compiling_error" ] }
Checklist