Skip to main content

Highlight Text

PDFHighlight 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

Quick reference

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>

Try it live
  1. document — JSON object with Name (capital N), e.g. { "Name": "Thiscar.pdf" }. Leave the field empty (delete all text) if you do not want a document property at all.
  2. docContent — PDF as Base64 (upload a file). Must be non-empty for a real run (same as Postman).
  3. textHighlightingAction — JSON object with TextHighlightList: an array of { "Text": "…", "HighlightColor": "#RRGGBB" }.
Loading API Tester...

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:

  1. Not a real PDF — The action expects a PDF. Do not send Word, images, or empty content. See File is Empty / Invalid File.
  2. document.Name vs file — Use document.Name with the same base filename as the PDF you encoded (including .pdf), e.g. if you upload invoice.pdf, use { "Name": "invoice.pdf" }. A mismatch can contribute to validation failures on some environments.
  3. 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).
  4. 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 use api-dev.pdf4me.com or a proxy—the JSON body should still match.

Overview, parameters, and 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.

Prerequisites

Response format

Typically a highlighted PDF (binary or JSON with docContent).

Get Help