pdf actions new version#306
Open
AlanAAG wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors PDF styling so create_pdf can derive colours/typography/margins from agent_file_system/FORMAT.md (with CraftBot defaults as fallback), and improves edit_pdf’s fill_field (AcroForm) error isolation and warning attribution. It also removes the previously hardcoded multi-theme system from create_pdf and updates action descriptions to reduce model confusion.
Changes:
- Add
app/utils/pdf_format.pyto parseFORMAT.md(## global+## pdf) into a resolved style dict and map it tocreate_pdf’s theme/render inputs. - Update
create_pdfto remove thethemeinput and instead resolve margins/header sizing/typography fromFORMAT.mdat render time;theme_usednow consistently returns"format_md". - Update
edit_pdfcopy and refactorfill_fieldpost-processing to validate upfront and isolate failures per operation and per stage (open/apply/write).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| app/utils/pdf_format.py | New FORMAT.md parser + theme mapper used by PDF actions. |
| app/data/action/create_pdf.py | Removes _THEMES/theme input; resolves styling from FORMAT.md; adjusts schema/simulated output. |
| app/data/action/edit_pdf.py | Updates action description and improves fill_field error handling/warnings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| pdf.set_font("Helvetica", "B", 20) | ||
| pdf.set_font("Helvetica", "B", _fmt["h1_pt"]) | ||
| pdf.set_text_color(*t["htxt"]) | ||
| title_y = y0 + (HH - 20) / 2 - (5 if subtitle else 0) |
Comment on lines
+17
to
+19
| "When editing a PDF created by create_pdf, the accent colour is always #FF4F18 " | ||
| "(FORMAT.md highlight). Use this for stamps, watermarks, and annotations " | ||
| "to match the document style. " |
Comment on lines
268
to
274
| pdf.rect(lm, y0, pw, HH, style="F") | ||
|
|
||
| if doc_title: | ||
| pdf.set_font("Helvetica", "B", 20) | ||
| pdf.set_font("Helvetica", "B", _fmt["h1_pt"]) | ||
| pdf.set_text_color(*t["htxt"]) | ||
| title_y = y0 + (HH - 20) / 2 - (5 if subtitle else 0) | ||
| pdf.set_xy(lm + 8, title_y) |
ahmad-ajmal
reviewed
Jun 4, 2026
ahmad-ajmal
requested changes
Jun 4, 2026
Collaborator
ahmad-ajmal
left a comment
There was a problem hiding this comment.
Just one small fix, please make sure to run ruff lint checks as well.
Collaborator
Author
|
ruff check . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two outstanding issues from V1.3.2 and closes #296.
Changes
New:
app/utils/pdf_format.pyFORMAT.md → PDF style resolver shared by
create_pdfandedit_pdf. Parses the## global(colours, typography) and## pdf(margins, header height) sections and maps them onto the fpdf2 render pipeline. Falls back to hardcoded CraftBot-brand defaults (#141517base,#FF4F18highlight,#6B6E76muted) if FORMAT.md is missing or malformed.Placed in
app/utils/rather thanapp/data/action/because the action loader scans all non-dunder.pyfiles in the action directory — placing a shared utility there causes a module name collision and import failure at runtime.app/data/action/create_pdf.py_THEMESdict andthemeinput parameterapp.utils.pdf_formatheader_height_infrom FORMAT.md, floored at 30mm so title text always fitstheme_usedalways returns"format_md"(including in simulated mode)app/data/action/edit_pdf.pydefault=#4f46e5etc.) with the single FORMAT.md accent colour#FF4F18— the old themes were removed and the hints were actively misleading the modelfill_fielderror handling:field_namevalidation in the main loop so missing fields are caught immediatelyacroform_opsnow stores(original_index, op)tuples so each warning references the correctop[N]tagapp/utils/__init__.pyNo changes —
pdf_formatis imported directly in the actions and does not need to be re-exported here. The existing I/O-free contract of this module is preserved.Acceptance criteria (issue #296)
create_pdfandedit_pdfproduce PDFs whose colours, fonts, headings, margins, and footer match FORMAT.md's## global/## pdfsections_THEMESdict removedtest_payload/ simulated mode still passesOut of scope (not touched)
read_pdf.py— no changesdocx,pptx,xlsx)