Currently, I have a controller action that outputs a PDF (as a Response.OutputStream.Write()
) and this is working just as it should.
However, I am interested in outputting another script section along with the PDF to "automatically print" (or simply perform a window.print();
) on the PDF.
Is this possible, or is there another method to solve this issue that I may not be aware of?
Controller Action:
public ActionResult PrintPDF(string ID)
{
//Population of Model
//Output Result
return PdfResult(model);
}
PDF Result:
var buffer = byteArrayStream.toByteArray();
response.OutputStream.Write(buffer, 0, buffer.Length);
//Is it possible to output something like the following:
response.Output.Write("<script type='text/javascript'>window.print();</script>");