How to download a file from dropbox using Javascript - javascript

I have a pdf file stored in dropbox. I have an URL to access that pdf file. The format of the URL is something like this https://www.dropbox.com/s/myPDF.pdf.
Now I need to use this URL in my angular application to download that PDF file and show it's content.
I need to display the pdf in the same webpage as my application. I used tag for achieving this. But I got the error saying Refused to display the pdf in a frame because it set 'X-Frame-Options' to 'SAVEORIGIN'.
I am new to dropbox. I need to know how to download this pdf and show it's content in my angular application by using the URL given above.

I understand your problem buddy. You dont need javascript for this, it can be done with simple and "anchor" tags.
Write the code as follows:
<a href="https://www.dropbox.com/s/myPDF.pdf">
<button>Download pdf</button>
</a>
Now, when the user clicks the button, the file will be downloaded.

Related

Angular : Save editable PDF data using angular/javascript?

Html:
<iframe [src] ="fileurl" #iframe>
</iframe>
<button (click)="saveDoc()">
</button>
Stuck at savedoc() functionality.
Typescript:
/*api call to get document blob data on load*/
var fileurl = new blob([res.body],{type:application/pdf});
fileurl = URL.createObjectUrl(fileurl);
savedoc(){//here need logic to access edited pdf content as blob }
I am able to view and write in pdf editable fields (as input or checkboxes) but I can't figure out once filled all details, how to save/access that edited PDF content (mostly in blob format) to send back to server when click on save button. I have also tried ng2-pdf-viewer library of npm but same issue. I have to send this edited pdf to server in blob format to replace with existing.
How can I access edited pdf content?
Edited: Alternative approach, if its possible to trigger saveAs event from code to save iFrame pdf in local drive? I am using Window.showSaveFilePicker();but saved file seem corrupted or not exist.
Have a look at PDF-LIB.
It is a great JavaScript library which provides all sorts of tools to manipulate PDF documents. There is even tooling for filling the fields and saving the newly filled PDF.
In a past project, I used this library to capture user information from an HTML form and have it inserted and saved into a PDF.
Note:
Remember that once you have the filled PDF on client side, you must send it back to server side to update the PDF that is stored on the server.

Url for Force Download PDF on Webview

How to make URL/link for force download pdf on webview
example url/link like this :
mytableview.php?export=pdf&id=4&custom=1&=?download
I try to add =?download
This can't force download (I mean can not auto-save)
Thanks
You can not just get PDF out of HTML. There should be some code on a backend which will translate the HTML content into PDF page.
https://pdfcrowd.com/blog/convert-html-to-pdf-in-php/
here is an example how other developer have achieve it. There also should be also ready php lib that you can use.
Once PDF is generated then you can attempt to dowload it using a download lib.

How do I write a function to autodownload pdf files from a link without navigating to another webpage either in java script or html

I am trying to implement the auto download feature in my web application where when clicked on a button a pdf file should download. I have the link but I am not able to download the file . I have used http get also and ionic file transfer plugin but neither of them are working. Can anyone help me write a code that does this task?
You can use the new download attribute for elements (new in HTML5). The following is from "https://www.w3schools.com/tags/att_a_download.asp"
"Specify a value for the download attribute, which will be the new filename of the downloaded file ("myFile.pdf" instead of "sampleFile.pdf"):"
Download PDF
Download PDF

Workaround for Error 414 when opening file from PHP script

I have a PHP script that's outputting a CSV file and up until now I've been just using a link and passing parameters that are used to determine the output in the GET data. However recently the size of the data increased and now that code gets Error 414 - Request URI too Large. I tried using a hidden form to do it with POST but it just reloaded the page and didn't supply a prompt to download the file and all of the suggestions I've been able to find online about doing it with AJAX suggest using a link with GET data instead. Does anyone know a workaround that will have the browser still let the user easily download the data?
Presently I'm just setting the href attribute of a <a> tag.
$("#exportCSV").attr('href', "myscript.php/?data=" + exportData);
exportData has become too long for GET data but I want to maintain the behavior where if you click on a link that has say a CSV file being outputted the browser provides a download dialog for the user.

How to check pdf->security->print option using php or jquery code for the uploaded pdf

In my application user uploads pdf files ,and i need to check(dynamically) that the uploaded pdf file->security options like printing option is set to allowed or not allowed to move further in my application using php or javascript coding.if the pdf file allows the printing i need to extact pages from it if not i need to throw a error to the user that pdf wont support printing??
Searched alot in google but ended up with no solution?
Any suggestions?

Categories

Resources