Spaces:
Running
Running
fix(pdf): tagged PDF显式关闭+容器CJK字体换静态TrueType——PDF体积3倍竞品根因修复(2026-10-04)——①server.js page.pdf显式tagged:false+outline:false:Puppeteer24 parsePDFOptions把tagged默认翻true(node_modules/puppeteer-core/common/util.js),每文字运行产StructElem(436轮NotebookLM实测63,171个5.65MB,xref 79,817);②Dockerfile弃装fonts-noto-cjk(CFF-in-OTC无法子集→全部汉字逐页Type3,745字典2.4MB CharProcs),改构建期从google/fonts(commit固定a85815a)下载SC/TC/JP/KR/HK变量字体+fonttools实例化400/700静态TrueType装系统(--update-name-table防family名带Thin致fontconfig miss;--no-install-recommends下需显式ca-certificates+fontconfig;fonttools走python3 -m入口);emoji字体保留(位图Type3残余0.02MB,视觉优先);真实容器端到端:同会话HTML POST实测26.66MB→8.69MB(-67%)低于竞品9.41MB,xref→3,182,Type3→45,图片5.19MB→0.69MB与竞品同量级,文本保真98.15%字符级一致,嵌入字体全TTF子集;本机pdf-test(17861)/pdf-prod(7860)已重建验证字节级一致;12平台API契约零改动,新旧插件全兼容;证据链XWXExporter/temp/test/notebooklm/2026-10-04/与解决方案API/111;HF Space待用户手动push部署
38f9bb7 Download Dockerfile from XWX-AI/api-server: direct link, hf CLI and curl.
- Browser
- Download file 2.49 kB
-
https://huggingface.co/spaces/XWX-AI/api-server/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/XWX-AI/api-server/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/XWX-AI/api-server/resolve/main/Dockerfile
2.49 kB
| # Use Node.js 20 on Debian Bookworm (Chromium 149, fixes SVG context-stroke support) | |
| # | |
| # ── CJK 字体策略(2026-10-04 PDF 体积根因修复,勿回退到 fonts-noto-cjk)── | |
| # Debian 的 fonts-noto-cjk 是 CFF 轮廓的 OTC 集合封装,Skia/PDF 无法对它做 | |
| # 子集嵌入,print-to-PDF 时每个 CJK 字形都退化为 Type3 逐页画(436 轮会话实测: | |
| # 745 个 Type3 字体字典 + 2.4MB CharProcs + 每页重复字形,韩文/康熙部首同样中招; | |
| # 变量字体也触发 Type3,已实测)。TrueType 轮廓的静态实例则正常以 TTF 子集嵌入, | |
| # 全文档共享一份。证据链见 XWXExporter 仓库 temp/test/notebooklm/2026-10-04/。 | |
| # 因此:构建期从 google/fonts 下载变量字体(commit 固定可复现),用 fontTools | |
| # 实例化 400/700 两个 weight 装为系统字体;不装 fonts-noto-cjk。 | |
| # 插件 document-export-css.js 的字体栈已按语言对齐静态家族名 | |
| # (Noto Sans SC/TC/JP/KR/HK 优先于 CJK OTC 名)。 | |
| # emoji 仍用 fonts-noto-color-emoji(CBDT 位图,少量 Type3 残留,视觉优先)。 | |
| FROM node:20-bookworm-slim | |
| RUN apt-get update && apt-get install -y \ | |
| chromium \ | |
| fonts-noto-core \ | |
| fonts-noto-color-emoji \ | |
| python3-fonttools \ | |
| fontconfig \ | |
| curl \ | |
| ca-certificates \ | |
| libxss1 \ | |
| --no-install-recommends \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # google/fonts 仓库 commit 固定(2026-10-04 取) | |
| ARG NOTO_FONTS_COMMIT=a85815a42757630ce188fdad368c2dfc444d4773 | |
| RUN set -eux; \ | |
| mkdir -p /usr/local/share/fonts/noto-sans-static; \ | |
| for fam in notosanssc:NotoSansSC notosanstc:NotoSansTC notosansjp:NotoSansJP notosanskr:NotoSansKR notosanshk:NotoSansHK; do \ | |
| dir="${fam%%:*}"; stem="${fam##*:}"; \ | |
| curl -fsSL -o "/tmp/${stem}-Var.ttf" \ | |
| "https://raw.githubusercontent.com/google/fonts/${NOTO_FONTS_COMMIT}/ofl/${dir}/${stem}%5Bwght%5D.ttf"; \ | |
| for w in 400 700; do \ | |
| python3 -m fontTools.varLib.instancer --update-name-table \ | |
| -o "/usr/local/share/fonts/noto-sans-static/${stem}-${w}.ttf" \ | |
| "/tmp/${stem}-Var.ttf" "wght=${w}"; \ | |
| done; \ | |
| rm -f "/tmp/${stem}-Var.ttf"; \ | |
| done; \ | |
| fc-cache -f | |
| # Set working directory | |
| WORKDIR /app | |
| # Install Node.js Dependencies | |
| COPY package.json . | |
| RUN npm install | |
| # Copy Application Code (including templates/) | |
| COPY . . | |
| # Expose Port (Hugging Face expects 7860) | |
| EXPOSE 7860 | |
| # Run the Application | |
| CMD ["node", "server.js"] | |