-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow multiple PDF embeddings in one page #25
Comments
Yes, it doesn't work. |
I tried your solution, but it doesn't work because - I suppose - I have a multilingual website, and if I click on "PDF", it misses something at the beginning of the PATH. |
Hard to say without an example. So only the download button does not work because |
Thank you for your reply. content Can you help me in setting the correct path? |
Apologies for the extremely reply but the last few months have been quite hectic. |
I did it as you suggest, using |
As a user, I confirm that I was very interested by hugo-embeded-pdf-shortcode, but as I was unable to display more than one pdf per page, I had to resign from using it, turning toward a more classic iframe. In other word, in my opinion this feature is a must. |
Hello all, I'm currently working on this, and have ended up with something mostly functional. My modified version of the You can see a demonstration of multiple PDFs rendered in a page at the following link: https://blog.ctis.me/2022/06/assorted-presentations/ Currently, I'm experiencing problems with transient corruption of text content when multiple PDFs are embedded. This behavior is inconsistent and occurs at random. I'm not entirely certain why this is, but would appreciate thoughts from others who have more experience working with the library. @anvithks Once the text corruption issue is sorted, I can roll my changes back into the main project as a PR to enable this feature for everyone. |
Actually, I just figured out the issue. The PDF shortcode includes the pdf.js library in the page. If you have multiple of these, the library will be embedded multiple times. This appears to have been causing the unexpected behavior. Thankfully, Hugo has a mechanism (.HasShortcode) to check for the existence of a shortcode which can be used in conditionals. I updated my master header template to include the following. As a result, the corruption bug appears to have been fixed. {{ if .HasShortcode "pdf" }}
<script type="text/javascript" src='{{"/pub/js/pdfjs/build/pdf.js" | relURL}}'></script>
{{ end }} |
Thanks for the awesome work @ctrezevant ! |
Problem: Embedding two PDFs in one page does not work
Solution: Use
window.addEventListener("load",function(){
instead ofwindow.onload = function(event) {
and have unique IDs.I made soma adaptions here: https://github.com/jakob-r/courseTheme/blob/main/layouts/shortcodes/pdfjs.html
If you are interested I can make a PR.
The text was updated successfully, but these errors were encountered: