> ## Documentation Index
> Fetch the complete documentation index at: https://docs.salmanahmad.online/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart Guide: Highlight PDFs with RAG PDF Highlighter

> Learn how to install RAG PDF Highlighter, start the local server, and send your first request to get back a highlighted PDF in under five minutes.

This guide walks you through installing RAG PDF Highlighter, starting the local server, and sending your first request to get back a highlighted PDF — all in under five minutes. You only need a terminal, Python 3.10 or later, and a publicly accessible PDF URL to follow along.

<Steps>
  <Step title="Install the package">
    Install RAG PDF Highlighter from PyPI using `pip`. All runtime dependencies are pulled in automatically.

    ```bash theme={null}
    pip install rag-pdf-highlighter
    ```
  </Step>

  <Step title="Start the server">
    Launch the FastAPI service with Uvicorn. The server will be available at `http://localhost:8000` by default.

    ```bash theme={null}
    uvicorn rag_pdf_highlighter.main:app --host 0.0.0.0 --port 8000
    ```

    You should see Uvicorn report that it is running. You can confirm the service is healthy by visiting `http://localhost:8000/` in your browser or with `curl` — it returns `{"status": "ok the app is running"}`.
  </Step>

  <Step title="Make your first request">
    Send a `POST` request to `/highlight` with a PDF URL and the list of document chunks you want to highlight. Choose your preferred approach:

    <CodeGroup>
      ```bash curl theme={null}
      curl -X POST http://localhost:8000/highlight \
        -H "Content-Type: application/json" \
        -d '{
          "pdf_url": "https://example.com/document.pdf",
          "documents": [
            {
              "page_content": "The quick brown fox jumps over the lazy dog",
              "metadata": {"page": 0}
            }
          ]
        }' \
        --output highlighted.pdf
      ```

      ```python Python theme={null}
      import requests

      response = requests.post(
          "http://localhost:8000/highlight",
          json={
              "pdf_url": "https://example.com/document.pdf",
              "documents": [
                  {
                      "page_content": "The quick brown fox jumps over the lazy dog",
                      "metadata": {"page": 0}
                  }
              ]
          }
      )

      with open("highlighted.pdf", "wb") as f:
          f.write(response.content)
      ```
    </CodeGroup>

    <Tip>
      Page numbers in `metadata.page` are **0-indexed**, so the first page of a PDF is `0`, the second is `1`, and so on. If you omit the `page` key, RAG PDF Highlighter searches the entire document for the chunk.
    </Tip>
  </Step>

  <Step title="Save the highlighted PDF">
    The `/highlight` endpoint returns the annotated PDF as a raw binary response with content-type `application/pdf`. Write the response body directly to a file to save it.

    If you used `curl`, the `--output highlighted.pdf` flag already handled this for you. If you used the Python `requests` example above, the file is written via `response.content`. Open `highlighted.pdf` in any PDF viewer and you will see your text chunk highlighted in yellow on the page you specified.
  </Step>
</Steps>
