视觉画布设计
canvas-design
基于设计原则创作静态视觉作品,用于海报与品牌图形。
docx【文档与办公】Read, create and edit Word DOCX documents, including paragraphs, styles, tables, headers, figures and comments. Use for editable reports and document revisions, with PDF export and visual inspection when layout matters.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Work on explicit paths and retain the source. Discover available Word or
LibreOffice automation before choosing a rendering path. For document structure
use python-docx, for example uv run --with python-docx script.py. This workflow
uses local files and does not require an application account or a hosted API.
Open the file with docx.Document(path). Inspect iter_inner_content() to retain
body paragraph/table order, then inspect sections, headers, footers, styles and
inline images as needed. Table cells can contain multiple paragraphs and nested
tables. Extracting only document.paragraphs omits important content. Revision
marks, text boxes, fields and drawings may require reading the OOXML archive or
using Word/LibreOffice. State missing coverage rather than inventing content.
Set the page size and section margins first. Define a small set of paragraph and
heading styles; use genuine headings and list numbering rather than repeated
manual formatting. Add captions and meaningful column labels. Fit tables and
images within the usable page width. Use page breaks only when needed for the
document structure. Save to a .docx file, then reopen it to verify text and
table values.
Identify the exact paragraph, cell or run before modifying it. Preserve styles,
hyperlinks and surrounding formatting. A word may be split across runs: inspect
the run boundaries before replacing it. Assigning a whole paragraph's .text
recreates its runs and loses their formatting; do that only when this loss is
acceptable. Use targeted XML changes for unsupported structures after inspecting
the actual markup, keeping namespaces and relationships valid. Do not claim
tracked changes when making ordinary text replacements. Use document comments
or an explicit change summary if revision markup is unavailable.
Use an available Word PDF export or LibreOffice conversion. With LibreOffice, use a separate temporary user profile to avoid interfering with an open session:
soffice -env:UserInstallation=file:///ABSOLUTE/TEMP/PROFILE --headless --convert-to pdf --outdir OUTPUT INPUT.docx
Pass each argument separately in a subprocess; construct the profile URI with
Path.resolve().as_uri(). Use a unique output directory and check the process
exit code and resulting PDF. Render that PDF with an available PDF renderer and
inspect every changed page for overflow, orphaned headings, broken tables,
missing glyphs and incorrect page breaks. Repeat after corrections. If no office
renderer is available, do structural checks and clearly label visual review as
not performed. Deliver the editable DOCX and the PDF when requested.
Reference: python-docx documentation.