Skip to content
Back to skills

Lab Report Docx

ASecurity

Use this skill whenever the user wants to inspect, fill, sanitize, audit, or render a university/engineering lab report `.docx` template into a WPS-compatible `.docx` and high-fidelity `.pdf` without rebuilding the document from scratch.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 2, 2026
ai-agentsrustbashrails

Works with

  • cli
  • mcp

Security analysis

A100/100

Scanned December 2, 2026

npx -y skills add eljcf/docx-lab-plugin --skill lab-report-docx --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Lab Report Docx?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Lab Report Docx
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/eljcf-lab-report-docx/badge)](https://www.skillsdirectory.com/skills/eljcf-lab-report-docx)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: lab-report-docx
description: >-
  Use this skill whenever the user wants to inspect, fill, sanitize, audit, or
  render a university/engineering lab report `.docx` template into a
  WPS-compatible `.docx` and high-fidelity `.pdf` without rebuilding the
  document from scratch.
---

# Lab Report DOCX & PDF Workflow

Always patch an existing `.docx` lab report template **in-place** using
`docx-lab-plugin` instead of regenerating the report from scratch or plain
intermediate markup. In-place OOXML patching preserves institutional
headers, footers, page numbers, different-first-page layouts, cover underlines,
table borders, cell margins, and teacher signature blocks.

You may execute this workflow via the bundled **MCP tools** (preferred when the
`docx-lab-plugin` MCP server is connected) or via the **CLI** (`uv run docx-lab`).

## 4-Step Procedure

### Step 1: Inspect Template Slots

Scan the `.docx` template first to discover exact cover field labels, table
section headings, red instructional prompts, cell widths, and WPS layout risks.

- **MCP:** `inspect_docx_template(docx_path="path/to/template.docx")`
- **CLI:** `uv run docx-lab inspect path/to/template.docx --out slots.json`

Review the returned JSON (`cover_fields`, `table_slots`, `diagnostics`):
- Note exact label names on the cover (including multi-slot lines like
  `报告人` / `学号` / `班级`).
- Note exact section headings inside tables (e.g., `实验步骤与结果`, `实验结论`,
  `指导教师批阅意见`, `备注`) and which cells contain red instructional hints.
- Note any WPS diagnostics (`missing tblLayout="fixed"`, `hRule="exact"`,
  missing hard page break before the first table, missing `w:ulTrailSpace`).

### Step 2: Generate Structured Payload JSON

Build a structured JSON object matching the template's exact field labels and
section headings:

```json
{
  "cover_fields": {
    "专业": "计算机科学与技术",
    "报告人": "张三",
    "学号": "20230001",
    "班级": "计科2301",
    "实验时间": "2026年5月10日",
    "实验报告提交时间": "2026年5月12日"
  },
  "sections": {
    "实验步骤与结果": [
      { "type": "subheading", "text": "1. 实验环境与网络拓扑配置" },
      { "type": "paragraph", "text": "在实验主机上配置静态地址并启用防火墙服务,确认端口监听正常。" },
      { "type": "code", "text": "sudo ufw enable\nsudo ufw deny 21/tcp\nsudo ufw status numbered" },
      {
        "type": "image",
        "path": "path/to/screenshot_1.png",
        "caption": "图 1 防火墙规则拦截 FTP 端口验证结果",
        "max_width_ratio": 0.92
      }
    ],
    "实验结论": [
      { "type": "paragraph", "text": "通过本次实验验证了状态检测防火墙在应用层与网络层访问控制中的有效性。" }
    ]
  },
  "keep_together_headings": ["指导教师批阅意见", "备注"]
}
```

Payload guidelines:
- Supported block `type` values inside `sections`: `subheading`, `paragraph`,
  `code`, `image`.
- For `image` blocks, always provide a valid local PNG or JPEG `path`, a concise
  `caption`, and `max_width_ratio` (default `0.92`, never exceeding `1.0`).
- Include compact tail/signature rows (such as `指导教师批阅意见`, `备注`) in
  `keep_together_headings` so they stay intact on one page (`w:cantSplit`).

### Step 3: Fill In-Place, Sanitize for WPS, and Audit

Patch the template in-place with WPS sanitization enabled (`sanitize_wps=True`),
then verify all 12 automated OOXML & WPS compatibility checks pass.

- **MCP:**
  1. `fill_docx_report(template_path="template.docx", payload_json=..., output_path="report_filled.docx", sanitize_wps=True)`
  2. `audit_docx_wps(docx_path="report_filled.docx")` (also included in `fill_docx_report`'s output)
- **CLI:**
  ```bash
  uv run docx-lab fill template.docx payload.json -o report_filled.docx --audit
  uv run docx-lab audit report_filled.docx --strict
  ```

Validation gate:
- Confirm `audit["passed"] == true` (`12/12` checks passed, `issues == []`).
- If any check fails (e.g., residual red prompt text because a section heading
  was misspelled in `payload_json`), fix the payload heading/field name and
  re-run Step 3 before moving to Step 4.

### Step 4: Convert to PDF via `dxpdf` and Visually Inspect Pages

Render the audited `.docx` to PDF using the Word-free Rust+Skia `dxpdf` engine
(with automatic LibreOffice fallback) and export PNG page previews so you can
visually verify the final layout.

- **MCP:**
  `convert_docx_to_pdf(docx_path="report_filled.docx", pdf_path="report_filled.pdf", engine="auto", preview_dir="preview_pages", dpi=150)`
- **CLI:**
  ```bash
  uv run --extra preview docx-lab pdf report_filled.docx -o report_filled.pdf --engine auto --preview-dir preview_pages --dpi 150
  ```

Open each rendered PNG in `preview_pages/` with your file-reading/vision tool
and inspect for:
1. **Cover isolation**: Page 1 holds only the cover; the main table starts
   cleanly on Page 2.
2. **Cover underlines**: Multi-slot lines (`报告人 / 学号 / 班级`) keep clean
   individual underlines without collapsing or trailing-space loss.
3. **Borders & margins**: Outer thick / inner thin table borders, headers, and
   page numbers remain intact.
4. **No clipping or overlap**: Code blocks have clean padding inside shaded
   borders, images fit inside cell margins with centered captions glued beneath
   them, and no text is clipped by exact row heights.
5. **No orphan headings or split signature blocks**: Section headings stay with
   their first content block, and `指导教师批阅意见` / `备注` stay intact.

## Guardrails

- Never overwrite the user's original template `.docx`; always write to a new
  `output_path`.
- Avoid regenerating an existing institutional `.docx` template from plain
  markup or blank document builders when strict layout fidelity is required.
- Always run with `sanitize_wps=True` unless the user explicitly asks for raw
  unsanitized output.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.