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 1,230 times
-1

sideshowbarker
- 81,827
- 26
- 193
- 197

Paul Müller
- 103
- 8
-
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.

crg
- 4,284
- 2
- 29
- 57
-
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