PDF Creation Using PhatomJS - phantomjs

I am trying to generate PDF using PhantomJS. All the examples i have seen so far is to run Phantom JS through command line. Is there a way to invoke PhantomJS and create the PDF when the user clicks on download option for the web page.

Related

Creating PDF version from Docusaurus 2.0

I've tried using the PDF plug in from https://github.com/kohheepeace/mr-pdf bit it is not working for me. PDF generation takes forever.
Is there an alternative or maybe some crawler that I could run on live site to get the PDF version?
Try using docusaurus-prince-pdf, this library relies on Prince printing library, so make sure you have prince installed before using this tool.
Simply run this command in your terminal to start downloading your docusaurus pages into a PDF file.
npx docusaurus-prince-pdf --include-index -u http://your-docusaurus-site/docs/intro
The PDF file will be saved in <current_dir>/pdf
This tool requires NodeJS 16 or later

Sphinx directive to open a PDF in the browser

tl;dr How can I make a PDF in the Sphinx html output open directly in the browser (or externally)? I want to click on the link and the PDF just opens.
I am currently trying to make sphinx create a link that opens a PDF file in the browser instead of downloading it. So far I only found the download directive, which is useful but I do not want to download those files as they are already available locally.
If there is no default way is there any way to extend Sphinx to achieve this behaviour?

Selenium Automation + chromedriver

I am trying to automate a web application wherein clicking a link downloads a PDF file. The default behavior of chromedriver should open a pop-up window for confirmation. I am facing issue with the same, In my case the file is directly downloading without prompting.(I need to pop up to change the file name)
My understanding is that there is no easy way to make Selenium download files. Browsers use native dialogs which cannot be controlled by JavaScript.
Why are you downloading a file in the first place?
Check out this for more detail.
This can be set via settings option,
refer the below link https://support.google.com/chrome/answer/95574

Can Cordova 'FileWriter' create/download a PDF document?

I've written a web application to create and download a pdf document on client-side using jsPDF and Downloadify. jsPDF prepares the document and Downloadify downloads it as a pdf. Everything works fine.
I'm trying to replicate this behavior on a PhoneGap app (using FileWriter instead of Downloadify). FileWriter handles writing onto files. Using FileWriter, I've created txt files but couldn't create a pdf.
Is is possible to create a PDF document using Cardova at all?
If not are there any plugins around?
As of now (Cordova 2.8.0), I have concluded that there's no inbuilt API or plugins to create a pdf document usgin Cordova. I ended up creating PDF in server side using PHP plugin called tcpdf and downloading it in local file system.
Again, as of now no. But to view pdf on local file system, there's FileOpener-Plugin
You can create PDF file using specific ( with Cordova support ) dll from the Apitron PDF kit package.

How to handle download dialog using Selenium IDE?

I have a web page which contains a download link. If I click on the link, download dialog window will be launched and asking save or cancel.
If I click on Save, file will get downloaded, it will be closed if I click on Cancel button.
But, Selenium IDE is capturing any actions performed in the dialog window.
Please tell how to handle this situation using Selenium IDE.
Thanks in advance.
Unfortunately save as dialogs cannot be interacted with via javascript so Selenium IDE can't manipulate them.
If you want to click on a link and download a file, you can set up Firefox to automatically save files (without dialog - http://kb.mozillazine.org/File_types_and_download_actions). At lease with this method you can save the file when running localy.
The limitation of this will be that if you wanted to export the selenese and run it on an external testing solution (Saucelabs or Testingbot) it is unlikely that this approach will work.
You can also modify the firefox profile in the setUp method of your test.
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/msword,application/csv,text/csv,application/rtf,application/xml,text/xml,application/octet-stream,application/vnd.ms-excel,application/zip,text/txt,text/plain,application/pdf,application/x-pdf");
If you have other types of documents you want to download you should look up the MIME type of whatever document you are trying to download and adding it to the comma delimited list.