Hi,
This example retrieves a pdf document.
How can I save the data as a pdf file to disk?
Thanks
string jsonResponse ;
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(string uri);
webRequest.Method = "GET";
webRequest.Accept = "application/pdf";
using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse())
{
using (StreamReader reader = new StreamReader(webResponse.GetResponseStream()))
{
jsonResponse = reader.ReadToEnd();
}
}
Marvin ReidPosted Feb 27, 2023, 6:11 PM
You can take a stream and convert it to PDF using the DocumentConverter class. Here is an example that you can build on:
https://www.leadtools.com/help/sdk/v22/tutorials/dotnet-console-convert-files-with-the-document-converter.html
Upendra Pratap ShahiPosted Jun 25, 2015, 1:24 AM
Manoj BhoirPosted Jun 25, 2015, 1:04 AM
webRequest.Method = "GET";
webRequest.Accept = "application/pdf";
using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse())
{
Stream objStream = webResponse.GetResponseStream();
using (var fileStream = new FileStream("Path To Save File", FileMode.Create, FileAccess.Write))
{
objStream.CopyTo(fileStream);
}
}