Текст не отображается в pdfjs - PullRequest
0 голосов
/ 28 мая 2019

Я использую pdfjs в проекте VUE. Некоторые страницы могут отображаться правильно, но когда вы встречаете некоторые специальные символы, pdfjs не показывает их.
Я не знаю, как показать слова специальными шрифтами.

  1. получить pdfjs объект

    const pdfWorkerUrl = that.common.PdfWorker;
    window.fetch(pdfWorkerUrl).then(response => response.text()).then((res) => {
    PDFJS.GlobalWorkerOptions.workerPort = new window.Worker(
    window.URL.createObjectURL(new window.Blob([res])));
    });
    
  2. Загрузить PDF

    that.pdfjsDocument = PDFJS.getDocument(this.pdfUrl);
    
    that.pdfjsDocument.onProgress = () => {
      // console.log(progress, total);
    };
    that.pdfjsDocument.then((pdf) => {
        that.pdfPage = pdf;
        that.pdfLoadState = 0;
        that.loadPage(pdfUrl, index);
    });
    
  3. that.pdfPage.getPage(pageIndex).then((page) => {.......}

Фактически, он может отображать текст в обычных шрифтах.

...