This is an archived forum post. The information may be outdated. Contact us if you have any questions.

How can i Save pdf File int the folder on the server?

Arash_jahan wrote on 2016-02-22:

hello my friends

this is my code in C# :

protected void btnPDF_OnServerClick(object sender, EventArgs e)
System.Web.HttpResponse Response = System.Web.HttpContext.Current.Response;
// create an API client instance
pdfcrowd.Client client = new pdfcrowd.Client("username", "password");

// convert a web page and write the generated PDF to a memory stream

MemoryStream Stream = new MemoryStream();
string urll = HttpContext.Current.Request.Url.AbsoluteUri;
client.convertURI(urll, Stream);

// set HTTP response headers
Response.AddHeader("Content-Type", "application/pdf");
Response.AddHeader("Cache-Control", "max-age=0");
Response.AddHeader("Accept-Ranges", "none");
Response.AddHeader("Content-Disposition", "attachment; filename=mspsoft_com.pdf");

// send the generated PDF
catch (pdfcrowd.Error why)
Actually i want to save pdf file on a servers folder and i dont want to download file .
But I dont know .....
please help me .
thank you.
support wrote on 2016-02-22:

The following code saves PDF to a local file
FileStream fileStream = new FileStream("c:/report_dir/report.pdf", FileMode.CreateNew);
client.convertURI("", fileStream);
Arash_jahan wrote on 2016-02-22:
thank you
but i want to save pdf in server Online.
what must i do Now?
support wrote on 2016-02-24:

What exactly do you mean by "to save pdf in server Online"?
kalarasaa76 wrote on 2016-10-10:
I want this code sample to Php