Highlight Text
PDF → Highlight Text
This endpoint matches the Highlight Postman collection: POST /api/v2/HighlightText with body document, docContent, and textHighlightingAction (same keys and nesting as Postman’s raw JSON).
Try the Highlight Text API
Path: POST /api/v2/HighlightText (Postman: https://api.pdf4me.com/api/v2/HighlightText) · Body keys: document, docContent, textHighlightingAction · Headers: Content-Type: application/json, Authorization: Basic <api-key>
- document — JSON object with
Name(capital N), e.g.{ "Name": "Thiscar.pdf" }. Leave the field empty (delete all text) if you do not want adocumentproperty at all. - docContent — PDF as Base64 (upload a file). Must be non-empty for a real run (same as Postman).
- textHighlightingAction — JSON object with
TextHighlightList: an array of{ "Text": "…", "HighlightColor": "#RRGGBB" }.
Same structure as Postman (raw body)
Your exported collection uses exactly these top-level properties:
{
"document": {
"Name": "Thiscar.pdf"
},
"docContent": "<base64 — from Postman or from file upload here>",
"textHighlightingAction": {
"TextHighlightList": [
{ "Text": "Welcome", "HighlightColor": "#FF2C00" },
{ "Text": "promise", "HighlightColor": "#00FF00" }
]
}
}
There is no docName, async, or IsAsync in that collection—only the three keys above plus auth headers.
If you see 400 — "Invalid File"
That response comes from the API when the file bytes are not accepted (not when JSON keys are wrong). Typical causes:
- Not a real PDF — The action expects a PDF. Do not send Word, images, or empty content. See File is Empty / Invalid File.
document.Namevs file — Usedocument.Namewith the same base filename as the PDF you encoded (including.pdf), e.g. if you uploadinvoice.pdf, use{ "Name": "invoice.pdf" }. A mismatch can contribute to validation failures on some environments.- Base64 pasted from elsewhere — Remove line breaks in the Base64 string and do not include a
data:application/pdf;base64,prefix in the field (the tester strips both when sending, but a corrupt or truncated paste still fails). - Upload instead of paste — Use Upload File on docContent so encoding is a single continuous Base64 string.
Other 400 causes
- JSON — No trailing commas; textHighlightingAction must include a non-empty TextHighlightList.
- Environment — Postman may use
api.pdf4me.com; the doc tester may useapi-dev.pdf4me.comor a proxy—the JSON body should still match.
Overview, parameters, and use cases
- Overview
- Parameters
- Use cases
Field → JSON mapping
Each body parameter name is the JSON key: document, docContent, textHighlightingAction, same as Find and Replace style testers.
Postman parity
Import Highlight.postman_collection and compare the raw body with the cURL preview in the tester—they should match after you upload the same PDF.
| Parameter | In JSON |
|---|---|
| document | Object with Name (optional; omit by clearing the field). |
| docContent | Base64 string. |
| textHighlightingAction | { "TextHighlightList": [ … ] }. |
- Multiple colored highlights in one call.
- Reuse the textHighlightingAction block copied from Postman.
Prerequisites
- PDF4me API key (Get your API Key)
- A PDF file
Response format
Typically a highlighted PDF (binary or JSON with docContent).