![]() You obviously need to host upload that document somewehere online. After hosting it, you can update the href value as the url of the file. You can use Google Drive, Onedrive or similar platforms for that and have necessary permissions to access. ![]() Opening some_pdf.html outside of the shiny app works fine. To solve your issue, you should host it somewhere. When the HTML renders, it comes out like this: Write(pdf_string, file = "www/some_pdf.html") ' Click here to download the PDF file.', sep = "") 'It appears you don\'t have a PDF plugin for this browser.', Here's the code that's relevant to this process: It seems like no matter what I try, Shiny can't find the file. The problem is that the nested file path, the one that links to the PDF document isn't being executed properly. When I try to do this with PDF documents, it coerces the HTML to include an iframe tag and it links the appropriate HTML file. My issue is this: In order to keep confidential information (files such as PDFs, sound files, images of suspects, etc) local, I do some behind the scenes checks about the files and if it needs to be local, I wrap it into an html file, which gets fed to the timeline, which gets wrapped in an iframe. The full code is too much to post in this forum, but can be found here. IncludeScript("The app itself serves as an interactive builder for the timeline, which updates with each addition of an element. TextAreaInput("markedTextFromPdf", label = "Test, if I can copy text from iframed local pdf"), Another way is to use a browser inspector tool. The shortcut keys CTRL + S on Windows, or Command + S on Mac open the same save options. Right-click, select Save as and then choose Webpage, HTML Only. The download attribute of the anchor tag should point to the link where the file to be downloaded is hosted. How to Download HTML Code from a Website. # fulltext::cache_options_set(full_path = paste0(wwwPath, "/cachedFiles")) Using good ol Javascript, you can use this feature to download the file directly. But I just want to export only the inner HTML. But I need to export that current HTML page from the outter site. But if I use these codes inside the inner HTML file it will export. Repeat steps 2-6 to see the console error When I click the export button the HTML file is exported and it will include the iFrame.Stop the shiny app, and change the source of the tags$iframe() in App.R by commenting out the current one and uncommenting the one above.Press and release Enter to trigger the javascript function (You should now see the marked text inside the textAreaInput in the parent element.Focus the parent frame by clicking outside the iframe. ![]() Inside the webbrowser, mark some text inside the iframe. ![]() Open R-Studio and run the app by executing all the code.set up the directory as shown under Folder Structure below.So I originally thought it was only a matter of storing the pdf file in the wrong place ( see this discussion), but I have myPdf.pdf already stored in the into the iframe, but when I embed myHtml.html I don't get that error and the function works as expected (besides the minor issue that I have to click outside the iframe to trigger the function, but that's another issue for another day).Īny help to solve this issues is highly appreciated (hints about that odd behaviour are also welcome) Steps to reproduce: SecurityError: Permission denied to access property "document" on cross-origin object The problem now is that my browser console gives me this error: I'm currently working on a little project to create a shiny app for systematic litreature reviews and as part of that I added functionality to download pdf-files and then show them inside an iframe (The pdf shows inside the iframe as expected).Īs a next step I want to be able to select text in that PDF and use Javascript to automatically copy it to a textAreaInput in the parent-frame. I've tried to get an answer to this on Stackoverflow already, but didn't get any answer for over a month. I've already checked your rules on cross-posting here and I think it's ok to do so, if not I apologize. Limitations and workarounds Nowadays, download attribute is supported in all mainstream browsers, but theres an important limitation: this attribute only works for same-origin URLs (protocol, port, and host have to match), and the blob: and data: schemes. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |