I need to program an api that has 3 parts:
- Get the pdf file from pdf url.
- Converting the pdf.
- Return the converted pdf file.
I have already completed part 2 and 3, What left is to fetch the pdf from url and copy/download it to my mvc web api.
This is the test html code:
< script >
$('#btnSendRequest').on('click', function() {
$.ajax({
type: "POST",
url: "/Convertor/Html",
data: {
strUrl: "http://make-sense.co.il/kb/avcp-script-installation.pdf"
},
success: function(data) {
return true;
},
});
}); < /script>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<title>tester</title>
</head>
<body>
<h1>tester html</h1>
<div>
<input id="btnSendRequest" type="button" value="SendHttpRequest" />
</div>
My ActionResult function: "convertor/html" , gets the url string from the web page. What I need is when I click the button, the pdf file will be automatically download to my server.
public ActionResult Html(string strUrl)
{
return View();
}
Anyone has any idea how that can be done? I also read somewhere on something called base64 encoding that might be also the solution, but I have never used it before.
Thanks in advance.