1. PDF to Text
Extract text from PDF with OCR support:
Write to /tmp/request.json:
```json
{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-to-text/sample.pdf",
"inline": true
}
```
```bash
bash -c 'curl --location --request POST "https://api.pdf.co/v1/pdf/convert/to/text" --header "x-api-key: ${PDFCO_API_KEY}" --header "Content-Type: application/json" -d @/tmp/request.json'
```
With specific pages (1-indexed):
Write to /tmp/request.json:
```json
{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-to-text/sample.pdf",
"pages": "1-3",
"inline": true
}
```
```bash
bash -c 'curl --location --request POST "https://api.pdf.co/v1/pdf/convert/to/text" --header "x-api-key: ${PDFCO_API_KEY}" --header "Content-Type: application/json" -d @/tmp/request.json'
```
2. PDF to CSV
Convert PDF tables to CSV:
Write to /tmp/request.json:
```json
{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-to-csv/sample.pdf",
"inline": true
}
```
```bash
bash -c 'curl --location --request POST "https://api.pdf.co/v1/pdf/convert/to/csv" --header "x-api-key: ${PDFCO_API_KEY}" --header "Content-Type: application/json" -d @/tmp/request.json'
```
3. Merge PDFs
Combine multiple PDFs into one:
Write to /tmp/request.json:
```json
{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-merge/sample1.pdf,https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-merge/sample2.pdf",
"name": "merged.pdf"
}
```
```bash
bash -c 'curl --location --request POST "https://api.pdf.co/v1/pdf/merge" --header "x-api-key: ${PDFCO_API_KEY}" --header "Content-Type: application/json" -d @/tmp/request.json'
```
4. Split PDF
Split PDF by page ranges:
Write to /tmp/request.json:
```json
{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-split/sample.pdf",
"pages": "1-2,3-"
}
```
```bash
bash -c 'curl --location --request POST "https://api.pdf.co/v1/pdf/split" --header "x-api-key: ${PDFCO_API_KEY}" --header "Content-Type: application/json" -d @/tmp/request.json'
```
5. Compress PDF
Reduce PDF file size:
Write to /tmp/request.json:
```json
{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-optimize/sample.pdf",
"name": "compressed.pdf"
}
```
```bash
bash -c 'curl --location --request POST "https://api.pdf.co/v1/pdf/optimize" --header "x-api-key: ${PDFCO_API_KEY}" --header "Content-Type: application/json" -d @/tmp/request.json'
```
6. HTML to PDF
Convert HTML or URL to PDF:
Write to /tmp/request.json:
```json
{
"html": "Hello World
This is a test.
",
"name": "output.pdf"
}
```
```bash
bash -c 'curl --location --request POST "https://api.pdf.co/v1/pdf/convert/from/html" --header "x-api-key: ${PDFCO_API_KEY}" --header "Content-Type: application/json" -d @/tmp/request.json'
```
From URL:
Write to /tmp/request.json:
```json
{
"url": "https://example.com",
"name": "webpage.pdf"
}
```
```bash
bash -c 'curl --location --request POST "https://api.pdf.co/v1/pdf/convert/from/url" --header "x-api-key: ${PDFCO_API_KEY}" --header "Content-Type: application/json" -d @/tmp/request.json'
```
7. AI Invoice Parser
Extract structured data from invoices:
Write to /tmp/request.json:
```json
{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/ai-invoice-parser/sample-invoice.pdf",
"inline": true
}
```
```bash
bash -c 'curl --location --request POST "https://api.pdf.co/v1/ai-invoice-parser" --header "x-api-key: ${PDFCO_API_KEY}" --header "Content-Type: application/json" -d @/tmp/request.json'
```
8. Upload Local File
Upload a local file first, then use the returned URL:
Step 1: Get presigned upload URL
```bash
bash -c 'curl -s "https://api.pdf.co/v1/file/upload/get-presigned-url?name=myfile.pdf&contenttype=application/pdf" --header "x-api-key: ${PDFCO_API_KEY}"' | jq -r '.presignedUrl, .url'
```
Copy the presigned URL and file URL from the response.
Step 2: Upload file
Replace with the URL from Step 1:
```bash
curl -X PUT "" --header "Content-Type: application/pdf" --data-binary @/path/to/your/file.pdf
```
Step 3: Use file URL in subsequent API calls
Replace with the file URL from Step 1:
Write to /tmp/request.json:
```json
{
"url": "",
"inline": true
}
```
```bash
bash -c 'curl --location --request POST "https://api.pdf.co/v1/pdf/convert/to/text" --header "x-api-key: ${PDFCO_API_KEY}" --header "Content-Type: application/json" -d @/tmp/request.json'
```
9. Async Mode (Large Files)
For large files, use async mode to avoid timeouts:
Step 1: Start async job
Write to /tmp/request.json:
```json
{
"url": "https://example.com/large-file.pdf",
"async": true
}
```
```bash
bash -c 'curl -s --location --request POST "https://api.pdf.co/v1/pdf/convert/to/text" --header "x-api-key: ${PDFCO_API_KEY}" --header "Content-Type: application/json" -d @/tmp/request.json' | jq -r '.jobId'
```
Copy the job ID from the response.
Step 2: Check job status
Replace with the job ID from Step 1:
Write to /tmp/request.json:
```json
{
"jobid": ""
}
```
```bash
bash -c 'curl --location --request POST "https://api.pdf.co/v1/job/check" --header "x-api-key: ${PDFCO_API_KEY}" --header "Content-Type: application/json" -d @/tmp/request.json'
```
---