4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[備忘録] pdf.jsで日本語が読み込めない場合はcMapを設定する必要があった

Last updated at Posted at 2022-01-15

このバージョンを使用しました。

        "pdfjs-dist": "^2.12.313",

npmでpdfjsをインストールしてelectronで使おうとしたとき、このようなエラーが出て一部の日本語がレンダリングされない問題に引っかかりました。

Warning: loadFont - translateFont failed: "TypeError: Failed to fetch".
Warning: Error during font loading: Failed to fetch

getDocumentするときにcMapフォルダがある場所を指定してやると表示されるようになりました。

        pdfjs.getDocument({
            url: path,
            cMapUrl:  "cmaps/",
            cMapPacked: true,
        });
4
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?