How can you read and change the x / y coordinates of a PDF in an iframe, my iframe looks like this: <iframe id="pdf-interface" class="pdf-interface" src=path></iframe>
where path
is the local path to the PDF file.
All attempts I've tried until now failed with the error message: Uncaught DOMException: Blocked a frame with origin "http://127.0.0.1:8080" from accessing a cross-origin frame
.
Is there any way to fix this or an alternative way of doing this?
Asked
Active
Viewed 21 times
-1
![](../../users/profiles/441757.webp)
sideshowbarker
- 62,215
- 21
- 143
- 153
![](../../users/profiles/14155583.webp)
Paul Müller
- 25
- 5
-
Does this help? https://stackoverflow.com/questions/22362008/access-to-iframe-contents-of-local-file/39685594#39685594 – Kevin B May 21 '21 at 22:22
-
Serve the pdf from your localhost so origins are the same – charlietfl May 21 '21 at 22:22
-
Thanks for your help, I'll look into the ressources, should've used the stackoverflow search engine not only google – Paul Müller May 21 '21 at 22:32
1 Answers
0
You can't access cross-origin iframes directly.
Read more about it on Quentin's answer https://stackoverflow.com/a/66139466/7942242
And Willy Wonka's answer might interest you as well https://stackoverflow.com/a/39685594/7942242 which has a reference about how to bypass Same Origin Policy.
![](../../users/profiles/7942242.webp)
crg
- 2,088
- 1
- 8
- 27
-
I'll look into it, shame that there is no way to at least read out the page number of a pdf, this makes an iframe for PDFs kind of useless in my opinion – Paul Müller May 21 '21 at 22:33