Add invoice generation complex flow sample - #130
datalogics-cgreen merged 22 commits into
Conversation
- Create a blank PDF and compose an invoice through pdfRest endpoints. - Build tagged text, shapes, an auto-paginated table, and an image from JSON, CSV, style, and logo inputs. - Include fictional invoice data that demonstrates multipage output, reserved footer space, and final totals. Assisted-by: Codex
- Split the seller and customer panels into aligned boxes. - Move the table closer to the header to reduce unused page space. - Keep text padding and table margins aligned with the document edges. Assisted-by: Codex
- Align the table position field with the surrounding profile properties. - Keep the sample source consistently formatted after the layout update. Assisted-by: Codex
- Keep seller details in the From box instead of repeating them above it. - Increase and reposition the billing boxes to clear the invoice metadata. - Add realistic service rows so the continuation page has useful content. Assisted-by: Codex
- Move the From and Bill To panels lower on the first page. - Keep the spacing even between invoice metadata, panels, and the table. - Move the panel text with its containing shapes to preserve padding. Assisted-by: Codex
- Reserve more bottom space for the table on ordinary pages. - Raise running footers into the reserved content area. - Keep the final-page footer below the payment panel. Assisted-by: Codex
- Use the same footer baseline on every invoice page. - Position the final payment panel above the shared footer. - Keep both payment sections inside the panel boundary. Assisted-by: Codex
- Raise payment terms and notes text within the final panel. - Preserve balanced padding above the shared footer. - Keep both content sections clear of the panel borders. Assisted-by: Codex
- Document the API key environment variable and bundled inputs. - Include dependency installation and the command to run the sample. - Help new users understand the generated output location. Assisted-by: Codex
- Build a tagged invoice from bundled JSON and CSV inputs. - Compose the document with blank PDF, shapes, text, table, image, page-info, and resource endpoints. - Include fictional metadata, styling, line items, and logo assets. Assisted-by: Codex
- Build a tagged invoice from bundled JSON and CSV inputs. - Compose the document with blank PDF, shapes, text, table, image, page-info, and resource endpoints. - Declare the multipart form dependency used by the workflow. Assisted-by: Codex
- Build a tagged invoice from bundled JSON and CSV inputs. - Compose the document with blank PDF, shapes, text, table, image, page-info, and resource endpoints. - Include setup guidance for the Guzzle dependency and API key. Assisted-by: Codex
- Add a routed complex-flow sample for tagged invoice generation. - Build the document from bundled JSON and CSV inputs using pdfRest blank PDF, shapes, text, table, image, page-info, and resource calls. - Document the command-line entry point and API key configuration. Assisted-by: Codex
- Build a tagged invoice from bundled JSON and CSV inputs. - Compose the document with blank PDF, shapes, text, table, image, page-info, and resource endpoints. - Use curl and jq to keep the workflow transparent and easy to adapt. Assisted-by: Codex
…ling Disable cookie management for the invoice workflow because the pdfRest requests do not use cookies and some local runtimes cannot initialize their cookie container correctly. Assisted-by: Codex
…gs correctly Send the single image insertion profile as an object, matching the pdfRest endpoint contract used by the other language samples. Assisted-by: Codex
- Use the deployed resource-ID image workflow in every language sample. - Upload the bundled logo once, then reference it with image_id. - Keep the invoice workflow compatible with the current public API while retaining the new shapes, tables, tagging, and pagination coverage. Assisted-by: Codex
Run the repository Spotless formatter on the new invoice workflow so the Java verification job passes with the project formatting rules. Assisted-by: Codex
- Build table header cells with a valid jq filter. - Generate footer entries for each page without iterating a number. This keeps the cURL workflow aligned with the other language samples and allows the complete invoice flow to run successfully. Assisted-by: Codex
- Supply the delimiter, enclosure, and escape parameters to fgetcsv. - Avoid PHP 8.5 deprecation warnings while reading invoice line items. The sample continues to parse the same CSV format without runtime warnings on current PHP versions. Assisted-by: Codex
- Add thousands separators to generated currency amounts. - Keep currency values consistently formatted with two decimal places. This makes the cURL output match the presentation of the other language samples. Assisted-by: Codex
datalogics-cgreen
left a comment
There was a problem hiding this comment.
Thanks for putting these together. I think the overall structure is solid, but I am requesting changes for a few sample-quality issues before this lands.
-
In the new .NET sample, the missing
PDFREST_API_KEYbranch prints an error and returns normally. That makesdotnet run -- create-invoice-from-structured-dataexit0even though the sample did not run. The other .NET complex-flow samples callEnvironment.Exit(1); return;for the same precondition, so this one should match that behavior. -
Please add a short inline comment near each
invoice-datadirectory constant/path explaining that these samples are intentionally self-contained and read bundled JSON, CSV, and logo fixture files. That should make the new sample shape clear without needing to document it as an exception in every README. -
Please add a few more inline comments describing the major API choreography, especially in the .NET and PHP samples. These are sample programs, and this workflow has enough steps that readers would benefit from signposts for: loading structured inputs, creating the blank PDF, adding header shapes/text, adding the auto-paginated table, uploading/reusing the logo resource ID, querying page count, adding final-page/footer content, and downloading the final PDF.
The runtime issue is small, but the readability points matter here because these files are teaching examples as much as runnable code.
- Exit the .NET sample with status 1 when the API key is missing. - Explain that each language keeps its input fixtures beside the sample. - Add API workflow signposts to the .NET and PHP implementations. These changes make the samples easier to follow and ensure a missing required credential is reported as a failed run. Assisted-by: Codex
|
Thanks for the review. Addressed all three points in commit
Validation completed:
|
There was a problem hiding this comment.
Rechecked the updates in 1701e79. The requested changes are addressed: the .NET missing-key path now exits non-zero, the fixture-path comments are present across the language samples, and the .NET/PHP samples now have useful workflow signposts for the major API steps.
Validation I reran locally:
dotnet buildpasses, with existing nullability warnings elsewhere in the project.env -u PDFREST_API_KEY dotnet run --no-build -- create-invoice-from-structured-datanow reportsexit=1after rebuilding.- Python compile, JavaScript syntax check, cURL shell syntax check, and Java Spotless check pass.
I could not rerun PHP lint locally because this machine does not have the updated PHP comments/readability changes look correct on review.php installed, but
EDIT: I fixed my local issue with php and manually ran the sample code to confirm that the expected output was received.
Summary
Add a Complex Flow Example that generates a realistic invoice from structured application data through the public pdfRest API.
The sample reads fictional invoice metadata and styling from JSON, line items from CSV, and a local logo image. It creates a blank Letter PDF and composes the invoice with these endpoints:
The table is built from every CSV row and uses automatic pagination, repeated headers, reserved page regions, totals, and optional tagging. The workflow also adds payment terms, notes, and page numbering after determining the generated page count. The logo is uploaded once and then referenced by its returned resource ID.
Included inputs
metadata.json: Fictional seller, customer, invoice, tax, payment, and note data.style.json: Fonts, colors, table text size, and border settings.line-items.csv: Variable invoice line items used to build the table.northstar-logo.png: Fictional local logo image used in the invoice header.Validation
Each language implementation was run against
https://api.pdfrest.comwith the same fictional JSON, CSV, and logo inputs:Each workflow completed all nine API operations successfully with HTTP 200 responses, including the image upload operation. Every generated output was verified as a tagged, two-page Letter PDF.
qpdf --checkreported no syntax or stream encoding errors for any output. The PHP run also completed without the PHP 8.5 CSV deprecation warning.