Reading a scanned image in pdf , returning "NO_CONTENT_HERE" #79

Open
opened 2026-02-16 00:16:49 -05:00 by yindo · 3 comments
Owner

Originally created by @swathithiyan on GitHub (Apr 8, 2024).

  1. I was using llama parse cloud to read the content from the scanned image in pdf. Llama parse was able to decode the text from the scanned image.
    2)But starting from today I see that , llama parse not able to decode the text, its returning "NO_CONTENT_HERE".

Below is the code:

import nest_asyncio
nest_asyncio.apply()
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
from llama_parse import LlamaParse
from langchain.text_splitter import SpacyTextSplitter
import os

class Document:
def init(self, page_content, metadata):
self.page_content = page_content
self.metadata = metadata

os.environ["OPENAI_API_KEY"] = ""
print("hello")
parser = LlamaParse(
api_key = '&
****',# can also be set in your env as LLAMA_CLOUD_API_KEY
result_type="markdown" # "markdown" and "text" are available
)
file_extractor = {".pdf": parser}
documents = SimpleDirectoryReader("./data", file_extractor=file_extractor).load_data()
#documents = parser.load_data("./data/LLP_27oct2008.pdf")
content = ""
for doc in documents:
content = doc.text

content = content.split('---')
print(len(content))
page_no = 1
page_to_content_map = {}
for tex in content:
page_to_content_map[page_no] = tex
page_no +=1

documents = []
for page in page_to_content_map:
metadata = {'page':page-1,'source':'LLP_27oct2008.pdf'}
page_content = page_to_content_map[page]
doc = Document(page_content=page_content, metadata=metadata)
documents.append(doc)

text_splitter = SpacyTextSplitter(chunk_size=500)
docs = text_splitter.split_documents(documents)
print(docs)

The PDF file am parsing has only scanned images.

Originally created by @swathithiyan on GitHub (Apr 8, 2024). 1) I was using llama parse cloud to read the content from the scanned image in pdf. Llama parse was able to decode the text from the scanned image. 2)But starting from today I see that , llama parse not able to decode the text, its returning "NO_CONTENT_HERE". Below is the code: import nest_asyncio nest_asyncio.apply() from llama_index.core import VectorStoreIndex, SimpleDirectoryReader from llama_parse import LlamaParse from langchain.text_splitter import SpacyTextSplitter import os class Document: def __init__(self, page_content, metadata): self.page_content = page_content self.metadata = metadata os.environ["OPENAI_API_KEY"] = "********************" print("hello") parser = LlamaParse( api_key = '&************************',# can also be set in your env as LLAMA_CLOUD_API_KEY result_type="markdown" # "markdown" and "text" are available ) file_extractor = {".pdf": parser} documents = SimpleDirectoryReader("./data", file_extractor=file_extractor).load_data() #documents = parser.load_data("./data/LLP_27oct2008.pdf") content = "" for doc in documents: content = doc.text content = content.split('---') print(len(content)) page_no = 1 page_to_content_map = {} for tex in content: page_to_content_map[page_no] = tex page_no +=1 documents = [] for page in page_to_content_map: metadata = {'page':page-1,'source':'LLP_27oct2008.pdf'} page_content = page_to_content_map[page] doc = Document(page_content=page_content, metadata=metadata) documents.append(doc) text_splitter = SpacyTextSplitter(chunk_size=500) docs = text_splitter.split_documents(documents) print(docs) The PDF file am parsing has only scanned images.
Author
Owner

@0xthierry commented on GitHub (Jun 4, 2024):

I'm facing the same problem 👀

@0xthierry commented on GitHub (Jun 4, 2024): I'm facing the same problem 👀
Author
Owner

@drewdru commented on GitHub (Oct 4, 2024):

Here how I fix it:

documents = LlamaParse(
    result_type="markdown",
    parsing_instructions="The document has images retrieve text from it and describe other content on it"
).load_data(temp_file_path)

It seems that parsing_instructions is required for OCR.

@drewdru commented on GitHub (Oct 4, 2024): Here how I fix it: ```python documents = LlamaParse( result_type="markdown", parsing_instructions="The document has images retrieve text from it and describe other content on it" ).load_data(temp_file_path) ``` It seems that `parsing_instructions` is required for OCR.
Author
Owner

@lefterisloukas commented on GitHub (Mar 9, 2025):

same here

@lefterisloukas commented on GitHub (Mar 9, 2025): same here
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: run-llama/llama_cloud_services#79