So basically what I want to do is to download a PDF file inside of a Web API from a URL I get as a parameter from the frontend and directly convert said file into a base64 string without saving the file on a file system.
I have already found WebClient.Download(URL, File) but that means, that I have to save the file.
So does anyone know any other solution that could work for me?
You can use below code to download PDF from url into base64 string format.
string pdfUrl = "URL_TO_PDF";
using(WebClient client = new WebClient())
{
var bytes = client.DownloadData(pdfUrl);
string base64String = Convert.ToBase64String(bytes);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With