1

Unlike the webapplication I would like to view pdf contents without storing it at physical location. I have bytes of array just need to display it in as pdf format.

below code works for webapplication but I am looking for windows console application.

Response.Clear();
Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Disposition", "inline;filename=data.pdf");
Response.BufferOutput = true;
byte[] pdf;
Response.AddHeader("Content-Length", response.Length.ToString());
Response.BinaryWrite(pdf);
Response.End();

1 Answers1

0

I only see two options here. Unfortunately, one of them isnt feasible and the other one doesnt exactly fit your criterions. Let's see:

  1. Write a PDF interpretor. Obviously, this cannot be done easily, but it is the only way to get rid of files. Why? Because typical applications are not designed to receive some .Net stream or byte array, they take file path and read them the way they want.
  2. Add some third party PDF reader. This Q/A should cover what you need. As mentionned, this solution wont be a perfect fit since it will need you to at least save the file to a temporary location. Let's say you use Acrobat or Foxit, you cannot pass a stream directly, they need a file path.

EDIT: Why do you want to avoid writing a file? If you draw the big picture, we might be able to figure a way arround your problem.

Community
  • 1
  • 1