Skip to content

Add search, highlight, redaction, and text replacement samples - #136

Merged
datalogics-dliang merged 13 commits into
pdfrest:mainfrom
datalogics-erics:add-search-and-modify-samples
Nov 20, 2026
Merged

datalogics-dliang merged 13 commits into
pdfrest:mainfrom
datalogics-erics:add-search-and-modify-samples

Conversation

@datalogics-erics

@datalogics-erics datalogics-erics commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Why this change

Developers need working examples for finding PDF text and using the results to highlight, redact, or replace selected content. These samples show both direct processing and search-first workflows in each of the repository's six primary languages.

What changed

Adds 120 examples in C#, Java, JavaScript, PHP, Python, and cURL. Every scenario has both a multipart example and a JSON example that uploads the PDF first and passes its resource ID:

Scenario What the example demonstrates
Search PDF Find literal text, regex matches, and email addresses; print the JSON results.
AI Search PDF Find people with a preset and medication names with a custom description; print the JSON results, including confidence.
Highlight PDF Find and highlight text in one processing request.
Replace PDF Text Apply multiple find-and-replace rules in one processing request.
Search → Highlight Pass retained search matches as selections to Highlight PDF.
Search → Redact Pass retained matches to Redact PDF preview, then apply the redactions.
Search → Replace Add replacement text to each retained match and submit the selections to Replace PDF Text.
AI Search → Highlight Find confidentiality obligations by meaning, even without the word “confidential,” then highlight retained findings.
AI Search → Redact Discover potential PII, including names and addresses not supplied in advance, then preview and apply retained redactions.
AI Search → Replace Discover people's names without a supplied list, then replace retained names with Person.

The examples use the existing language dependencies, payload directories, and configuration conventions. The .NET dispatcher exposes the new commands. A short guide links the examples and explains how the workflows fit together.

Behavior changes

These are opt-in samples only; API behavior and existing direct-redaction examples are unchanged. Search-first examples identify where a program can remove unwanted matches and reuse the same unchanged PDF for processing. Replacement comments explain that each retained match can have its own replacement text and layout mode.

AI Search is identified as Cloud-only. Its workflows use a custom description or AI category rather than known literal strings or regex patterns. Name replacement explicitly uses shrink_to_fit to preserve surrounding text positions when several names share a paragraph. More advanced combinations are outside this sample set.

Validation

All 120 examples ran successfully against a Cloud test deployment, covering both payload styles in all six languages. Another 30 no-match workflow checks passed. Output checks confirmed expected matches and AI confidence fields, replacement text, permanently removed redacted text, and unchanged text in highlighted PDFs.

All 120 generated PDF outputs, including redaction previews, passed qpdf checks and reopened with PDFL. Representative input/output pages were rendered and visually inspected. Shell syntax, JavaScript syntax, PHP lint, Python execution, all three Java Maven verification builds, and the .NET 8 build passed. The .NET project retains existing warnings outside these samples.

Risks and follow-ups

Samples use placeholder keys and input paths that developers replace before running. Redaction workflows demonstrate immediate preview-to-apply processing and explicitly recommend inspecting previews before applying redactions in a review workflow. The guide notes that masked Starter search text cannot validate for replacement.

No packages, API contracts, or existing samples are changed.

Eric Shore and others added 11 commits November 16, 2026 09:43
- Demonstrate direct search, AI search, highlighting, and replacement
  with JSON resource IDs and multipart uploads.
- Pass retained search matches to highlight, redact preview/apply,
  and replacement calls using the same unchanged PDF.
- Explain per-match replacement and stop cleanly when no matches exist.

Assisted-by: Codex
- Use Axios and FormData for direct JSON and multipart requests.
- Show search results passed to highlight, redact preview/apply,
  and replacement without changing the source PDF between calls.
- Demonstrate per-match replacement and clean no-match handling.

