Text is not displayed in pdfjs

Asked by At

I use pdfjs in vue project. Some pages can be displayed properly, but when you encounter some special characters, pdfjs don't show them.
I don't know how to show words with special fonts.

  1. get pdfjs object

    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. load 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) => {.......}

In fact, it can display text in normal fonts.

0 Answers