Skip to content

fix(pdf): render CJK text with pdf.js resources - #21625

Merged
OrcaWin merged 1 commit into
mainfrom
bug-japanese-cjk-pdfs-render-without-their-text
Sep 19, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
bug-japanese-cjk-pdfs-render-without-their-text

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Sep 19, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​16 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​16
Prod 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​136 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​128

Problem

Japanese and other CJK PDFs can open with Latin text visible but CJK glyphs missing because pdf.js is initialized without its CMap resources. The same missing resource configuration affects standard fonts and WASM decoders.

Change

Pass CMap, standard-font, and WASM URLs to pdf.js and make the corresponding pdfjs-dist directories available in desktop builds, web builds, development, and the paired web runtime. The resources remain local and are loaded on demand.

Validation

  • Focused Vitest tests pass.
  • pnpm run build:web passes and outputs all three resource directories.
  • oxlint and commit hooks pass.

Fixes #21458.

@pullfrog

pullfrog Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

This run was cancelled 🛑

The workflow was cancelled before completion. Please check the link below for details.

Pullfrog  | View workflow run | via Pullfrog | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

The change adds a Vite plugin for PDF.js cmaps, standard_fonts, and wasm assets. The plugin serves validated requests in development and copies assets during builds. Renderer projection and static request mapping include the assets. PDF.js document loading now receives URLs resolved from document.baseURI, and tests verify the generated options.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to 2ef36

