Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function createPDFViewer() {
PDFJS.GlobalWorkerOptions.workerSrc = '../../../node_modules/pdfjs-dist/build/pdf.worker.js';
const container = document.getElementById('viewerContainer');
if (! container) {
throw new Error("No container");
}
const pdfLinkService = new PDFLinkService();
// the text area is working!
//
// FIXME: I think I ahve to specify a custom RenderingQueue here because right now it renders ALL the pages...
//
// // and I need to limit this to say += 10 pages..
//
// // FIXME: how do we change the zoom
//
// // FIXME: how do we render the thumbnails
//
// FIXME: center the page properly
// FIXME make sure all the background and spacing is proper on the PDF
const pdfViewer = new PDFViewer({
container: container as HTMLDivElement,
componentDidMount() {
const { pdfDocument } = this.props;
this.debouncedAfterSelection = _.debounce(500, this.afterSelection);
this.linkService = new PDFLinkService();
this.viewer = new PDFViewer({
container: this.containerNode,
enhanceTextSelection: true,
removePageBorders: true,
linkService: this.linkService
});
this.viewer.setDocument(pdfDocument);
this.linkService.setDocument(pdfDocument);
this.linkService.setViewer(this.viewer);
// debug
window.PdfViewer = this;
document.addEventListener("selectionchange", this.onSelectionChange);