web/pdf_viewer.js cannot load build/pdf.js
See original GitHub issueConfiguration:
- Web browser and its version: Chrome, Version 62.0.3202.94 (Official Build) (64-bit)
- Operating system and its version: Win 10
- PDF.js version: 2.0.185, installed from npm
I’m using TypeScript with requirejs and trying to use pdfjs library.
My configuration is:
require.config({
paths: {
'pdfjs-dist': 'libs/pdfjs-dist',
}
shim: {
'pdfjs-dist/web/pdf_viewer': {
deps: ['pdfjs-dist/build/pdf']
}
}
});
The imports are:
import { PDFJSViewer } from "pdfjs-dist/web/pdf_viewer";
import * as PDFJSWorker from "pdfjs-dist/build/pdf.worker";
The problem is that when pdf_viewer tries to load the “…/build/pdf.js” with require from the “else” branch:
var pdfjsLib = void 0;
if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
pdfjsLib = window['pdfjs-dist/build/pdf'];
} else {
**pdfjsLib = require('../build/pdf.js');**
}
module.exports = pdfjsLib;
…but it throws the following error
Since requirejs is using its own config one possible solution could be that giving the path defined in the require.config section.
**pdfjsLib = require('pdfjs-dist/build/pdf');**
Issue Analytics
- State:
- Created 6 years ago
- Comments:15 (1 by maintainers)
Top Results From Across the Web
pdf.js not loading pdf file - Stack Overflow
So I moved what I had in my js file into my html file and put it in script tags and now it...
Read more >Easy Web PDF Viewer With jQuery And pdf.js - pdfjs-viewer
A jQuery Plugin that provides a simple way for your users to view PDF documents directly in their web browser.
Read more >How to create a PDF Viewer in JavaScript - Educative.io
PDF.js is a JavaScript library maintained by Mozilla and designed for handling PDFs in JavaScript. We are going to create a PDF viewer...
Read more >Rendering PDF Files in the Browser with PDF.js - PSPDFKit
In this tutorial, we'll go a bit deeper and examine one of the most popular open source libraries for rendering PDF files in...
Read more >Reinstatement Form - Investors Heritage Life Insurance ...
web/pdfviewer.js cannot load build/pdf.js Issue #9239 ... Landers. esq gmail.com Counsel for Relator Dick Flanagan Christopher J. Gagin 0062820 Of Counsel ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Found a temporary solution.
Loading the pdfjs before bootstrapping the Application and attaching it to window
Since pdf_viewer.js has the following code this will work:
It’s not the proper way tho, but it works at least.
Have you tried the following import order instead?