Skip to content

Commit

Permalink
Add examples for options and posting a local file for conversion
Browse files Browse the repository at this point in the history
Signed-off-by: Brent Salisbury <[email protected]>
  • Loading branch information
nerdalert committed Jan 2, 2025
1 parent b00718b commit 24213e4
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,55 @@ curl -X 'POST' \
}'
```

Example extracting Markdown with a placeholder for images (http source):

```sh
curl -s -X POST "http://localhost:8000/convert/markdown" -H "Content-Type: application/json" -d '{
"options": {
"include_images": false
},
"http_source": {
"url": "https://arxiv.org/pdf/2206.01062"
}
}' > output.md
```

Example posting a file for conversion or explicit Markdown conversion:

When your PDF or other file type is too large, encoding it as a base64 string
and passing it inline to curl can lead to an “Argument list too long” error on
some systems. To avoid this, we write the JSON request body to a file and have
curl read from that file.

```sh
# 1. Base64-encode the file
B64_DATA=$(base64 -w 0 /path/to/file/pdf-to-convert.pdf)

# 2. Build the JSON with your options
cat <<EOF > /tmp/request_body.json
{
"options": {
"output_markdown": true,
"include_images": false
},
"file_source": {
"base64_string": "${B64_DATA}",
"filename": "pdf-to-convert.pdf"
}
}
EOF

# 3. POST the request to the docling service
curl -X POST "http://localhost:8000/convert" \
-H "Content-Type: application/json" \
-d @/tmp/request_body.json

# Or explicitly convert to Markdown
curl -X POST "http://localhost:8000/convert/markdown" \
-H "Content-Type: application/json" \
-d @/tmp/request_body.json
```

### Cuda GPU Support

For GPU support try the following:
Expand Down

0 comments on commit 24213e4

Please sign in to comment.