Skip to content
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

Trouble creating local build of playground due to absolute paths to logo.pdf and opensans.ttf #270

Open
jamesmarchment opened this issue Nov 12, 2021 · 1 comment

Comments

@jamesmarchment
Copy link

Hi,

Apologies if this is just caused by my own error or unfamiliarity with npm, but when trying to recreate the Playground locally I ran into a bunch of problems... and then sorted them out by making a very small change to the code.

I kept getting 404s and failed fetch requests on "logo.pdf" and "opensans.ttf" until I opened playground.js and saw that on lines 100-103 the paths are absolute:

const fixtrues = [
fetch('/logo.pdf'),
fetch('/opensans.ttf'),
]

So I changed them to relative paths:

const fixtrues = [
fetch('./logo.pdf'),
fetch('./opensans.ttf'),
]

...and after repeating the npm build process it worked fine. I think this isn't a problem on http://pdfjs.rkusa.st/ because there it is in a root directory, but when running it in a folder it causes an error that stops the whole thing from working. Again, sorry if this is the kind of thing that doesn't present a problem for more experienced developers, but I in my noob-ness got really hung up on it for a while before I discovered the cause.

@rkusa
Copy link
Owner

rkusa commented Dec 27, 2021

You are right, fetching the assets from root will cause an error when opening the playground from e.g. a file:/// path. When I test the playground locally I usually do the following:

cd playground/public
python3 -m http.server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants