Documents

Search for Text

Use this endpoint to search in a whole document or a continuous range of pages.

This API offers three different types of search, controlled via type query parameter:

  • text (default) - simple, text search. By default, the search query is case insensitive, but you can change this by setting case_sensitive to true.
  • preset - search using one of the predefined patterns. For the full list of presets, see the request parameters schema.
  • regex - search using a regular expression. The regular expressions needs to comply with the ICU regex standard. By default, the regular expression is case sensitive, but you can change that by setting the case_sensitive parameter to false.

When using text search, the search query needs to be at least three characters long.

By default, search results do not include annotations. If you want to search inside annotations in the document, you can include a include_annotations parameter set to true.

get/api/documents/{documentId}/search

Request

  • Base URL: http://localhost:5000
  • URL: http://localhost:5000/api/documents/{documentId}/search
  • Auth: one of:
    • API key in header Authorization
    • HTTP bearer

Path parameters

documentIdstring required

The document ID

Query parameters

string required
OR
string required
OR
'credit-card-number' | 'date' | 'email-address' | 'international-phone-number' | 'ipv4' | 'ipv6' | 'mac-address' | 'north-american-phone-number' | 'social-security-number' | 'time' | 'url' | 'us-zip-code' | 'vin' required
  • credit-card-number — matches a number with 13 to 19 digits that begins with 1—6. Spaces and - are allowed anywhere in the number.
  • date — matches date formats such as mm/dd/yyyy, mm/dd/yy, dd/mm/yyyy, and dd/mm/yy. It rejects any days greater than 31 or months greater than 12 and accepts a leading 0 in front of a single-digit day or month. The delimiter can be -, ., or /.
  • email-address — matches an email address. Expects the format of *@*.* with at least two levels of the domain name.
  • international-phone-number — matches international phone numbers. The number can have 7 to 15 digits with spaces or - occurring anywhere within the number, and it must have prefix of + or 00.
  • ipv4 — matches an IPv4 address with an optional mask at the end.
  • ipv6 — matches a full and compressed IPv6 address as defined in RFC 2373.
  • mac-address — matches a MAC address with either - or : as a delimiter.
  • north-american-phone-number — matches North American-style phone numbers. NANPA standardization is used with international support.
  • social-security-number — matches a social security number. Expects the format of XXX-XX-XXXX or XXXXXXXXX, with X denoting digits.
  • time — matches time formats such as 00:00:00, 00:00, and 00:00 PM. 12- and 24-hour formats are allowed. Seconds and AM/PM denotation are both optional.
  • url — matches a URL with a prefix of http or https, with an optional subdomain.
  • us-zip-code — matches a USA-style zip code. The format expected is XXXXX, XXXXX-XXXX or XXXXX/XXXX.
  • vin — matches US and ISO Standard 3779 Vehicle Identification Number. The format expects 17 characters, with the last 5 characters being numeric. I, i, O, o ,Q, q, and _ characters are not allowed.
Example:support@nutrient.io

The search query: a piece of text, a preset name, or a regular expression.

type'text' | 'regex' | 'preset'

The type of the search: text, preset, or regex.

startinteger

The index of the page from where you want to start the search.

limitinteger

The maximum number of pages to search, starting from start. For example, start=3&limit=2 searches pages 3 and 4. The default is to search to the end of the document.

include_annotationsboolean

When true, search inside the document annotations.

case_sensitiveboolean

Overrides the default search case sensitivity: case insensitive for text search and case sensitive for regex/preset search.

Headers

pspdfkit-pdf-passwordstring

The PDF document password.

The value can be either a plain-text password or a base64 encoded password in a form base64:<encoded-password>. Use the Base64 encoding if your password contains characters that are not allowed in HTTP header or would be otherwise mangled (e.g. trailing or leading spaces)

If the document is password protected, any operations performed on it require supplying a password.

Response

Document Engine returned the search results.

Example response

{
  "data": [
    {
      "previewText": "PSPDFKit supports almost all PDF annotation types",
      "rangeInPreview": [
        2,
        3
      ],
      "rectsOnPage": [
        [
          82.1448974609375,
          61.14007568359375,
          34.11000061035156,
          18
        ]
      ]
    }
  ]
}

Changes

No recorded changes to this operation across all 1 revision of this API.