Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

81 changes: 39 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/esm/index.d.ts",
"exports": {
".": {
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js"
}
},
"engines": {
"node": ">=12.0.0"
},
Expand All @@ -39,7 +45,7 @@
"mustache": "^4.2.0",
"papaparse": "^5.4.1",
"react-pdf": "7.7.1",
"styled-components": "^6.1.9"
"styled-components": "^6.1.10"
},
"devDependencies": {
"@babel/core": "^7.23.0",
Expand Down
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ export default DocViewer;
export { DocViewerRenderers } from "./renderers";
export * from "./models";
export * from "./utils/fileLoaders";
export { AvailableLanguages } from "./i18n";
export type { AvailableLanguages } from "./i18n";
export * from "./renderers";
13 changes: 11 additions & 2 deletions src/renderers/pdf/components/pages/PDFPages.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable */
import React, { FC, useContext, useEffect } from "react";
import { Document } from "react-pdf";
import React, { FC, useContext, useEffect, useMemo } from "react";
import { Document, pdfjs } from "react-pdf";
import styled from "styled-components";
import { useTranslation } from "../../../../hooks/useTranslation";
import { PDFContext } from "../../state";
Expand All @@ -18,6 +18,14 @@ const PDFPages: FC<{}> = () => {

const currentDocument = mainState?.currentDocument || null;

const options = useMemo(
() => ({
cMapUrl: `https://cdn.jsdelivr.net/npm/pdfjs-dist@${pdfjs.version}/cmaps/`,
cMapPacked: true,
}),
[],
);

useEffect(() => {
dispatch(setNumPages(initialPDFState.numPages));
}, [currentDocument]);
Expand All @@ -29,6 +37,7 @@ const PDFPages: FC<{}> = () => {
file={currentDocument.fileData}
onLoadSuccess={({ numPages }) => dispatch(setNumPages(numPages))}
loading={<span>{t("pdfPluginLoading")}</span>}
options={options}
>
{paginated ? <PDFSinglePage /> : <PDFAllPages />}
</DocumentPDF>
Expand Down
2 changes: 2 additions & 0 deletions src/renderers/pdf/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { DocRenderer, IStyledProps } from "../..";
import PDFPages from "./components/pages/PDFPages";
import PDFControls from "./components/PDFControls";
import { PDFProvider } from "./state";
import "react-pdf/dist/esm/Page/AnnotationLayer.css";
import "react-pdf/dist/esm/Page/TextLayer.css";

pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.js`;

Expand Down
Loading