0

I want to open a PDF file from a MemoryStream.

I am using this code

System.Diagnostics.Process.Start(filepath);

In the above code if I pass the file path as a argument, then it works fine and my PDF file is also opened in the default reader. But I don't want to store the file on the hard drive. I want just open it from my MemoryStream.

How can we open a file from MemoryStream?

venerik
  • 5,766
  • 2
  • 33
  • 43
Jatin Gadhiya
  • 1,955
  • 5
  • 23
  • 42
  • 3
    Possible duplicate of [Read a stored PDF from memory stream](http://stackoverflow.com/questions/29030723/read-a-stored-pdf-from-memory-stream) –  Nov 11 '15 at 06:42
  • @Micky.. let me check your suggested. – Jatin Gadhiya Nov 11 '15 at 06:57
  • @Micky.. I've seen answer and found comment " // Load PDF Document into WinForms Control". But i am using asp.net mvc not a winform. can please look on it – Jatin Gadhiya Nov 11 '15 at 07:07
  • In that case your question is unclear and you really can't use `Process.Start`. Have a look at [Force browser to download pdf document](http://stackoverflow.com/questions/8590543/force-browser-to-download-pdf-document-instead-of-opening-it) – venerik Nov 11 '15 at 07:09
  • @Force.. sorry for confusion. see we have file in memoryStream. now we are storing into local and then we're opening file using process.start. But now we don't want to store in local. we want to open from memoryStream. or do you have idea about promt in browser as a like download pdf. we have download url from azure. – Jatin Gadhiya Nov 11 '15 at 07:27
  • This won't always work, because not every pdf viewer will support loading pdf content from a memory stream. I.e. Even if you got it working for one viewer it won't necessarily work for another/others. – Don Nov 11 '15 at 10:19
  • So is it compulsory to save in local? then an only we can open PDF from local. – Jatin Gadhiya Nov 11 '15 at 10:21
  • Yes, That is the guaranteed and only way, if you want to support the default (any pdf) viewer on the OS. – Don Nov 11 '15 at 10:26

0 Answers0