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.
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
The document ID
Query parameters
The search query: a piece of text, a preset name, or a regular expression.
The type of the search: text, preset, or regex.
The index of the page from where you want to start the search.
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.
When true, search inside the document annotations.
Overrides the default search case sensitivity: case insensitive for text search and case sensitive for regex/preset search.
Headers
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.