Assisted-by: Codex
- Use Guzzle for direct JSON resource-ID and multipart requests.
- Pass retained search results to highlighting, redaction preview/apply,
  and per-match replacement using the unchanged source PDF.
- Print processing responses and stop on HTTP errors or empty results.

Assisted-by: Codex
- Demonstrate direct JSON resource-ID and multipart requests.
- Use jq to retain search selections and add replacement text before
  passing them to highlight, redact preview/apply, or replace.
- Stop on failed requests and leave the PDF unchanged on no matches.

Assisted-by: Codex
- Add direct search, AI search, highlight, and replacement examples
  for JSON resource IDs and multipart uploads.
- Demonstrate retained search selections passed to highlighting,
  redaction preview/apply, and per-match replacement.
- Register all examples in the dispatcher and command help.

Assisted-by: Codex
- Use OkHttp and org.json for direct JSON and multipart requests.
- Demonstrate search selections reused by highlighting, redaction
  preview/apply, and per-match replacement.
- Preserve existing dotenv and regional API configuration conventions.

Assisted-by: Codex
- Index the six-language JSON and multipart examples and .NET commands.
- Explain optional match filtering, required replacement text, unchanged
  source PDFs, and redaction preview/apply behavior.
- Clarify Cloud-only AI search and Starter replacement considerations.

Assisted-by: Codex
- Find confidentiality obligations with a custom AI search description,
  without requiring known clause wording or regex patterns.
- Pass reviewed selections to highlighting in six languages with JSON
  resource-ID and multipart request examples.
- Explain confidence review, optional filtering, and unchanged inputs.

Assisted-by: Codex
- Discover potentially identifying content without supplying known
  names, addresses, or regex patterns.
- Pass retained AI findings to redaction preview and apply in six
  languages with JSON resource-ID and multipart requests.
- Explain reviewing AI findings and previews before permanent removal.

Assisted-by: Codex
- Find people's names with the AI category instead of a supplied list
  of names or deterministic matching rules.
- Add Person and explicit shrink_to_fit settings to retained matches
  before replacement, preserving surrounding text positions.
- Cover six languages with JSON resource-ID and multipart requests.

Assisted-by: Codex
- Register JSON and multipart AI workflow commands in .NET.
- Explain how meaning-based discovery differs from literal, regex,
  and pattern-preset searches in the sample guide.
- Distinguish discovered-name replacement from deterministic examples
  and document the explicit layout choice.

Assisted-by: Codex
@datalogics-erics
datalogics-erics marked this pull request as ready for review November 16, 2026 18:29
- Remove unsupported EU switch comments from AI endpoint and workflow
  samples across all six languages.
- Clarify .NET URL configuration and US Cloud availability in the
  workflow guide without changing executable requests.

Assisted-by: Codex
@datalogics-erics

Copy link
Copy Markdown
Contributor Author

Corrected AI Search regional guidance in 6bc193d. All 48 AI endpoint/workflow samples now identify the US Cloud service and no longer suggest switching to EU. The guide also clarifies the .NET URL setting. Only comments and documentation changed; executable requests are unchanged.

Validation passed: comment-only diff checks, unchanged Python ASTs, JavaScript/PHP/shell syntax checks, all three Java Maven verification builds, and the .NET build (zero errors; existing warnings remain).

@datalogics-dliang datalogics-dliang self-assigned this Nov 18, 2026
@datalogics-dliang
datalogics-dliang self-requested a review November 18, 2026 15:33

@datalogics-dliang datalogics-dliang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new samples are consistent with the repository's JSON and multipart layout and are easy to follow across languages. The guide explains the search-first workflows, AI availability, and redaction preview/apply behavior clearly. Given the reported successful runs, I have no execution concerns from this conventions review.

Comment thread search-and-modify-examples.md Resolved
- List curl and jq setup checks in the cURL README.
- Link the search and modify guide to the prerequisite instructions.

Assisted-by: Codex
@datalogics-dliang
datalogics-dliang merged commit 6393bee into pdfrest:main Nov 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants