How to download PDF in chrome viewer using automation script - javascript

I have to download PDFs using any automation script, when i click on download PDF button, it opens up in new tab in chrome pdf viewer, manually I can click on Download button and download. But when I try to automate it, I can see the button id 'Download' in Inspect element, but when I use command Document.GetelementbyID('Download').click(), the button or any other icon on screen in not getting identified.
I tried changing the chrome setting to directly download pdf, instead of opening in new tab, but it fails for large PDFs (maybe something wrong with source application). I cannot change browsers.
So is there a way to download pdf from pdf viewer, some key shortcut or some script to retrieve the PDF from chrome temp.

Related

How to figure out how a popup URL is derived in chrome devtools?

https://www.ingentaconnect.com/content/govi/pharmaz/2012/00000067/00000002/art00012
I am trying to learn how to resolve the PDF download link after clicking "Download" on the above webpage in chrome devtools. Because the popup windows is started automatically, I use the following command to automatically open the devtools window for the pop up.
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' --auto-open-devtools-for-tabs --user-data-dir=tmpdir --incognito
I see the pdf download link in the pop window. But it is not clear how to PDF download URL is derived from the original webpage.
Can anybody show me how to figure out the way the PDF download URL is derived from the original webpage? Thanks.

How to open a file directly from msSaveOrOpenBlob?

I am using IE 11 for web development. Now in javascript, I do window.msSaveOrOpenBlob(fileBlob), a pop up shows on the button of the page with save and open option.
Now what I want to achieve is that perform click event on open so the file will be open automatically(without user click open).
Here is the case:
User click a link, it should open the associated file with whatever file reader that can open the file. PDF, will be adobe reader, word document will be opened in microsoft word.
Things still works when I click the open button from pop up. I just want to skip this manual click and do it in the code.
I've seen some webpage does this, but can't figure out myself. Need some help.
As far as I know, we can't control the "open or save" prompt using JavaScript. It is the browser behavior.
As a workaround, to the pdf file, I suggest you could try to use the pdf.js plugin to display the pdf file. To the Office documents, you could check the following article to use the Office Web Viewer to view the document.
Office Web Viewer: View Office documents in a browser
Besides, here is an article about displaying (Show) Word, Excel, PowerPoint (PPT) and PDF files in browser web page in ASP.Net, you can also refer to it.

ExpertPDF Run JavaScript only in PDF

I am using old version of ExpertPDF.
I have web page and I click PDF link.
I have some JavaScript that I only want to run in the PDF window.
How do I check in JavaScript that the script will run in the PDF generated window? I am trying to hide some elements that don't need to show in the PDF.

Javascript call programmatically the "Save as PDF" feature of Chrome dialog print

Google Chrome have the option "Save as PDF" when you enter the Print dialog or window.print().
The user need to choice this option in dialog to save the page as pdf.
Can I call some funcion or pass an argument to window.print() in chrome to "print" the page as a pdf without the print dialog appears?
Any ideas?
Unfortunately there isn't any param you could pass to window.print(); and force it to print pdf unless there is a pdf driver plugin already present on the client's browser. There are plugins for firefox and IE (JS Print Setup and MeadCo Script respectively).
You may want to look at MrRio/jsPDF, a tool to generate pdf files at client-side JS.

Is there any way to open ppt file open in Full screen when I click on anchor link in HTML?

I have ppt file in the href attribute of an anchor tag.If i click on the Anchor tag the file should open in Full screen.I tried by saving the ppt file in different Formats but nothing worked. Please let me know if any way to do that in Html or using Javascript.
Ppt is not an HTML standard so you can't expect to see it in the web page properly, but only if you have a proper viewer installed in the computer, but you can't predict it's behaviour.
Why not export the ppt to HTML and then point a link to it with target="_blank"?
Upload your PowerPoint to Scribd and you can use their API to show it on your website without any add-ons or special software.

Categories