Skip to content

Add structured input endpoint examples - #131

Merged
datalogics-tsmith merged 11 commits into
pdfrest:mainfrom
datalogics-erics:add-structured-input-endpoint-examples
Aug 24, 2026
Merged

datalogics-tsmith merged 11 commits into
pdfrest:mainfrom
datalogics-erics:add-structured-input-endpoint-examples

Conversation

@datalogics-erics

@datalogics-erics datalogics-erics commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Why this change

The Convert to PDF endpoint now supports structured text inputs, but the endpoint examples did not yet make those workflows easy to discover across the primary languages. This change gives developers complete examples for the supported structured formats and shows how to use the same endpoint with either an uploaded file or a previously uploaded resource.

What changed

Added endpoint examples for Markdown, CSV, JSON, XML, and plain text in cURL, Python, JavaScript, PHP, Java, and .NET. Each format has both JSON-resource and multipart examples.

The Markdown examples include page setup, styling, table formatting, tagged output, and image mapping. The JSON-resource variant uploads the Markdown image first and maps it through image_ids; the multipart variant maps an uploaded image through image_files. The .NET dispatcher includes commands for all new examples.

Behavior changes

The JSON-resource examples upload the source file before calling /pdf and pass the resulting resource ID in the JSON payload. Multipart examples send the source file and structured_text_options in one /pdf request. All examples print the API response, including output and input resource IDs where returned.

The examples enable tagging so the generated PDFs demonstrate tagged output. Format-specific options are limited to the formats where they apply: Markdown image mapping, CSV table configuration, JSON/XML hierarchy presentation, and plain-text line preservation.

Validation

All 60 examples were executed against the pdfRest service using the same five representative inputs. Every request succeeded. The 60 returned PDFs passed qpdf --check, and extracted text matched across all six languages and both payload styles for each format. Representative Markdown, CSV, JSON, XML, and plain-text PDFs were rendered and visually inspected.

Static validation passed for Python, JavaScript, cURL, PHP, .NET, and Java. No secrets or machine-specific paths are included.

Risks and follow-ups

There are no API behavior or compatibility changes in this repository; this PR adds examples only. The cURL, Python, JavaScript, and PHP samples follow the established endpoint-example convention of using placeholder API keys and local paths in the source. Java retains the existing default API-key constant with optional dotenv lookup, and .NET retains its repository-standard environment-variable configuration and dispatcher arguments. Users replace the placeholders before running the samples.

- Add JSON and multipart examples for Markdown, CSV, JSON, XML,
  and plain text conversion.
- Demonstrate resource uploads, structured options, Markdown image
  mapping, table styling, and tagged output.

Assisted-by: Codex
- Add JSON and multipart examples for Markdown, CSV, JSON, XML,
  and plain text conversion.
- Demonstrate resource uploads, structured options, Markdown image
  mapping, table styling, and tagged output.

Assisted-by: Codex
- Add JSON and multipart examples for Markdown, CSV, JSON, XML,
  and plain text conversion.
- Demonstrate resource uploads, structured options, Markdown image
  mapping, table styling, and tagged output.

Assisted-by: Codex
- Add JSON and multipart examples for Markdown, CSV, JSON, XML,
  and plain text conversion.
- Demonstrate resource uploads, structured options, Markdown image
  mapping, table styling, and tagged output.

Assisted-by: Codex
- Add JSON and multipart examples for Markdown, CSV, JSON, XML,
  and plain text conversion.
- Demonstrate resource uploads, structured options, Markdown image
  mapping, table styling, and tagged output.

Assisted-by: Codex
- Add JSON and multipart examples for Markdown, CSV, JSON, XML,
  and plain text conversion.
- Demonstrate resource uploads, structured options, Markdown image
  mapping, table styling, tagged output, and dispatcher commands.

Assisted-by: Codex
- Apply the repository Spotless and Google Java Format rules to the
  new JSON and multipart examples.
- Remove unused imports and normalize wrapped declarations so Maven
  verify accepts the added samples in CI.

Assisted-by: Codex
@datalogics-erics
datalogics-erics marked this pull request as ready for review August 24, 2026 20:58
- Use repository-standard API URL, placeholder key, and local path setup.
- Restore regional endpoint comments across the new language samples.
- Keep Java dotenv and .NET configuration patterns consistent with their
  existing folders.

Assisted-by: Codex
@datalogics-erics

Copy link
Copy Markdown
Contributor Author

Addressed in commit 58975ce (Samples: Match established endpoint example conventions).

The new endpoint examples now match the established samples in their respective language folders: cURL, Python, JavaScript, and PHP use the standard API URL and placeholder API key in the request setup, fixed /path/to/... sample paths, and the existing regional endpoint comments. Java retains its existing default-key plus optional dotenv pattern, and .NET remains on its repository-standard environment-variable and dispatcher configuration.

Validation completed locally: all 40 normalized cURL, Python, JavaScript, and PHP samples passed syntax checks; both Java endpoint projects passed Spotless and Maven tests under JDK 17; and the .NET project built successfully with its existing warnings only.

- Use the repository-standard .txt extension in Python and
  JavaScript structured text examples.
- Keep both JSON-resource and multipart plain text examples
  runnable with the documented sample input.

Assisted-by: Codex
@datalogics-erics

Copy link
Copy Markdown
Contributor Author

Addressed in commit 58cd4d0 (Samples: Fix plain text sample file paths).

The Python and JavaScript plain-text examples were using /path/to/sample.text; they now consistently use /path/to/sample.txt in both JSON-resource and multipart variants.

I also ran the complete current 60-example matrix locally against pdfRest: 5 formats × 2 payload styles × 6 languages. All 60 requests succeeded, every returned PDF downloaded successfully, and all 60 PDFs passed qpdf --check. The run covered cURL, Python, JavaScript, PHP, Java, and .NET. No repository samples were modified to insert the test key or local paths.

- Name the Markdown, CSV, JSON, XML, and plain text input format in
  each sample description.
- Keep the JSON-resource and multipart sample comments consistent.

Assisted-by: Codex
- Add axios for JSON-resource requests.
- Add form-data for multipart requests.
- Regenerate the root lockfile so a clean npm install resolves both
  dependencies.

Assisted-by: Codex
@datalogics-erics

Copy link
Copy Markdown
Contributor Author

Addressed in commit 2472361 (DotNET: Clarify structured input sample comments).

The .NET structured-input examples now identify their actual input format in the What this sample does comment: Markdown, CSV, JSON, XML, or plain text. This applies consistently to both JSON-resource and multipart examples.

@datalogics-erics

Copy link
Copy Markdown
Contributor Author

Addressed in commit 668bb3b (JavaScript: Declare endpoint sample dependencies).

The root JavaScript/package.json now declares both axios and form-data, and package-lock.json was regenerated. A clean npm ci now resolves axios, form-data, and node-fetch from the root package. I reran all 10 JavaScript structured-input examples using only that clean root dependency set; all requests succeeded and every PDF passed qpdf --check.

@datalogics-tsmith
datalogics-tsmith merged commit 5807ff3 into pdfrest:main Aug 24, 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