Closed bfang711 closed 6 years ago
Hi! There is no way of getting the current page for the moment, but I can add it.
But the problem is that this should not happen :) I think your problem is related to the way the component is updated when the props are updated. It should keep the page number when you update the scale prop.
Can you please provide a code example that teiggers that issue? I'll try to fix it in a way that you'll not need to get the cureent page number :)
Thanks!
Thank you for your quick reply.
the way I do it is the following.
class Viewer extends Component{
constructor(props)
{ super(props);
this.state = {scale: 1.0};
}
render()
{
return (<PDFViewer document={xxx} scale={this.state.scale} />)
}
}
Then from somewhere else I change the state variable scale
, which trigger rerender of the PDFViewer, and everytime it goes back to the 1st page.
I wonder if this is the correct way of using PDFViewer. If you think this is the correct way, then I will make a code example for you. If you think this is not the correct way, which means rerender is not necessary, pls let me know how to do it correctly.
thank you so much.
I suppose that is the correct way for your case, I mean you have a reason to chage the scale during runtime.
As I said, in that case the current page number of the PDFViewer is the internal state of PDFViewer component, and should not change when the sclae prop change, it should somehow persist internally.
I'll try to fix that behavior tomorrow (so in 24hours :) ) otherwise if you can find time for you can create pull request :) but I'll fix it, no worries
I actually do think rerender will reset to the 1st page after reading your source code. Since I don't give page
as props, it will go back to page 1 according to your src code, unless it is not rerendered some how.
The reason I want to change scale runtime is to add +/- buttons to zoom in/out. However met this issue.
Again. Thank you so much for your kind and quick response. Pls do let me know if this is fixed.
Fixed in version 1.0.1, please let me know if that really fix it for your case :)
Cool. This resolved my issue.
Thank you for bring us this wonderful library.
I met an issue when rescale it, followed by rerender, it goes back to page 1. However I don't want to go back to page 1, but wherever I was viewing. How to do this?
thank you.