fix (pdf): js based pdfviewer as fallback

This commit is contained in:
Mickael Kerjean
2022-11-25 17:14:34 +11:00
parent bb8fcfda91
commit 42e7c10c41
2 changed files with 4 additions and 4 deletions

View File

@ -2,7 +2,7 @@ import React, { useState } from "react";
import { Document, Page, pdfjs } from "react-pdf"; import { Document, Page, pdfjs } from "react-pdf";
import "react-pdf/dist/esm/Page/AnnotationLayer.css"; import "react-pdf/dist/esm/Page/AnnotationLayer.css";
pdfjs.GlobalWorkerOptions.workerSrc = "/assets/vendor/pdfjs/2.6.347/build/pdf.worker.js"; pdfjs.GlobalWorkerOptions.workerSrc = "/assets/vendor/node_modules/pdfjs-dist/build/pdf.worker.js";
export function PDFJSViewer({ src }) { export function PDFJSViewer({ src }) {
const [numPages, setNumPages] = useState(0); const [numPages, setNumPages] = useState(0);
@ -12,7 +12,7 @@ export function PDFJSViewer({ src }) {
file={src} file={src}
onLoadSuccess={(d) => setNumPages(d["numPages"])} onLoadSuccess={(d) => setNumPages(d["numPages"])}
options={{ options={{
cMapUrl: "/assets/vendor/pdfjs/cmaps/", cMapUrl: "/assets/vendor/node_modules/pdfjs-dist/cmaps/",
cMapPacked: true, cMapPacked: true,
}}> }}>
{ {

View File

@ -73,8 +73,8 @@ const config = {
{ from: "assets/fonts/*" }, { from: "assets/fonts/*" },
], { context: path.join(__dirname, "client") }), ], { context: path.join(__dirname, "client") }),
new CopyWebpackPlugin([ new CopyWebpackPlugin([
{ from: "node_modules/pdfjs-dist/build/*.js", to: "assets/vendor/pdfjs/2.6.347/build/" }, { from: "node_modules/pdfjs-dist/build/*.js", to: "assets/vendor/" },
{ from: "node_modules/pdfjs-dist/cmaps/", to: "assets/vendor/pdfjs/2.6.347/cmaps/" }, { from: "node_modules/pdfjs-dist/cmaps/*", to: "assets/vendor/" },
]), ]),
// new BundleAnalyzerPlugin() // new BundleAnalyzerPlugin()
], ],