Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

645
Views
How i can fix this error message with pdfjs-dist and angular?

I install pdfjs-lib in project angular for convert PDF to canvas after I get this error message:

Error: ./node_modules/pdfjs-dist/build/pdf.js 2094:26
Module parse failed: Unexpected token (2094:26)
File was processed with these loaders:
 * ./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js
 * ./node_modules/@ngtools/webpack/src/ivy/index.js
You may need an additional loader to handle the result of these loaders.
|   async destroy() {
|     this.destroyed = true;
>     await this._transport?.destroy();
|     this._transport = null;
| 

the goal is to convert the PDF page to canvas before rendering in HTML :

import * as pdfjslib from 'pdfjs-dist';
pdfjslib.getDocument(url).promise.then(async(pdf) => {
        pdf.getPage(1).then(async (page) => {
          let viewport = page.getViewport({ scale: 0.3 });
          let canvas =<HTMLCanvasElement> document.getElementById("card"+pageId);
          let context =<CanvasRenderingContext2D> canvas.getContext("2d");
          canvas.width = viewport.width;
          canvas.height = viewport.height;
          await page.render({
            canvasContext: context,
            viewport: viewport
          });
          resolve("ok");
        }).catch((err) => {
          reject("Erreur sur le pdf!!");
        });
      }).catch((err) => {
        reject("Erreur sur le pdf!!");
       });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Your build configuration does not support option chaining.

You should try to use legacy folder, like this: import from legacy build folder

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!