Use this case when the user supplies a long listed-company annual report PDF (100–300+ pages) and asks for a Chinese financial summary/report with accurate key tables, segment revenue, charts, and a professional broker-research / academic feel. This case is especially relevant when the user later rejects decorative layouts and wants a compact, dense, data-table-first LaTeX PDF.
Editable artifacts:
../templates/data-viz-report/cases/annual-report-financial-digest-latex/source.tex — compact LaTeX source template; do not store generated PDFs.../templates/data-viz-report/cases/annual-report-financial-digest-latex/build_charts.py — chart/data scaffold from the PetroChina run; adapt data and paths before use.Representative prompt:
Process the attached 200+ page annual report PDF. Extract the “主要财务指标” table, extract segment revenue for the main business lines, generate charts (multi-year financial trend, business revenue donut, financial-health radar), and output a polished Chinese PDF summary ≤10 pages with cover/TOC/charts and unified style.
Acceptance criteria from this run:
2,937,981 RMB mn ≈ 2.94万亿元, accepted vs “约3.03万亿元”).油气和新能源.炼油化工和新材料.销售.天然气销售.tectonic/xelatex; it is not HTML→PDF.For >200 page annual reports, index first. Do not blind-grep repeatedly.
pdfinfo "$PDF" | grep -E "Pages|Encrypted|Page size"
python3 - <<'PY'
from pypdf import PdfReader
pdf = "$PDF"
doc = PdfReader(pdf)
def walk(items, depth=0):
for it in items:
if isinstance(it, list):
walk(it, depth+1)
else:
try:
print(f"{' '*depth}{it.title}\t{doc.get_destination_page_number(it)+1}")
except Exception:
pass
walk(getattr(doc, 'outline', []))
PY
pdftotext -layout -f 1 -l 8 "$PDF" -
If outline is empty, use printed TOC from first pages. In the PetroChina run, printed TOC showed:
会计数据和财务指标摘要 printed p5 → physical PDF p7.经营情况讨论与分析 printed p21 → physical PDF p23.python3 - <<'PY'
import pdfplumber
pdf = "$PDF"
for pno in [7,25,26,27,173,174,262,263]:
with pdfplumber.open(pdf) as doc:
text = doc.pages[pno-1].extract_text(x_tolerance=1, y_tolerance=3) or ''
print('\n=== PAGE', pno, '===')
print(text[:5000])
PY
For complex annual-report financial tables, run read_pdf_vision.py one page at a time. Do not pass ranges for these target pages.
cd "$MINIMAX_PDF_SKILL"
python3 -m scripts.read_pdf_vision \
--input "$PDF" \
--pages 7 \
--prompt "请逐字提取本页‘主要财务数据/会计数据和财务指标摘要’表格,保留所有行名、年份和数值,输出 Markdown 表格。" \
--max-stdout-bytes 12000
Segment prompts used in this run:
请逐字提取本页分部业绩中的‘油气和新能源’部分,保留营业收入、经营支出、经营利润及同比描述,输出结构化中文。
请逐字提取本页分部业绩中的‘炼油化工和新材料’与‘销售’部分,保留营业收入、经营支出、经营利润及同比描述,输出结构化中文。
请逐字提取本页分部业绩中的‘天然气销售’部分,以及资产负债权益表关键数据,保留营业收入、经营支出、经营利润及同比描述,输出结构化中文。
Recovery: gemini analysis failed: unexpected end of JSON input may occur. Retry once; if it repeats and the text layer is clean, use pdfplumber output for that page and cross-check against adjacent segment tables.
Use a normalized display vocabulary but preserve annual-report source names in a column:
| Display term | Source term examples | Notes |
|---|---|---|
| 勘探与生产 | 油气和新能源 / Exploration and Production | Mention mapping explicitly. |
| 炼油与化工 | 炼油化工和新材料 / Refining, Chemicals and New Materials | If source added “新材料”, keep source name in table. |
| 销售 | 销售 | Include trade business if source does. |
| 天然气与管道 | 天然气销售 / Natural Gas Sales | Some annual reports no longer use “管道”; map to requested term. |
Number rules:
百万元, 亿元, 万亿元).分部收入 with 对外交易收入. Include both when possible.This run had two layout phases:
When user asks for broker-research / academic style but complains about whitespace, switch to the compact LaTeX strategy:
\scriptsize tables, narrow margins (≈11–12mm), compact section spacing.Use static PNG charts. The build_charts.py artifact contains an end-to-end scaffold using matplotlib. Adapt:
financial dict: revenue, profit, EPS, assets, cash flow, ROE by year.segments list: business-line revenue/profit/yoy values.trend.png, donut.png, radar.png.Run:
python3 build_charts.py
If using only the compact LaTeX template, place the generated PNGs in the same working directory as source.tex, or update \includegraphics{...} paths.
Use the case source as the editable deliverable:
cp "$MINIMAX_PDF_SKILL/templates/data-viz-report/cases/annual-report-financial-digest-latex/source.tex" ./report.tex
# edit company name, dates, tables, source notes, chart paths
tectonic -X compile report.tex --outdir ./out
cp ./out/report.pdf ./company_annual_report_digest.pdf
If tectonic is unavailable:
xelatex -interaction=nonstopmode report.tex
xelatex -interaction=nonstopmode report.tex
Important: if user explicitly requires HTML→PDF (some evals do), use the normal pdf HTML route instead. If user explicitly requests LaTeX or rejects HTML-style whitespace, this case applies.
Run every time:
pdfinfo "$OUT" | grep -E "Pages|Page size"
pdfimages -list "$OUT" | wc -l
pdftotext -layout "$OUT" - | grep -E "2,937,981|勘探与生产|炼油与化工|销售|天然气与管道"
Expected evidence for the PetroChina-style case:
Pages ≤ 10. Compact final in this run: 2 pages.Page size is A4 (595.28 x 841.89 pts or close).pdftotext finds:
2,937,981 for PetroChina 2024 case);Optional link check if using TOC:
python3 - <<'PY'
from pypdf import PdfReader
r = PdfReader('$OUT')
ann = 0
for page in r.pages:
a = page.get('/Annots')
if a:
ann += len(a.get_object())
print('annots', ann)
PY
| Pitfall | Symptom | Recovery |
|---|---|---|
| Too much decorative whitespace | User says “每页很多空白 / 不需要好看的样式” | Switch to compact LaTeX table-first template; remove cover/cards; reduce margins and font size. |
| LaTeX floats create blank pages | Chart jumps to last page or creates a blank page | Use \usepackage{float} and [H], reduce image height, avoid one-chart-per-page. |
| HTML vs LaTeX confusion | User asks “你这个不是HTML转的吗?” | State clearly; deliver .tex-compiled PDF; include note “LaTeX直接编译生成,非HTML转PDF”. |
| Segment names mismatch | User asks “天然气与管道” but report says “天然气销售” | Include both display term and source term columns. |
| Vision transient failure | unexpected end of JSON input |
Retry once; fallback to pdfplumber if text layer is clean. |
| Revenue acceptance mismatch | User expects “约3.03万亿元” but source says 2.94万亿元 | Show source value and percentage error; verify within ±5%. |
| Over-wide Chinese tables | Column overflow or tiny unreadable text | Use tabularx, \scriptsize, narrow margins, abbreviate headers, or split into two tables. |
pdfinfo, pdftotext, pdfplumber, pypdf, tectonic/xelatex..tex source in the working directory for edits.