Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AcroPDFLib to open PDF file from stream in WindowsForms C# .NET

I've spent the whole afternoon looking for an answer to my question and found none :(

I'm making a windows forms application and one of it's features is to show files stored in a DB. This files, upon upload, can be marked as "read-only", meaning they cannot be downloaded. At this point, I'm struggling with PDF files. I'm using the AcroPDFLib and I can't find a way to display the file from the byte array stored in the DB.

So, my question is, is there a way to open a PDF file from a stream? Even if it's a plugin, what plugin is that and where can I find it?

Using the web browser object, I don't think it will work since I would have to create something server-side that sends to the response output the stream. And creating the file in a temporary folder... well, in that case I might as well allow the file download :D

Thanks for your help

like image 234
Nuno Carvalho Avatar asked Oct 04 '22 09:10

Nuno Carvalho


1 Answers

In order to do what you want, you need to open the file from a memory stream, however from the Interapplication Communication API reference from Adobe we get that there is only one Open(...) method:

Syntax:
VARIANT_BOOL Open(BSTR szFullPath, BSTR szTempTitle);

Parameters:

szFullPath
The full path of the file to open.

szTempTitle
An optional title for the window in which the file is opened. If szTempTitle is NULL or the empty string, it is ignored. Otherwise, szTempTitle is used as the window title.

So I would guess that what you are trying to do cannot be done with Adobe's library.

like image 171
yms Avatar answered Oct 07 '22 00:10

yms