T
Tom Vergote
Hello world,
I'm running into an issue where I would like to save the response stream as
an html file on the server (and convert it to a pdf)
I've tried putting a streamreader on the outputstream like in the following
code, but the stream doesn't seem to be readable
Is there any way to do this?
--- CODE----
string path = Server.MapPath("testfile.html");
StringWriter sw = new StringWriter();
StreamWriter sWriter = File.CreateText(path);
sWriter.WriteLine(sw.ToString());
StreamReader sr = new StreamReader(Response.OutputStream);
sWriter.Write(sr.ReadToEnd());
sWriter.Close();
string pdf = Run(path); // THIS SHOULD CONVERT TO PDF
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "Application/pdf";
try
{
Response.WriteFile( MapPath( pdf ) );
Response.Flush();
Response.Close();
}
catch (Exception ex)
{
Response.ClearContent();
}
-----/CODE-------
I'm running into an issue where I would like to save the response stream as
an html file on the server (and convert it to a pdf)
I've tried putting a streamreader on the outputstream like in the following
code, but the stream doesn't seem to be readable
Is there any way to do this?
--- CODE----
string path = Server.MapPath("testfile.html");
StringWriter sw = new StringWriter();
StreamWriter sWriter = File.CreateText(path);
sWriter.WriteLine(sw.ToString());
StreamReader sr = new StreamReader(Response.OutputStream);
sWriter.Write(sr.ReadToEnd());
sWriter.Close();
string pdf = Run(path); // THIS SHOULD CONVERT TO PDF
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "Application/pdf";
try
{
Response.WriteFile( MapPath( pdf ) );
Response.Flush();
Response.Close();
}
catch (Exception ex)
{
Response.ClearContent();
}
-----/CODE-------