Skip to content

Commit

Permalink
Add props cMapUrl & cMapPacked
Browse files Browse the repository at this point in the history
  • Loading branch information
euglena1215 committed Nov 25, 2018
1 parent 130fa9c commit 11e5943
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Binary file modified example/public/test.pdf
Binary file not shown.
8 changes: 7 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ export default class ReactPdfJs extends Component {
page: PropTypes.number,
onDocumentComplete: PropTypes.func,
scale: PropTypes.number,
cMapUrl: PropTypes.string,
cMapPacked: PropTypes.bool,
className: PropTypes.string,
}

static defaultProps = {
page: 1,
onDocumentComplete: null,
scale: 1,
cMapUrl: '../node_modules/pdfjs-dist/cmaps/',
cMapPacked: false,
}

state = {
Expand All @@ -32,9 +36,11 @@ export default class ReactPdfJs extends Component {
file,
onDocumentComplete,
page,
cMapUrl,
cMapPacked,
} = this.props;
PdfJsLib.GlobalWorkerOptions.workerSrc = '//cdnjs.cloudflare.com/ajax/libs/pdf.js/2.0.943/pdf.worker.js';
PdfJsLib.getDocument(file).then((pdf) => {
PdfJsLib.getDocument({ url: file, cMapUrl, cMapPacked }).then((pdf) => {
this.setState({ pdf });
if (onDocumentComplete) {
onDocumentComplete(pdf._pdfInfo.numPages); // eslint-disable-line
Expand Down

1 comment on commit 11e5943

@rijk
Copy link

@rijk rijk commented on 11e5943 Feb 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I ask — do you know what these cMaps are for? Are they required?

Please sign in to comment.