Angular 8 - PDF generation using jsPdf - javascript

Im using jsPdf to generate a PDF document which captures my html screen contents. I can see my downloaded PDF file in the download folder.
Can we change the path where the PDF is getting downloaded? Instead of having the default c:/downloads can we change the path?

Answer to your question is NO. It is not possible to change default download folder from Angular/Javascript or any other framework/language for that matter. It is forbidden due to user's security. That decision is always handled by the browser.
You could however define a Content-Disposition header that tells the browser if the file is supposed to be displayed inline or if it an attachment that can be downloaded and saved locally.

Related

Converted PDF should be saved on server side, not downloaded

The issue is that a converted PDF is downloaded by the client. I need the PDF to be saved on server side and sent by mail.
I am using jsPDF and html2canvas for converting HTML to PDF.
I guess that jsPDF is not the proper tool for your task. First line at Github is "Client-side JavaScript PDF generation for everyone" which says it all.
To let the server create a PDF, you need a tool which renders the HTML result and creates a PDF from it. Maybe a MS Word or OpenDocument template used in headless mode will suit your needs, as suggested here among other solutions.

Creating a directory picker to download a file to clients computer using js

I have written an application where on button click a .docx file is generated on the server and returned to client as base64 string. What I want to do now, is to let the user download the file in a directory of their choice.
To demonstrate what I mean, if I instead want to upload a file having a <input type='file'/> opens a dialog such like this
Where I can select the file. Is there any way to open this kind of dialog for a download button? I understand that the web-page doesn't receive the actual path on a clients pc for security reasons, but if you can chose an upload file, there is no reason to not chose a download path right?
No, for security reasons this is not possible.
See:
https://github.com/eligrey/FileSaver.js/issues/42

Download a file with javascript without any prompt name select, path select window

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.

Tinymce - Loading local file content to Tinymce Instance

I'm not sure how to go about this but I wanted to be able to load content from a file (i.e. txt, html, etc...) to my Tinymce instance.
So basically a button that initiates a file browser and then loads the content of the file to Tinymce.
I've seen this for images and image browsers but I'm not sure how to do this for files.
This would be done locally, not on a server as well.
Nick -
Prior to HTML 5, JavaScript in the browser cannot read files directly from the hard drive - this is done for security reasons:
https://en.wikipedia.org/wiki/JavaScript#Security
In HTML 5 there are new APIs that allow you to get to files. This page has a decent overview:
http://www.html5rocks.com/en/tutorials/file/dndfiles/
I would note that browser support for this is not yet universal:
http://caniuse.com/#feat=fileapi
Assuming you can use the File API you should be able to do what you want after a user selects a file.

Chrome API retrieving most recently downloaded file

Is there a function in the Chrome API that gets the most recently downloaded file?
My goal is to grab this file, copy it, and save it to a different location since in Chrome you cannot change the default download directory for specific file types/websites:
How to set download location via chrome api
Is this idea feasible?
The chrome.downloads API just became stable with Chrome 31. It allows you to deal with all download interactions, like getting the filename and the MIME type. I'm not sure if and how you can copy and move files on the user's system by a Chrome extension.
For your goal you could use the onDeterminingFilename function and alter the filename to contain subdirectories, like putting all .jpg files into Downloads/images/.

Categories