I want to show the first page of a pdf file as an image. As far as I can see, I can´t do that with the typescript library "ng2-pdf-viewer" and therefore need to use the javascript library "pdfjs-dist". I found this post describing how to create a thumbnail with pdfjs.
On "ng serve" I get the following error message:
Error: ./node_modules/pdfjs-dist/build/pdf.js 2205:45
Module parse failed: Unexpected token (2205:45)
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.
| intent: renderingIntent,
| renderInteractiveForms: renderInteractiveForms === true,
> annotationStorage: annotationStorage?.serializable || null
| });
| }
I found this post describing how to solve this by changing the angular builder. Then however I get the following error:
TypeError: Cannot read property 'flags' of undefined
I can only find mentions of this error in angular 9.
Therefore my questions:
- Is it really necessary to use a custom builder?
- How can I fix "Cannot read property 'flags'" in angular 11?
I´m using the following dependencies:
"dependencies": {
"@angular/animations": "~11.2.13",
"@angular/common": "~11.2.13",
"@angular/compiler": "~11.2.13",
"@angular/core": "~11.2.13",
"@angular/forms": "~11.2.13",
"@angular/platform-browser": "~11.2.13",
"@angular/platform-browser-dynamic": "~11.2.13",
"@angular/router": "~11.2.13",
"@types/pdfjs-dist": "^2.7.4",
"pdfjs-dist": "^2.8.335",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.11.3"
},