opensourcegreasemonkey / hugo-embed-pdf-shortcode-demo

This repository holds the source code for the demo website for hugo-embed-pdf-shortcode
https://hugo-embed-pdf.netlify.app/
MIT License
4 stars 1 forks source link

Uncaught TypeError: #4

Open jfparie opened 3 years ago

jfparie commented 3 years ago

Chrome browser 95.0.4638.69 gives the following error:

Cannot read properties of undefined (reading 'GlobalWorkerOptions') at window.onload ((index):256)

I copied ./layouts/shortcodes/embed-pdf.html to my own /layouts/shortcodes folder. The same from pdf.js library files from ./static/js/pdf-js to ./static/js. Is the following path structure correct?

- static

-- js

--- pdf-js

---- build ----- pdf.js ----- pdf.js.map ----- pdf.worker.js ----- pdf.worker.js.map

---- LICENSE

---- web ----- cmaps etc.

anvithks commented 3 years ago

@jfparie Seems correct. Could you please share a link to your repository. This repo is for the demo website of Hugo Embed PDF shortcode. You could refer the code in this repository and compare it with your code. The shortcode is hosted at this repository

jfparie commented 3 years ago

@anvithks Thanks for your response :-) Here is the link to the repository of my website where I want to use Hugo Embed PDF shortcode. I call the short code only in a .md markdown file by using the following command:

{{< embed-pdf url="./uploads/file_name.pdf" >}}

My issue has great similarities to issue #18. However, I was not able to solve the issue based on the mentioned work around by Arwhyte .

Note I cloned your repository by using git clone https://github.com/anvithks/hugo-embed-pdf-shortcode.git outside my website's repository, then I copied and pasted the earlier mentioned files in the above tree structure.

Thanks for looking into this!

anvithks commented 3 years ago

One thing I see is that the PDF file is not located with the .md file where it is included. Currently this is a limitation for which I am yet to get a proper solution. Another thing I noticed is that clicking on http://algorithmaudit.eu/ opens a site not found error page. This is the baseURL specified in the config.toml file. Could you please share the link to the website and page where you are including the pdf?

jfparie commented 3 years ago

Hi @anvithks, thanks for your reply :-)

  1. I included the file_name.pdf in the folder where the file_name.md document is located. I rendered {{< embed-pdf url="file_name.pdf" >}} but this doesn't seem to work. The same Failed to load resource: net::ERR_NAME_NOT_RESOLVED and Uncaught TypeError occur.
  2. The url you mentioned is indeed the baseURL where the website ultimately can be reached. However, for the time being I am working locally (using Hugo server on http://localhost:1313/) to develop the website. Based on this, have you any thoughts how to solve the issue. Many thanks!
anvithks commented 3 years ago

@jfparie I cloned your repository and by making a few changes I was able to get the pdf to display. You are right. It is related to the src and baseURL. The changes I made were:

With these changes I am able to see the pdf file.

This problem arises when we use the baseURL and try to build locally or do not specify one and try to build locally. I have not been able to spend a lot of time recently and have not been able to put out a fix. The code works when deployed on the actual baseURL.

I will try to fix this but in the meanwhile you can try the following:

Best, Anvith.

jfparie commented 2 years ago

Many thanks for fixing this! I will take a careful look later. Would you mind to remove the image previewing the document (the document should remain undisclosed)? Many thanks again :-)

anvithks commented 2 years ago

@jfparie sure. I have removed the screenshot. Let me know if you are able to get it to work.