DEV Community

César Freitas
César Freitas

Posted on

Convert PDFs to clean Markdown for your RAG pipeline (with OCR)

Converting PDFs to clean Markdown for your RAG Pipeline (with OCR)

As a developer, have you ever struggled with working on a project that relies heavily on receipts and invoices? Perhaps you're building an e-commerce platform or an invoice tracking system. In such cases, having access to high-quality receipt data is crucial. However, dealing with PDFs can be a nightmare. Scanned documents are often messy, with text that's difficult to read and recognize.

Document Intelligence API offers a solution to this problem by converting digital or scanned PDFs into clean, LLM/RAG-ready Markdown with built-in OCR (Optical Character Recognition). This means you can extract relevant information from receipts and invoices and use it in your application. The extracted data is available as JSON, making it easy to integrate into your workflow.

How Does Document Intelligence API Work?

The API takes a PDF file as input and uses advanced algorithms to remove noise, correct OCR errors, and format the text for better readability. This results in clean Markdown that's easily usable by Large Language Models (LLMs) and Reasoning Artificial Generalism (RAG). The built-in OCR capabilities allow it to extract information from scanned documents as well.

The API can handle various types of PDFs, including invoices, receipts, contracts, and more. It can also differentiate between different types of text, such as names, addresses, phone numbers, and dates.

What Does the Request/Response Look Like?

When you send a request to the Document Intelligence API with a PDF file attached, it will return a response in JSON format containing the extracted data. The response includes various fields such as invoice number, date, vendor name, amount paid, etc. depending on the type of document being processed.

For example, if you're sending an invoice PDF, the response might include:

{
"invoiceNumber": "INV001",
"date": "2022-01-01T00:00:00Z",
"vendorName": "ABC Inc.",
"amountPaid": 100.0,
// Additional fields might be present depending on the document type
}

This response is clean, readable, and easily usable by LLMs and RAG systems.

Try Document Intelligence API Today

If you're looking for a reliable way to convert PDFs into clean Markdown with built-in OCR capabilities, look no further than the Document Intelligence API. It's available on RapidAPI, a platform that offers free tiers for developers. With its ease of use and robust features, it's an ideal solution for developers working on projects that rely on receipts and invoices.

Take advantage of the Document Intelligence API today and streamline your workflow with high-quality receipt data. Sign up for the RapidAPI free tier to get started with converting PDFs into clean Markdown and unlock the full potential of your RAG pipeline.

Quick example

curl -X POST 'https://document-intelligence3.p.rapidapi.com/v1/pdf-to-markdown' \
  -H 'X-RapidAPI-Key: YOUR_RAPIDAPI_KEY' \
  -H 'X-RapidAPI-Host: document-intelligence3.p.rapidapi.com' \
  -H 'Content-Type: application/json' \
  -d '{"url":"https://example.com/file.pdf"}'
Enter fullscreen mode Exit fullscreen mode

Try it: the Document Intelligence API is live on RapidAPI with a free tier — get your key here.

Top comments (0)