Convert a Document Page Image to Markdown

Turns an image of a document page into Markdown, keeps headers and footers, returns tables as HTML, interprets charts and wraps logos, watermarks and page numbers in tags.

  • 🤖 Any vision LLM
  • 🗂️ Data

Last verified: write-up checked

Prompt by Omni AI (getomni-ai/zerox) · Original source (opens in a new tab)

Convert a Document Page Image to Markdown — prompt preview

The prompt

prompt
Convert the following document to markdown.
Return only the markdown with no explanation text. Do not include delimiters like ```markdown or ```html.

RULES:
  - You must include all information on the page. Do not exclude headers, footers, or subtext.
  - Return tables in an HTML format.
  - Charts & infographics must be interpreted to a markdown format. Prefer table format when applicable.
  - Logos should be wrapped in brackets. Ex: <logo>Coca-Cola<logo>
  - Watermarks should be wrapped in brackets. Ex: <watermark>OFFICIAL COPY<watermark>
  - Page numbers should be wrapped in brackets. Ex: <page_number>14<page_number> or <page_number>9/22<page_number>
  - Prefer using ☐ and ☑ for check boxes.

What it is

Turns an image of a document page into Markdown, keeps headers and footers, returns tables as HTML, interprets charts and wraps logos, watermarks and page numbers in tags. The example below is a real output printed in the source. The prompt text comes from the Zerox repository (MIT licence as stated in its LICENSE file, which names no copyright holder). Only the Python quotes and the common indentation were removed. Original author: Omni AI (getomni-ai/zerox).

Who it's for

  • Developers processing PDFs
  • Data teams

يحوّل صورة صفحة من مستند إلى Markdown، ويحتفظ بالترويسات والتذييلات، ويعيد الجداول بصيغة HTML، ويفسر الرسوم البيانية، ويضع الشعارات والعلامات المائية وأرقام الصفحات داخل وسوم.

Examples

Example output in the README

python
python
ZeroxOutput(
    completion_time=9432.975,
    file_name='cs101',
    input_tokens=36877,
    output_tokens=515,
    pages=[
        Page(
            content='| Type    | Description                          | Wrapper Class |\n' +
                    '|---------|--------------------------------------|---------------|\n' +
                    '| byte    | 8-bit signed 2s complement integer   | Byte          |\n' +
                    '| short   | 16-bit signed 2s complement integer  | Short         |\n' +
                    '| int     | 32-bit signed 2s complement integer  | Integer       |\n' +
                    '| long    | 64-bit signed 2s complement integer  | Long          |\n' +
                    '| float   | 32-bit IEEE 754 floating point number| Float         |\n' +
                    '| double  | 64-bit floating point number         | Double        |\n' +
                    '| boolean | may be set to true or false          | Boolean       |\n' +
                    '| char    | 16-bit Unicode (UTF-16) character    | Character     |\n\n' +
                    'Table 26.2.: Primitive types in Java\n\n' +

What it does: Start of the output the README prints from azure/gpt-4o-mini. We cut it here; the README goes on. The README notes it wrapped the output by hand for readability.

Tips

  • This is the default system prompt of the Python package. The Node package uses a slightly different one, stored in shared/systemPrompt.txt.
  • The tool converts each file to images and sends them page by page to the model.
  • The README says a maintain-format option passes the previous page as context, which is slower but helps with tables across pages.