Results 1 to 11 of 11

Thread: [1.0/1.1] Open Adobe Reader with MemoryStream

  1. #1

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    [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.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

  3. #3

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    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.
    Last edited by GlenW; Jul 16th, 2006 at 12:34 PM.

  4. #4
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    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.
    I don't live here any more.

  5. #5

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    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.

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

  7. #7

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    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.

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

  9. #9

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    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().

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  11. #11

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width