You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] CJK PDFs render blank and index empty: PDF.js CMap/font assets are not bundled #130
CJK PDFs (Chinese / Japanese / Korean) fail in two places at once:
Reader: the canvas has no glyphs for CJK runs; the text layer is missing the same text.
Ingestion: PdfLoader.getTextContent() silently drops every CJK run, so chunks contain only the Latin/ASCII text. Anything the model could retrieve from that document is therefore wrong or empty — this is a plausible part of why notebook chat "does not retrieve or cite indexed knowledge" for CJK sources.
The only signal is a warning, not an exception:
Warning: loadFont - translateFont failed:
"UnknownErrorException: Ensure that the `cMapUrl` API parameter is provided."
Warning: Error during font loading:
Ensure that the `cMapUrl` API parameter is provided.
Because it is a warning, both paths "succeed" with missing text.
Root cause
PDF.js treats predefined CMaps, standard fonts and the wasm image decoders as external assets fetched by filename (${cMapUrl}${name}.bcmap). KnowNote never passed any of the three to getDocument:
PdfLoader.ts — getDocument({ data, password })
PdfSourceReader.tsx — getDocument({ data })
pdfjs-dist ships the files (cmaps/, standard_fonts/, wasm/), but nothing references them.
Reproduced on main with noembed-jis7.pdf (non-embedded Japanese font):
extracted text
CJK present
no cMapUrl
"ABC 1231"
❌
cMapUrl + cMapPacked
"ABCあいうえお123 1"
✅
Scope
Bundle pdfjs-dist/{cmaps,standard_fonts,wasm} as real files (electron-builder extraResources → resources/pdfjs/, outside app.asar).
Pass cMapUrl + cMapPacked: true to both getDocument call sites.
Pass standardFontDataUrl and wasmUrl too — PDF.js exposes all three as one contract.
Renderer reads them through a dedicated knownote-asset:// protocol (the renderer must not receive filesystem paths, same rule as knownote-doc://). Main reads them as filesystem paths.
Symptom
CJK PDFs (Chinese / Japanese / Korean) fail in two places at once:
PdfLoader.getTextContent()silently drops every CJK run, so chunks contain only the Latin/ASCII text. Anything the model could retrieve from that document is therefore wrong or empty — this is a plausible part of why notebook chat "does not retrieve or cite indexed knowledge" for CJK sources.The only signal is a warning, not an exception:
Because it is a warning, both paths "succeed" with missing text.
Root cause
PDF.js treats predefined CMaps, standard fonts and the wasm image decoders as external assets fetched by filename (
${cMapUrl}${name}.bcmap). KnowNote never passed any of the three togetDocument:PdfLoader.ts—getDocument({ data, password })PdfSourceReader.tsx—getDocument({ data })pdfjs-distships the files (cmaps/,standard_fonts/,wasm/), but nothing references them.Reproduced on
mainwithnoembed-jis7.pdf(non-embedded Japanese font):cMapUrl"ABC 1231"cMapUrl+cMapPacked"ABCあいうえお123 1"Scope
pdfjs-dist/{cmaps,standard_fonts,wasm}as real files (electron-builderextraResources→resources/pdfjs/, outsideapp.asar).cMapUrl+cMapPacked: trueto bothgetDocumentcall sites.standardFontDataUrlandwasmUrltoo — PDF.js exposes all three as one contract.knownote-asset://protocol (the renderer must not receive filesystem paths, same rule asknownote-doc://). Main reads them as filesystem paths.connect-src; add'wasm-unsafe-eval'for wasm compilation. The scripting boundary from security(pdf): remediate GHSA-hq66-cqwq-w95j before v1.4 (pdfjs-dist 5.7.284 in affected range) #121 is unaffected — that forbids JSeval/inline script, andscript-srcstill has no'unsafe-eval'.npm run dev.Acceptance
Renderer
cMapUrl/ font-loading warnings in the consoleIngestion / retrieval
getTextContent()on the same PDF returns correct CJKRetrieverPackaging
npm run build:unpackshipsresources/pdfjs/{cmaps,standard_fonts,wasm}npm run smoke:packagedpasses on the packaged appRelated