Skip to main content

Parsing options

Set language

LlamaParse uses OCR to extract text from images. Our OCR supports a long list of languages. You can specify one or more languages by separating them with a comma. This only affects text extracted from images.

parser = LlamaParse(
language="fr"
)


Disable OCR

By default, LlamaParse runs OCR on images embedded in the document. You can disable it with disable_ocr=True.

parser = LlamaParse(
disable_ocr=True
)


Skip diagonal text

By default, LlamaParse will attempt to parse text that is diagonal on the page. This can be useful for some documents, but also introduce noise and errors. To avoid parsing diagonal text, set skip_diagonal_text=True.

parser = LlamaParse(
skip_diagonal_text=True
)


Do not unroll columns

By default, LlamaParse tries to unroll columns into reading order. Set do_not_unroll_columns=True to prevent LlamaParse from doing so.

parser = LlamaParse(
do_not_unroll_columns=True
)


Target pages

By default, all pages will be extracted. To parse specific pages only, use a comma-separated string. Page numbering starts at 0.

parser = LlamaParse(
target_pages="0,2,7"
)


Page separator

By default, LlamaParse will separate pages in the markdown and text output by \n---\n. You can change this separator by setting page_separator to the desired string.

It's also possible to include the page number within the separator using {pageNumber} in the string. It will be replaced by the page number of the next page.

parser = LlamaParse(
page_separator="\n=================\n",
# page_separator="\n== {pageNumber} ==\n" # Will transform to "\n== 4 ==\n" to separate page 3 and 4.
)


Page prefix and suffix

It's possible to specify a prefix or a suffix to be added to each page. These strings can contain {pageNumber} as well and will be replaced by the current page number. Both parameters are optional and empty by default.

parser = LlamaParse(
page_prefix="START OF PAGE: {pageNumber}\n"
page_suffix="\nEND OF PAGE: {pageNumber}"
)


Bounding box

Specify an area of a document that you want to parse. This can be helpful to remove headers and footers. To do so you need to provide the bounding box margin in clockwise order from the top in a comma-separated. The margins are expressed as a fraction of the page size, a number between 0 and 1.

Examples:

  • To exclude the top 10% of a document: bounding_box="0.1,0,0,0"
  • To exclude the top 10% and bottom 20% of a document: bounding_box="0.1,0,0.2,0"
parser = LlamaParse(
bounding_box="0.1,0,0.2,0"
)


Take screenshot

Take a screenshot of each page and add it to JSON output in the following format:

{
"images": [
{
"name": "page_1.jpg",
"height": 792,
"width": 612,
"x": 0,
"y": 0,
"type": "full_page_screenshot"
}
]
}
parser = LlamaParse(
take_screenshot=True
)


Disable image extraction

It is possible to disable the extraction of image for better performance using disable_image_extraction=true

parser = LlamaParse(
disable_image_extraction=True
)


Extract multiple table per sheet in spreadsheet

By default LlamaParse extract each sheet of a spreadsheet as one table. Using spreadsheet_extract_sub_tables=true, LlamaParse will try to identify spreadsheet sheet with multiple table and return them as separated tables.

parser = LlamaParse(
spreadsheet_extract_sub_tables=True
)


Output table as HTML in markdown

A common issue with markdown table is that they do not handle merged cells well. It is possible to ask LlamaParse to return table as html with colspan and rowspan to get a better representation of the table. When output_tables_as_HTML=true, tables present in the markdown will be output as HTML tables.

parser = LlamaParse(
output_tables_as_HTML=True
)


Preserve alignment across pages

If set to preserve_layout_alignment_across_pages=True will try to keep the text align in text mode accross pages. Useful for document with continuous table / alignment accross pages.

parser = LlamaParse(
preserve_layout_alignment_across_pages=True
)