Closed mgodbole closed 1 week ago
I did a quick test asumming you're using latest Vaadin 24.4 version and latest add-on version. I can see a browser error related to CORS:
Do you see that same message?
If I try with a different pdf, for example https://ontheline.trincoll.edu/images/bookdown/sample-local-pdf.pdf, it renders okay.
If you see the same message about CORS then I think the problem is in the server configuration of the url you're using. It should provide the CORS headers.
Hi @paodb I can confirm the same behaviour you mention above. I do get the CORS error but the second URL works just fine. You are a life saver. Thank you!
Also is there any way I can attach any kind of listener to get notified when the user turns the page? For better UX, I would like to "remember" the last page read.
The addThumbnailClickedListener
is not really reliable, as the user might navigate using the previous/next Vaadin buttons.
Update:
pdfViewer.addClickListener(event -> {
Notification.show("}> Clicked " + pdfViewer.getCurrentPage());
});
Good news: This works just fine. I get notified if the user clicks on the previous/next as well as the thumbnails or any other clicks for that matter.
Bad news: The user can still change the page by scrolling. Can't figure out a way to hook a listener onto the scroll.
pdfViewer.getElement().addEventListener("scroll",event -> {
Notification.show("}> Scroll " + pdfViewer.getCurrentPage());
});
This does not work.
Any ideas are most welcome. Thank you
Hi @mgodbole you can use currentPage-changed event . This seems to work when user clicks previous/next button or when scrolling the document:
pdfViewer.getElement().addEventListener("currentPage-changed", event -> {
Notification.show("Page changed to:" + pdfViewer.getCurrentPage());
});
Just a quick note: to keep the conversation focused and ensure each issue gets the attention it needs, please create a new issue for any different or unrelated questions about the component. This makes it easier to track and helps others who might have the same issue. Thanks!
That did the trick @paodb Not only does it work for previous/next and scroll, but also for thumbnail selection and navigating directly to a page by typing in the page number. Thank you so much!
Just a quick note: to keep the conversation focused and ensure each issue gets the attention it needs, please create a new issue for any different or unrelated questions about the component. This makes it easier to track and helps others who might have the same issue. Thanks!
Noted.
Issue resolved.
I just stumbled across this add-on and it is exactly what I was looking for. Awesome job @paodb ! Thank you!
I wish to render a remote pdf file in my Vaadin app, but it is not working.
The URL which I am using for testing works just fine in my browser https://www.gutenberg.org/files/42911/Bizet-Variations_Chromatiques_de_concert/Bizet-Variations_Chromatiques_de_concert_Theme_A4.pdf
Expectations:
Reality:
All this makes me think that my understanding of
public void setSrc(String src)
is not correct, even though the API comment says it expects a URL stringCan someone please help point me in the right direction? Thank you