diff --git a/grobid_client/grobid_client.py b/grobid_client/grobid_client.py index b63cf20..61fe167 100644 --- a/grobid_client/grobid_client.py +++ b/grobid_client/grobid_client.py @@ -243,9 +243,18 @@ def process_pdf( include_raw_citations, include_raw_affiliations, tei_coordinates, - segment_sentences + segment_sentences, + from_memory=False ): - pdf_handle = open(pdf_file, "rb") + if from_memory: + # PDF already loaded into memory + # expects pdf_file to be of type 'bytes' + pdf_handle = io.BytesIO(pdf_file) + pdf_file = "" + else: + # expects pdf_file to be path to PDF file + pdf_handle = open(pdf_file, "rb") + files = { "input": ( pdf_file,