Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- byte[] theData = doc.GetData();
- Response.ClearHeaders();
- Response.ClearContent();
- Response.Expires = -1000;
- Response.ContentType = "application/pdf";
- Response.AddHeader("content-length", theData.Length.ToString());
- Response.AddHeader("content-disposition", "attachment; filename=test.pdf");
- Response.BinaryWrite(theData);
- HttpContext.Current.ApplicationInstance.CompleteRequest();
- 'HttpResponse' does not contain a definition for 'ClearHeaders'
- 'HttpResponse' does not contain a definition for 'ClearContent'
- 'HttpResponse' does not contain a definition for 'Expires'
- 'HttpResponse' does not contain a definition for 'AddHeader'
- 'HttpResponse' does not contain a definition for 'BinaryWrite'
- 'HttpContext' does not contain a definition for 'Current'
- [Route("api/[controller]")]
- public class PDFController : Controller {
- // GET: api/<controller>
- [HttpGet]
- public IActionResult Get() {
- using (Doc theDoc = new Doc()) {
- theDoc.FontSize = 96;
- theDoc.AddText("Hello World");
- Response.Headers.Clear();
- Response.Headers.Add("content-disposition", "attachment; filename=test.pdf");
- return new FileStreamResult(theDoc.GetStream(), "application/pdf");
- }
- }
- }
Add Comment
Please, Sign In to add comment