pdfjsLib.getDocument({data: this.props.pdfData}).then((pdf) => {
this.setState({pdf: pdf});
});
I have changed the above block of code to
var loadingTask = pdfjsLib.getDocument({ data: this.props.pdfData });
loadingTask.promise.then((pdf) => {
this.setState({ pdf: pdf });
});
because I was getting
pdfViewer.jsx?5761:28 Uncaught TypeError: pdfjsLib.getDocument(...).then is not a function
after that my page loads without any errors but am getting CSS NAN if change renderPages
function canvas.width
and canvas.height
to some value pages are loading but pdf is looking wired
_renderPage(page) {
const { scale } = this.context;
const viewport = page.getViewport(scale);
const { width, height } = viewport;
const canvas = this.canvas.current;
const context = canvas.getContext('2d');
canvas.width = width;
canvas.height = height;
page.render({
canvasContext: context,
viewport,
});
this.setState({ status: 'rendered', page, width, height });
}
Any suggestions
question from:
https://stackoverflow.com/questions/65838870/pdf-viewer-component-cannot-load-images 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…