Paired web clients served from a /cmaps proxy path can fail to load CMap files, so CJK glyph rendering may remain broken until the path mapping uses the inner asset prefix.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the problem, the implementation, the validation, and links issue #21458. It does not follow the required template and omits the required Visual Proof section, testing checklis… Update the description to include all required template sections. Add visual proof or write N/A with a reason if there is no visual or interaction change. Document manual testing, tested platforms, automated tests, AI disclosure when appl…
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: fixing CJK PDF rendering by providing pdf.js resources.
Linked Issues check ✅ Passed The PR meets the coding requirements in [#21458]. PdfViewer now uses buildPdfJsDocumentOptions, which passes cMapUrl, cMapPacked: true, standardFontDataUrl, and wasmUrl. The focused test v…
Out of Scope Changes check ✅ Passed The changes stay within [#21458]. The build plugin, web projection, static web prefixes, and PDF viewer helper directly support local PDF.js resource delivery for development, packaged renderer output…
Full details: Description check

Explanation

The description explains the problem, the implementation, the validation, and links issue #21458. It does not follow the required template and omits the required Visual Proof section, testing checklist and platform details, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections.

Resolution

Update the description to include all required template sections. Add visual proof or write N/A with a reason if there is no visual or interaction change. Document manual testing, tested platforms, automated tests, AI disclosure when applicable, review considerations, upstream-boundary status, and checklist results.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 720e1203-4ee6-49e3-85f9-239c8768f8f8

📥 Commits

Reviewing files that changed from the base of the PR and between a37282b and 2ef366d.

📒 Files selected for processing (8)
  • config/build-plugins/pdfjs-viewer-assets.ts
  • config/scripts/project-renderer-web-client.mjs
  • electron.vite.config.ts
  • src/main/runtime/rpc/static-web-client-handler.ts
  • src/renderer/src/components/editor/PdfViewer.tsx
  • src/renderer/src/components/editor/pdf-js-document-options.test.ts
  • src/renderer/src/components/editor/pdf-js-document-options.ts
  • vite.web.config.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

const assetIndex = pathname.indexOf(assetMarker)
if (assetIndex !== -1) {
const prefixIndex = STATIC_WEB_ALLOWED_PREFIXES.reduce(
(deepest, prefix) => Math.max(deepest, pathname.indexOf(prefix)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

rg -n -C 4 'mapProxyPrefixedStaticPathname|STATIC_WEB_ALLOWED_PREFIXES|static-web' src config --glob '!node_modules'
sed -n '1,180p' src/main/runtime/rpc/static-web-client-handler.ts

Repository: stablyai/orca

Length of output: 9285


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- symbol and handler references ---'
rg -n -C 5 'mapProxyPrefixedStaticPathname|createStaticWebClientHandler|STATIC_WEB_ALLOWED_PREFIXES|/cmaps/|foo\.bcmap|standard_fonts|wasm/' src --glob '*.{ts,tsx,js,json}' --glob '!node_modules'
printf '%s\n' '--- relevant test files ---'
rg --files src | rg '(static-web|ws-transport-static-web|pdf|cmaps|standard_fonts|wasm)'
printf '%s\n' '--- transport setup around static handler ---'
sed -n '1,180p' src/main/runtime/rpc/ws-transport.ts

Repository: stablyai/orca

Length of output: 17098


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- static web test outline and targeted content ---'
ast-grep outline src/main/runtime/rpc/ws-transport-static-web.test.ts
sed -n '1,280p' src/main/runtime/rpc/ws-transport-static-web.test.ts
printf '%s\n' '--- static root and PDF.js asset packaging references ---'
rg -n -C 4 'staticRoot|cmaps|standard_fonts|wasm|pdfjs|pdf\.worker|web-index\.html' src package.json config --glob '*.{ts,tsx,js,json,mjs,cjs,yml,yaml}' --glob '!node_modules'

Repository: stablyai/orca

Length of output: 50369


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- PDF.js asset plugin ---'
sed -n '1,115p' config/build-plugins/pdfjs-viewer-assets.ts
printf '%s\n' '--- runtime lifecycle web-root wiring ---'
sed -n '145,190p' src/main/runtime/runtime-rpc/runtime-rpc-lifecycle.ts
printf '%s\n' '--- endpoint and web-client path construction ---'
sed -n '120,155p' src/main/runtime/runtime-rpc/runtime-rpc-pairing-types.ts
rg -n -C 5 'webClientPathForEndpoint|webClientUrl|proxy|pathname' src/main/runtime/runtime-rpc src/main/runtime --glob '*.{ts,tsx}' | head -n 180

Repository: stablyai/orca

Length of output: 22407


🌐 Web query:

pdfjs-dist 6.3.289 cmaps directory nested files package contents

💡 Result:

<search_synthesis>
In the pdfjs-dist package (version 6.3.289), the cmaps directory does not contain any nested subdirectories [1][2]. It consists of a flat structure containing a collection of character map files, which are typically stored with the.bcmap file extension [1][3]. These files are used by the PDF.js library to map character codes to Unicode values [4][5]. As of this version, the directory contains over 160 individual files directly within the cmaps folder [1].
</search_synthesis>

<source_evidence>

<title>UNPKG</title> https://app.unpkg.com/[email protected]/files/cmaps # pdfjs-dist ... Generic build of Mozilla&`#39`;s PDF.js library. ... 169 files ... | Filename | Content Type | Size | | --- | --- | --- | | ../ | | | | 78-EUC-H.bcmap | application/octet-stream | 2.4 kB | | 78-EUC-V.bcmap | application/octet-stream | 173 B | | 78-H.bcmap | application/octet-stream | 2.38 kB | | 78-RKSJ-H.bcmap | application/octet-stream | 2.4 kB | | 78-RKSJ-V.bcmap | application/octet-stream | 173 B | | 78-V.bcmap | application/octet-stream | 169 B | | 78ms-RKSJ-H.bcmap | application/octet-stream | 2.65 kB | | 78ms-RKSJ-V.bcmap | application/octet-stream | 290 B | | 83pv-RKSJ-H.bcmap | application/octet-stream | 905 B | | 90ms-RKSJ-H.bcmap | application/octet-stream | 721 B | | 90ms-RKSJ-V.bcmap | application/octet-stream | 290 B | | 90msp-RKSJ-H.bcmap | application/octet-stream | 715 B | | 90msp-RKSJ-V.bcmap | application/octet-stream | 291 B | | 90pv-RKSJ-H.bcmap | application/octet-stream | 982 B | | 90pv-RKSJ-V.bcmap | application/octet-stream | 260 B | ... | Add-H.bcmap | application/octet-stream | 2.42 kB | | Add-RKSJ-H.bcmap | application/octet-stream | 2.41 kB | | Add-RKSJ-V.bcmap | application/octet-stream | 287 B | | Add-V.bcmap | application/octet-stream | 282 B | ... bcmap | application ... octet-stream | ... 371 B | ... 376 ... CNS1- ... .bcmap ... stream | 401 B | ... | Adobe-CNS1-4 ... 405 ... | Adobe-CNS1 ... bcmap | application/octet-stream | 406 B | | Adobe-CNS1 ... map | application/octet-stream | 406 B | ... 2 kB | ... | Adobe- ... stream | 217 B | ... | Adobe-GB1 ... 25 ... | Adobe-GB1 ... application/octet-stream | ... 65 B | | Adobe-GB1-3. ... map | application/octet-stream | 47 ... | Adobe-GB ... octet-stream | ... | Adobe-GB ... -stream | ... 25 B | ... -stream | ... stream | ... 09 kB | ... map | application ... stream | 142 B | | B5pc-H ... map | application/octet-stream | 1.1 kB | ... map | application ... stream | ... 44 B | ... stream | 1 ... bcmap | ... stream | ... map | application ... stream | ... ETenms ... bcmap | application/octet-stream | ... 1 B | ... bcmap | application/octet ... stream | 172 B | ... | EUC-H.bcmap | application/octet-stream | 578 B | | EUC-V.bcmap | application/octet-stream | 170 B | ... | Ext-H.bcmap | application/octet-stream | 2.54 kB | | Ext-RKSJ-H.bcmap | application/octet-stream | 2.54 kB | | Ext-RKSJ-V.bcmap | application/octet-stream | 218 B | | Ext-V.bcmap | application/octet-stream | 215 B | ... | GB-EUC-H.bcmap | application/octet-stream | 549 B | | GB-EUC-V.bcmap | application/octet-stream | 179 B | | GB- ... .bcmap | application/octet-stream | 528 B | | GB-V.bcmap | application/octet-stream | 175 B | ... | GBK-EUC-H.bcmap | application/octet-stream | 14.7 kB | | GBK-EUC-V.bcmap | application/octet-stream | 180 B | | GBK2K-H.bcmap | application/octet-stream | 19.7 kB | | GBK2K-V.bcmap | application/octet-stream | 219 B | ... | GBKp- ... UC-H.bcmap | application/octet-stream | 14.7 kB | | GBKp-EUC-V.bcmap | application/octet-stream | 181 B | ... | GBT-EUC-H.bcmap | application/octet-stream | 7.29 kB | | GBT-EUC-V.bcmap | application/octet-stream | 180 B | | GBT-H.bcmap | application/octet-stream | 7.27 kB | | GBT-V.bcmap | application/octet-stream | 176 B | | GBTpc-EUC-H.bcmap | application/octet-stream | 7.3 kB | | GBTpc-EUC-V.bcmap | application/octet-stream | 182 B | | GBpc-EUC-H.bcmap | application/octet-stream | 557 B | | GBpc-EUC-V.bcmap | application/octet-stream | 181 B | | H.bcmap | application/octet-stream | 553 B | ... stream | 148 B ... | HKdl ... 2.41 kB | ... -B5- ... map | application ... stream | 14 ... octet-stream | 2.2 ... kB | | ... -B5- ... stream | 14 ... | HKm31 ... -B5- ... .bcmap | application/octet-stream | ... kB | | HKm314 ... B5-V.bcmap | ... -stream | 1 ... 9 B | ... | HKm ... 1-B5- ... .bcmap | application/octet-stream | 2.17 kB | | HKm471-B5-V.bcmap | application/octet-stream | 149 B | ... | HKscs-B5-H.bcmap | application/octet-stream | 4.44 kB | | HKscs-B5 ... V.bcmap | application/octet ... stream |…[truncated] <title>UNPKG</title> https://app.unpkg.com/[email protected] UNPKG # pdfjs-dist Generic build of Mozilla&`#39`;s PDF.js library. mozilla.github.io/pdf.js/ mozilla/pdf.js 9 folders, 5 files | Filename | Content Type | Size | | --- | --- | --- | | build/ | – | 12.4 MB | | cmaps/ | – | 1.17 MB | | iccs/ | – | 15 kB | | image_decoders/ | – | 648 kB | | legacy/ | – | 16.4 MB | | standard_fonts/ | – | 798 kB | | types/ | – | 420 kB | | wasm/ | – | 1.55 MB | | web/ | – | 1.37 MB | | CODE_OF_CONDUCT.md | text/markdown | 691 B | | LICENSE | text/plain | 10.2 kB | | README.md | text/markdown | 666 B | | package.json | application/json | 710 B | | webpack.mjs | text/javascript | 924 B | <title>pdfjs-dist/cmaps at master · mozilla/pdfjs-dist · GitHub</title> https://github.com/mozilla/pdfjs-dist/tree/master/cmaps pdfjs-dist/cmaps at master · mozilla/pdfjs-dist · GitHub This repository was archived by the owner on Jul 14, 2024. It is now read-only. / pdfjs-dist Public archive Star 1.3k - Pricing - Notifications - Fork 568 ## Files master # cmaps History master # cmaps Top Last commit message Last commit date 78-EUC-H.bcmap 78-EUC-H.bcmap 78-EUC-V.bcmap 78-EUC-V.bcmap 78-H.bcmap 78-H.bcmap 78-RKSJ-H.bcmap 78-RKSJ-H.bcmap 78-RKSJ-V.bcmap 78-RKSJ-V.bcmap 78-V.bcmap 78-V.bcmap 78ms-RKSJ-H.bcmap 78ms-RKSJ-H.bcmap 78ms-RKSJ-V.bcmap 78ms-RKSJ-V.bcmap 83pv-RKSJ-H.bcmap 83pv-RKSJ-H.bcmap 90ms-RKSJ-H.bcmap 90ms-RKSJ-H.bcmap 90ms-RKSJ-V.bcmap 90ms-RKSJ-V.bcmap 90msp-RKSJ-H.bcmap 90msp-RKSJ-H.bcmap 90msp-RKSJ-V.bcmap 90msp-RKSJ-V.bcmap 90pv-RKSJ-H.bcmap 90pv-RKSJ-H.bcmap 90pv-RKSJ-V.bcmap 90pv-RKSJ-V.bcmap Add-H.bcmap Add-H.bcmap Add-RKSJ-H.bcmap Add-RKSJ-H.bcmap Add-RKSJ-V.bcmap Add-RKSJ-V.bcmap Add-V.bcmap Add-V.bcmap Adobe-CNS1-0.bcmap Adobe-CNS1-0.bcmap Adobe-CNS1-1.bcmap Adobe-CNS1-1.bcmap Adobe-CNS1-2.bcmap Adobe-CNS1-2.bcmap Adobe-CNS1-3.bcmap Adobe-CNS1-3.bcmap Adobe-CNS1-4.bcmap Adobe-CNS1-4.bcmap Adobe-CNS1-5.bcmap Adobe-CNS1-5.bcmap Adobe-CNS1-6.bcmap Adobe-CNS1-6.bcmap Adobe-CNS1-UCS2.bcmap Adobe-CNS1-UCS2.bcmap Adobe-GB1-0.bcmap Adobe-GB1-0.bcmap Adobe-GB1-1.bcmap Adobe-GB1-1.bcmap Adobe-GB1-2.bcmap Adobe-GB1-2.bcmap Adobe-GB1-3.bcmap Adobe-GB1-3.bcmap Adobe-GB1-4.bcmap Adobe-GB1-4.bcmap Adobe-GB1-5.bcmap Adobe-GB1-5.bcmap Adobe-GB1-UCS2.bcmap Adobe-GB1-UCS2.bcmap Adobe-Japan1-0.bcmap Adobe-Japan1-0.bcmap Adobe-Japan1-1.bcmap Adobe-Japan1-1.bcmap Adobe-Japan1-2.bcmap Adobe-Japan1-2.bcmap Adobe-Japan1-3.bcmap Adobe-Japan1-3.bcmap Adobe-Japan1-4.bcmap Adobe-Japan1-4.bcmap Adobe-Japan1-5.bcmap Adobe-Japan1-5.bcmap Adobe-Japan1-6.bcmap Adobe-Japan1-6.bcmap Adobe-Japan1-UCS2.bcmap Adobe-Japan1-UCS2.bcmap Adobe-Korea1-0.bcmap Adobe-Korea1-0.bcmap Adobe-Korea1-1.bcmap Adobe-Korea1-1.bcmap Adobe-Korea1-2.bcmap Adobe-Korea1-2.bcmap Adobe-Korea1-UCS2.bcmap Adobe-Korea1-UCS2.bcmap B5-H.bcmap B5-H.bcmap B5-V.bcmap B5-V.bcmap B5pc-H.bcmap B5pc-H.bcmap B5pc-V.bcmap B5pc-V.bcmap CNS-EUC-H.bcmap CNS-EUC-H.bcmap CNS-EUC-V.bcmap CNS-EUC-V.bcmap CNS1-H.bcmap CNS1-H.bcmap CNS1-V.bcmap CNS1-V.bcmap CNS2-H.bcmap CNS2-H.bcmap CNS2-V.bcmap CNS2-V.bcmap ETHK-B5-H.bcmap ETHK-B5-H.bcmap ETHK-B5-V.bcmap ETHK-B5-V.bcmap ETen-B5-H.bcmap ETen-B5-H.bcmap ETen-B5-V.bcmap ETen-B5-V.bcmap ETenms-B5-H.bcmap ETenms-B5-H.bcmap ETenms-B5-V.bcmap ETenms-B5-V.bcmap EUC-H.bcmap EUC-H.bcmap EUC-V.bcmap EUC-V.bcmap Ext-H.bcmap Ext-H.bcmap Ext-RKSJ-H.bcmap Ext-RKSJ-H.bcmap Ext-RKSJ-V.bcmap Ext-RKSJ-V.bcmap Ext-V.bcmap Ext-V.bcmap GB-EUC-H.bcmap GB-EUC-H.bcmap GB-EUC-V.bcmap GB-EUC-V.bcmap GB-H.bcmap GB-H.bcmap GB-V.bcmap GB-V.bcmap GBK-EUC-H.bcmap GBK-EUC-H.bcmap GBK-EUC-V.bcmap GBK-EUC-V.bcmap GBK2K-H.bcmap GBK2K-H.bcmap GBK2K-V.bcmap GBK2K-V.bcmap GBKp-EUC-H.bcmap GBKp-EUC-H.bcmap GBKp-EUC-V.bcmap GBKp-EUC-V.bcmap GBT-EUC-H.bcmap GBT-EUC-H.bcmap GBT-EUC-V.bcmap GBT-EUC-V.bcmap GBT-H.bcmap GBT-H.bcmap GBT-V.bcmap GBT-V.bcmap GBTpc-EUC-H.bcmap GBTpc-EUC-H.bcmap GBTpc-EUC-V.bcmap GBTpc-EUC-V.bcmap GBpc-EUC-H.bcmap GBpc-EUC-H.bcmap GBpc-EUC-V.bcmap GBpc-EUC-V.bcmap H.bcmap H.bcmap HKdla-B5-H.bcmap HKdla-B5-H.bcmap HKdla-B5-V.bcmap HKdla-B5-V.bcmap HKdlb-B5-H.bcmap HKdlb-B5-H.bcmap HKdlb-B5-V.bcmap HKdlb-B5-V.bcmap HKgccs-B5-H.bcmap HKgccs-B5-H.bcmap HKgccs-B5-V.bcmap HKgccs-B5-V.bcmap HKm314-B5-H.bcmap HKm314-B5-H.bcmap HKm314-B5-V.bcmap HKm314-B5-V.bcmap HKm471-B5-H.bcmap HKm471-B5-H.bcmap HKm471-B5-V.bcmap HKm471-B5-V.bcmap HKscs-B5-H.bcmap HKscs-B5-H.bcmap HKscs-B5-V.bcmap HKscs-B5-V.bcmap Hankaku.bcmap Hankaku.bcmap View all files | Name | Name | | --- | --- | | .. | <title>PDF.js - Getting Started</title> https://mozilla.github.io/pdf.js/getting_started/ PDF.js - Getting Started # Getting Started An introduction to PDF.js with examples. ## Introduction Before downloading PDF.js please take a moment to understand the different layers of the PDF.js project. | Layer | About | | --- | --- | | Core | The core layer is where a binary PDF is parsed and interpreted. This layer is the foundation for all subsequent layers. It is not documented here because using it directly is considered an advanced usage and the API is likely to change. For an example of using the core layer see the PDF Object Browser. | | Display | The display layer takes the core layer and exposes an easier to use API to render PDFs and get other information out of a document. This API is what the version number is based on. | | Viewer | The viewer is built on the display layer and is the UI for PDF viewer in Firefox and the other browser extensions within the project. It can be a good starting point for building your own viewer. However, we do ask if you plan to embed the viewer in your own site, that it not just be an unmodified version. Please re-skin it or build upon it. | ## Download Please refer to this wiki page for information about supported browsers. ### Prebuilt (modern browsers) Includes the generic build of PDF.js and the viewer. Stable (v6.2.108) ### Prebuilt (older browsers) Includes the generic build of PDF.js and the viewer. Stable (v6.2.108) ### Source To get a local copy of the current code, clone it using git: ``` $ git clone https://github.com/mozilla/pdf.js.git $ cd pdf.js ``` ## Including via a CDN PDF.js is hosted on several free CDNs: - https://www.jsdelivr.com/package/npm/pdfjs-dist - https://cdnjs.com/libraries/pdf.js - https://unpkg.com/pdfjs-dist/ ## File Layout Overview Note that we only mention the most relevant files and folders. ### Prebuilt ```plaintext ├── build/ │ ├── pdf.mjs - display layer │ ├── pdf.mjs.map - display layer&`#39`;s source map │ ├── pdf.worker.mjs - core layer │ └── pdf.worker.mjs.map - core layer&`#39`;s source map ├── web/ │ ├── cmaps/ - character maps (required by core) │ ├── compressed.tracemonkey-pldi-09.pdf - PDF file for testing purposes │ ├── images/ - images for the viewer and annotation icons │ ├── locale/ - translation files │ ├── viewer.css - viewer style sheet │ ├── viewer.html - viewer layout │ ├── viewer.mjs - viewer layer │ └── viewer.mjs.map - viewer layer&`#39`;s source map └── LICENSE ``` ### Source ```plaintext ├── docs/ - website source code ├── examples/ - simple usage examples ├── extensions/ - browser extension source code ├── external/ - third party code ├── l10n/ - translation files ├── src/ │ ├── core/ - core layer │ ├── display/ - display layer │ ├── shared/ - shared code between the core and display layers │ ├── interfaces.js - interface definitions for the core/display layers │ └── pdf.*.js - wrapper files for bundling ├── test/ - unit, font, reference, and integration tests ├── web/ - viewer layer ├── LICENSE ├── README.md ├── gulpfile.mjs - build scripts/logic ├── package-lock.json - pinned dependency versions └── package.json - package definition and dependencies ``` ## Trying the Viewer With the prebuilt or source version, open `web/viewer.html` in a browser and the test pdf should load. Note: the worker is not enabled for file:// urls, so use a server. If you&`#39`;re using the source build and have node, you can run `npx gulp server`. ## More Information For a further walkthrough of a minimal viewer, see the hello world example. More documentation can be found in our wiki too. <title>docs/contents/getting_started/index.md</title> https://github.com/mozilla/pdf.js/blob/master/docs/contents/getting_started/index.md # docs/contents/getting_started/index.md - Branch: master - Repository: mozilla/pdf.js --- --- title: Getting Started layout: layout.njk slug: getting_started --- # Getting Started An introduction to PDF.js with examples. ## Introduction Before downloading PDF.js please take a moment to understand the different layers of the PDF.js project. Layer About Core The core layer is where a binary PDF is parsed and interpreted. This layer is the foundation for all subsequent layers. It is not documented here because using it directly is considered an advanced usage and the API is likely to change. For an example of using the core layer see the PDF Object Browser. Display The display layer takes the core layer and exposes an easier to use API to render PDFs and get other information out of a document. This API is what the version number is based on. Viewer The viewer is built on the display layer and is the UI for PDF viewer in Firefox and the other browser extensions within the project. It can be a good starting point for building your own viewer. However, we do ask if you plan to embed the viewer in your own site, that it not just be an unmodified version. Please re-skin it or build upon it. ## Download Please refer to this wiki page for information about supported browsers. Prebuilt (modern browsers) Includes the generic build of PDF.js and the viewer. Stable (vSTABLE_VERSION) Prebuilt (older browsers) Includes the generic build of PDF.js and the viewer. Stable (vSTABLE_VERSION) Source To get a local copy of the current code, clone it using git: $ git clone https://github.com/mozilla/pdf.js.git $ cd pdf.js ## Including via a CDN PDF.js is hosted on several free CDNs: - https://www.jsdelivr.com/package/npm/pdfjs-dist - https://cdnjs.com/libraries/pdf.js - https://unpkg.com/pdfjs-dist/ ## File Layout Overview Note that we only mention the most relevant files and folders. ### Prebuilt ```plaintext ├── build/ │ ├── pdf.mjs - display layer │ ├── pdf.mjs.map - display layer&`#39`;s source map │ ├── pdf.worker.mjs - core layer │ └── pdf.worker.mjs.map - core layer&`#39`;s source map ├── web/ │ ├── cmaps/ - character maps (required by core) │ ├── compressed.tracemonkey-pldi-09.pdf - PDF file for testing purposes │ ├── images/ - images for the viewer and annotation icons │ ├── locale/ - translation files │ ├── viewer.css - viewer style sheet │ ├── viewer.html - viewer layout │ ├── viewer.mjs - viewer layer │ └── viewer.mjs.map - viewer layer&`#39`;s source map └── LICENSE ``` ### Source ```plaintext ├── docs/ - website source code ├── examples/ - simple usage examples ├── extensions/ - browser extension source code ├── external/ - third party code ├── l10n/ - translation files ├── src/ │ ├── core/ - core layer │ ├── display/ - display layer │ ├── shared/ - shared code between the core and display layers │ ├── interfaces.js - interface definitions for the core/display layers │ └── pdf.*.js - wrapper files for bundling ├── test/ - unit, font, reference, and integration tests ├── web/ - viewer layer ├── LICENSE ├── README.md ├── gulpfile.mjs - build scripts/logic ├── package-lock.json - pinned dependency versions └── package.json - package definition and dependencies ``` ## Trying the Viewer With the prebuilt or source version, open `web/viewer.html` in a browser and the test pdf should load. Note: the worker is not enabled for file:// urls, so use a server. If you&`#39`;re using the source build and have node, you can run `npx gulp server`. ## More Information For a further walkthrough of a minimal viewer, see the hello world example. More documentation can be found in our wiki too.

Citations:


Use the last occurrence of each allowed prefix.

When the proxy path is /cmaps, the web client requests PDF.js CMaps as /cmaps/cmaps/<file>.bcmap. indexOf() keeps the outer prefix, so the handler can look for staticRoot/cmaps/cmaps/<file>.bcmap instead of staticRoot/cmaps/<file>.bcmap and return 404.

-    (deepest, prefix) => Math.max(deepest, pathname.indexOf(prefix)),
+    (deepest, prefix) => Math.max(deepest, pathname.lastIndexOf(prefix)),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
(deepest, prefix) => Math.max(deepest, pathname.indexOf(prefix)),
(deepest, prefix) => Math.max(deepest, pathname.lastIndexOf(prefix)),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Japanese/CJK PDFs render without their text — pdf.js is initialized without cMapUrl

1 participant