I currently have a controller action that successfully generates and outputs a PDF using Response.OutputStream.Write()
. Everything is functioning as expected.
However, I am interested in adding another scripting section to automatically print the PDF (using window.print();
) when it is generated. Is there a way to achieve this, or perhaps an alternative solution available?
Controller Action:
public ActionResult PrintPDF(string ID)
{
// Create Model
// Output Result
return PdfResult(model);
}
PDF Result:
var buffer = byteArrayStream.toByteArray();
response.OutputStream.Write(buffer, 0, buffer.Length);
// How can I include something like this:
response.Output.Write("<script type='text/javascript'>window.print();</script>");