I ran into an interesting PDF file which has some custom javascript that triggers the print window function automatically when the file is opened.
The annoyance comes when the file is uploaded into a web app and every time the file is previewed or opened it fires up the print dialog.
The only information I found was about cleaning the file in a PDF creator/reader software or blocking the default print dialog on the page with javascript, but that seems to interfere with normal print options.
Has anyone run into this combination before and found a way to block the print dialog on PDF files (only) without disrupting the usual print options for the browser?
Related
I wanted to print from the Client PC, the document is more secured which should not allow to save in the local. So I want to print directly to the default printer.
Our current problem is that in the print dialog there is an option to save the document in the local "Save as PDF". I need a solution for this:
I want to print directly in the printer without showing print dialog.
Save As PDF Dialog should not be showed in the print dialog.
For security reasons, I think you can't do this, because normally, the actions that require to store data in the disk memory without asking anything or to interface with internal or external components (except a part of RAM - in fact, for example, clipboard actions are available) are not supposed to work being forced.
I'm generating pdf files from a html file using decktape (and ofc reveal.js) inside a docker image. In the html file there are multiple svg files, which i need to download separately.
My idea was to create a script which automatically downloads the svg-s with the computed css when the html file is opened. But I have to solve the problem of the prompt window. Is there any way to download files automatically with javascript without the prompt window popping up?
I'm already able to download the file with the prompt window popping up, but I would like to do it without that, automatically. This is happening on a Linux Debian 9 server, and the decktape is using a Chromium.
Task:
I have a huge html file that is placed on server, I want to show it to the user by click of an URL.
Issue:
As this file is huge, On click of the URL the browser doesn't render the page in time*(Records get appended continuously while the vertical scroll bar size diminishes, user is not able to do anything but see the first few records)* and the default spinner of the browser spins endlessly.
Can this be achieve this way, if yes, how?---> On click of the "link", the html file should get downloaded on client machine first, then viewed on client browser window from his local system not from URL directly(maybe in a iframe or something).
EDIT
loading 500 MB of HTML was asking a lot of a browser.
Work around
Since generated htmls files were huge, we converted htmls files to pdf format. Later, used browser's default pdf viewer capability to view the data on browser window itself or simply downloaded the pdf file onto the disk.
No, there is no way to force a browser to download an HTML file to disk and open it.
In practical terms, a 500+ MB HTML file will never be readable -- loading it requires much more memory than is available to a web browser. Downloading it won't help. You need to break it up into smaller documents.
I am automating a website with WebDriver but my file download needs are a little different from those I have found when googling.
I have a website which creates orders. When I click the 'place order' button, it redirects me to the Print Order page. As a "convenience" for me, this page automatically launches the download operation in its body onload, meaning that when I click the 'place order' button, I go to a new page and then a file download dialog immediately appears to let me download the generated pdf, thus blocking the browser.
Here are the solutions I found/thought of, and why I couldn't use them:
Configure Firefox/Chrome profiles to silently download files. Can't use this because I have the requirement of timing how long the download takes.
Override window.open with a function that prevents the download, and allows me to grab the URL and download it with wget. Can't use this because the file download is started from the onload function of the next page, so any javascript I run on this page will be lost.
Cancel the onload function or try to execute code before the onload function. Can't find a way to do this in webdriver.
Download the print page with wget, modify the html to change the onload handler, and inject the modified html back into selenium. Can't find a way to replace an entire page, including <head> and <body> tag and URL.
Unfortunately I can't change the source code of this website because I am in QA and I don't have that sort of leverage with development. Does anyone have any ideas for a way to download this file in an automatic manner that can be timed?
Thanks.
Seems to me you have 2 options.
Use an AUTOIT script to download the file once you receive the popup, this tests the functionality of the page opening and the download.
Download the file just using http get. This misses out testing that the page loads but will still check that the file exists.
The other tests you mention above seem to be too complicated.
How can I do this:
the page loads
javascript loads a remote PDF file into local memory
the user clicks a button/link
the system launches the PDF reader or starts a download dialog with the PDF file already in memory
In other words, it's a regular file download in the browser EXCEPT that the file has already been loading in the background in order to speed up its receipt when/if the user decides to download the file.
You would have to encode the file (perhaps via a servlet), then you could get it through an XHR, and write it into a data uri, which you could then attach to a button or link.
This technique would probably only work on small files and very recent browsers.
StackOverflow won't let me post an example link as a link, so to test the concept, you'll have to copy the following line into an html file and see if you can load the link:
pdf link
This worked perfectly in Chrome when I tested it just now, and worked partially in Firefox. It didn't work at all in my version of IE.
Another potential solution is to make absolutely sure that the pdf is being cached, and then try to load it in a hidden iframe. Whether this works or not will depend on how the user has their browser set up.
You should consider not doing it at all, given the difficulties.