[1.0/1.1] Open Adobe Reader with MemoryStream
Does anyone know if it is possible to open Adobe Reader and have a PDF displayed that comes from a memory stream?
I don't want to create any files, so I just want to get the PDF as a byte[] then use a memory stream to load it into Reader. Users can then save it where they want.
This is in a Windows application, Web is easy just Response.Write() it.
Re: [1.0/1.1] Open Adobe Reader with MemoryStream
No matter what you do, the PDF will be downloaded to the client's machine before it is rendered. So even when you Response.Write() it, it goes to the client's temporary internet files folder and is then displayed.
You could consider the same, save to a temporary folder, and System.Diagnostics.Process.Start() it.
Re: [1.0/1.1] Open Adobe Reader with MemoryStream
Quote:
Originally Posted by mendhak
No matter what you do, the PDF will be downloaded to the client's machine before it is rendered. So even when you Response.Write() it, it goes to the client's temporary internet files folder and is then displayed.
You could consider the same, save to a temporary folder, and System.Diagnostics.Process.Start() it.
This is for a Windows application. There is no file at present and I don't want to create one, I realise I may have to if I can't figure out how to display the byte[] in Reader.
In Web applications you don't need to create a file from the byte[] to send it to the client, you can just read it from the database and send it. I realise it is then made into a file and held in Temporary Internet files on the client.
Re: [1.0/1.1] Open Adobe Reader with MemoryStream
Why are you so phobic about storing a file on the disk? You could always stick it somewhere it won't get noticed. Are these PDF's really HUGE? In which case memory streams are a bad idea anyway.
Re: [1.0/1.1] Open Adobe Reader with MemoryStream
Quote:
Originally Posted by wossname
Why are you so phobic about storing a file on the disk? You could always stick it somewhere it won't get noticed. Are these PDF's really HUGE? In which case memory streams are a bad idea anyway.
None of the PDFs will be larger then a single A4 sheet. I'm not phobic about storing them as files, if it was up to me I'd simply overwrite one file everytime, show it in Reader and let the user do what they want with it. However, it isn't up to me, the spec asks for no file to be created unless the user specifies that they want to save it! I may get away with creating a file then deleting it afterwards.
Would be nice to try and figure out how to do what I wanted though.
Re: [1.0/1.1] Open Adobe Reader with MemoryStream
Quote:
Originally Posted by GlenW
In Web applications you don't need to create a file from the byte[] to send it to the client, you can just read it from the database and send it. I realise it is then made into a file and held in Temporary Internet files on the client.
And so you've answered your own question. Your only way is assume the user has, or, make the user get the Acrobat Plugins for their browser, which can then handle the PDF file which will be saved to Temporary Internet Files no matter what.
I'm not sure who made the specs but either they were ignorant about this matter, or they meant that the file should be displayed directly rather than downloaded.
Keep in mind, a browser is a 'graphical' download client. Almost everything you see on a page is downloaded.
Re: [1.0/1.1] Open Adobe Reader with MemoryStream
Quote:
Originally Posted by mendhak
And so you've answered your own question. Your only way is assume the user has, or, make the user get the Acrobat Plugins for their browser, which can then handle the PDF file which will be saved to Temporary Internet Files no matter what.
I'm not sure who made the specs but either they were ignorant about this matter, or they meant that the file should be displayed directly rather than downloaded.
Keep in mind, a browser is a 'graphical' download client. Almost everything you see on a page is downloaded.
This is not a web application!
There is no downloading of any files!
The byte[] is retieved from a database.
There is no need to use Acrobat Plugins, the user has Reader installed.
Re: [1.0/1.1] Open Adobe Reader with MemoryStream
I understand. I was explaining what you could do to come close to what you want. I should've mentioned that you ought to embed a web browser control into your application. :)
Get it now?
If you only want to use the Reader, then you'll have to download the file somewhere. And then use Process.Start() to open it up. There may be a way to determine when the user has closed the application after which you can delete the file. But as for your original specification, you must download it to the user's computer.
Re: [1.0/1.1] Open Adobe Reader with MemoryStream
I've written web applications that use a proxy page to write images, so I can retrieve jpegs from image fields in SQL Server. Then I can set Image controls url to the proxy web page. That way there is no need to have the jpeg files on the server. I realise they still go to the client. I was hoping I could something similar with Process.Start().
Re: [1.0/1.1] Open Adobe Reader with MemoryStream
When you're using a browser the files are downloaded to a temporary location and opened from there. If you're using a Windows app then you'll have to do the same. That's what the user's Temp directory is for. Save the file to the user's Temp folder, use Process.Start to open it, then handle the Exited event of the Process object you create to know when it has closed so you can delete the temp file.
Re: [1.0/1.1] Open Adobe Reader with MemoryStream
Quote:
Originally Posted by jmcilhinney
When you're using a browser the files are downloaded to a temporary location and opened from there. If you're using a Windows app then you'll have to do the same. That's what the user's Temp directory is for. Save the file to the user's Temp folder, use Process.Start to open it, then handle the Exited event of the Process object you create to know when it has closed so you can delete the temp file.
That's what I'll have to do. I'm going to try and use Process.Start and give it the url of a web page that writes the byte[], just to see what happens. I'm going to try it tomorrow, I need sleep now.