# convert pdf to text using ocr

make sure you have imagemagick and tesseract are installed

```
$ sudo apt install imagemagick tesseract-ocr
```

It's a 2 step process:

1. Convert PDF to .tiff using `convert` from imagemagick

   ```
   $ convert -density 300 input.pdf -depth 8 output.tiff
   ```
2. convert .tiff to text using `tesseract`

   generate `out.txt`

   ```
   $  tesseract output.tiff out
   ```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://til.yulrizka.com/unix/convert-pdf-to-text-using-ocr.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
