Open PDF for ActiveX-Viewer from stream instead of file
Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange
-
- User
- Posts: 24
- Joined: Tue May 27, 2008 5:50 am
Open PDF for ActiveX-Viewer from stream instead of file
Hi,
is it possible to open a pdf from a memory-stream instead of a file on disk drive ?
Background : I use your components as a frontend to a large DMS. The DMS returns the documents as memory streams, so I have to save the stream to a file and reopen it via activeX-control. This is no good practice for two reasons. First, unnecessary i/o operations and second, security reasons. I would not give the end user the possibility to get a 'real' pdf file. If I could use only memory streams, it`s much harder to get the pdf data.
I use C# with .net Framework 3.5
Thanks,
Jürgen
is it possible to open a pdf from a memory-stream instead of a file on disk drive ?
Background : I use your components as a frontend to a large DMS. The DMS returns the documents as memory streams, so I have to save the stream to a file and reopen it via activeX-control. This is no good practice for two reasons. First, unnecessary i/o operations and second, security reasons. I would not give the end user the possibility to get a 'real' pdf file. If I could use only memory streams, it`s much harder to get the pdf data.
I use C# with .net Framework 3.5
Thanks,
Jürgen
-
- Site Admin
- Posts: 5223
- Joined: Tue Jun 29, 2004 10:34 am
Re: Open PDF for ActiveX-Viewer from stream instead of file
Hi,
this is not currently possible - however we hope to add this ability in the next release in approx 20-14 days time
this is not currently possible - however we hope to add this ability in the next release in approx 20-14 days time
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.
Best regards
Tracker Support
http://www.tracker-software.com
Best regards
Tracker Support
http://www.tracker-software.com
-
- User
- Posts: 18
- Joined: Tue Jun 17, 2008 3:37 am
Re: Open PDF for ActiveX-Viewer from stream instead of file
Hi,
Am I just missing something here, or was this feature not included in build 38?
It's mentioned in the end user viewer history: https://www.pdf-xchange.com/home/pr ... r/history/
But I can't find any support for this in the interface definitions..
With regards,
Kenneth
Am I just missing something here, or was this feature not included in build 38?
It's mentioned in the end user viewer history: https://www.pdf-xchange.com/home/pr ... r/history/
But I can't find any support for this in the interface definitions..
With regards,
Kenneth
-
- Site Admin
- Posts: 3586
- Joined: Thu Jul 08, 2004 10:36 pm
Re: Open PDF for ActiveX-Viewer from stream instead of file
Please see documentaion for Named operations: OpenDocument and SaveDocument.
PDF-XChange Co Ltd. (Project Director)
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
-
- User
- Posts: 18
- Joined: Tue Jun 17, 2008 3:37 am
Re: Open PDF for ActiveX-Viewer from stream instead of file
I did, and have rechecked.
And as far as I can see, both in the documentation and in idl viewed with oleview, there is no support for loading/saving with a memory array or the IStream COM interface.
Are we talking about different things here?
With regards,
Kenneth
And as far as I can see, both in the documentation and in idl viewed with oleview, there is no support for loading/saving with a memory array or the IStream COM interface.
Are we talking about different things here?
With regards,
Kenneth
-
- Site Admin
- Posts: 5223
- Joined: Tue Jun 29, 2004 10:34 am
Re: Open PDF for ActiveX-Viewer from stream instead of file
Hi Kenneth,
my colleague was unaware that the SDK Doc's are still in progress for build 38, though we have released the ActiveX - these will be available tomorrow AM.
In the meantime - please see attached which are not fully proof read/corrected.
Hope that helps
my colleague was unaware that the SDK Doc's are still in progress for build 38, though we have released the ActiveX - these will be available tomorrow AM.
In the meantime - please see attached which are not fully proof read/corrected.
Hope that helps
You do not have the required permissions to view the files attached to this post.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.
Best regards
Tracker Support
http://www.tracker-software.com
Best regards
Tracker Support
http://www.tracker-software.com
-
- User
- Posts: 18
- Joined: Tue Jun 17, 2008 3:37 am
Re: Open PDF for ActiveX-Viewer from stream instead of file
Got the hint I needed, thanks!
Kenneth
Kenneth
-
- Site Admin
- Posts: 5223
- Joined: Tue Jun 29, 2004 10:34 am
Re: Open PDF for ActiveX-Viewer from stream instead of file
Pleasure 

If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.
Best regards
Tracker Support
http://www.tracker-software.com
Best regards
Tracker Support
http://www.tracker-software.com
-
- User
- Posts: 24
- Joined: Tue May 27, 2008 5:50 am
Re: Open PDF for ActiveX-Viewer from stream instead of file
Nice to see that the open and save funcs now support streams.
Will try it out immediately. Many thanks guys, great work
Juergen
Will try it out immediately. Many thanks guys, great work
Juergen
-
- Site Admin
- Posts: 5223
- Joined: Tue Jun 29, 2004 10:34 am
Re: Open PDF for ActiveX-Viewer from stream instead of file
Pleasure Juergen 

If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.
Best regards
Tracker Support
http://www.tracker-software.com
Best regards
Tracker Support
http://www.tracker-software.com
-
- User
- Posts: 275
- Joined: Mon Aug 04, 2008 5:04 pm
Re: Open PDF for ActiveX-Viewer from stream instead of file
Please can you give me a little sample-code for VB6 OR a link to any documentation about this feature?
I dont understand how to load or save it to a stream/array.
In help-PDF (on page 30 or page 95) I found "save to disc" only...!
I dont understand how to load or save it to a stream/array.
In help-PDF (on page 30 or page 95) I found "save to disc" only...!

-
- User
- Posts: 275
- Joined: Mon Aug 04, 2008 5:04 pm
Re: Open PDF for ActiveX-Viewer from stream instead of file
Any way to do this?
-
- Site Admin
- Posts: 5223
- Joined: Tue Jun 29, 2004 10:34 am
Re: Open PDF for ActiveX-Viewer from stream instead of file
Hi,
Here is the updated Manual - please see indexed page 34 (39 of the physical file)
HTH
Here is the updated Manual - please see indexed page 34 (39 of the physical file)
HTH
You do not have the required permissions to view the files attached to this post.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.
Best regards
Tracker Support
http://www.tracker-software.com
Best regards
Tracker Support
http://www.tracker-software.com
-
- User
- Posts: 275
- Joined: Mon Aug 04, 2008 5:04 pm
Re: Open PDF for ActiveX-Viewer from stream instead of file
Sorry, but I do not succeed.
I do not manage to submit the IStream to and from a ADO-Data-Object.
And also I do not find any documentation of Eduardo's-"STRM.tlb"-Typelibrary. So I dont know how to put the content of "VBStrm.IStream" to "ADODB.Stream"...!?
What I want is to save/load the PDF to and from a sql-database (blob-/image-object of SQL-Server).
PLEASE, is it possible to give me a little sample-code in VB6?
Very big thanks!

I do not manage to submit the IStream to and from a ADO-Data-Object.
And also I do not find any documentation of Eduardo's-"STRM.tlb"-Typelibrary. So I dont know how to put the content of "VBStrm.IStream" to "ADODB.Stream"...!?
What I want is to save/load the PDF to and from a sql-database (blob-/image-object of SQL-Server).
PLEASE, is it possible to give me a little sample-code in VB6?

Very big thanks!
-
- User
- Posts: 664
- Joined: Tue Nov 14, 2006 12:23 pm
Re: Open PDF for ActiveX-Viewer from stream instead of file
Sorry, but I'm not familiar with "ADODB.Stream" and can't check projects which uses ADO-Data-Object here.
Have you tried to use ADODB.Stream instead of VBStrm.IStream? Any luck with that?
Anyway, you can always save ADODB.Stream object to file on disk and then load it directly to ViewerAx.
Have you tried to use ADODB.Stream instead of VBStrm.IStream? Any luck with that?
Anyway, you can always save ADODB.Stream object to file on disk and then load it directly to ViewerAx.
-
- User
- Posts: 275
- Joined: Mon Aug 04, 2008 5:04 pm
Re: Open PDF for ActiveX-Viewer from stream instead of file
Yes, no luck! ;-(Have you tried to use ADODB.Stream instead of VBStrm.IStream? Any luck with that?
Yes, I know. That's the way I go at this time (but I don't want the detour to HDD!)Corwin wrote:Anyway, you can always save ADODB.Stream object to file on disk and then load it directly to ViewerAx.
-
- User
- Posts: 664
- Joined: Tue Nov 14, 2006 12:23 pm
Re: Open PDF for ActiveX-Viewer from stream instead of file
I'm thinking that there must be a way to get/set binary data (array of bytes) from ADODB.Stream. This array can be used to create standard IStream.
-
- User
- Posts: 275
- Joined: Mon Aug 04, 2008 5:04 pm
Re: Open PDF for ActiveX-Viewer from stream instead of file
Yes, that is correct...and I know this way!I'm thinking that there must be a way to get/set binary data (array of bytes) from ADODB.Stream.
Yes, I agree with you - but the question is "how"?This array can be used to create standard IStream.
-
- Site Admin
- Posts: 2449
- Joined: Thu Jun 30, 2005 4:11 pm
Re: Open PDF for ActiveX-Viewer from stream instead of file
Possible solution for you:
Open document:
1. Create empty, memory-IStream object by CreateStreamOnHGlobal(NULL, TRUE, StreamOut);
2. Load binary data from ADODB.Stream into this memory-IStream.
3. Pass filled IStream-object to our 'OpenDocument' routine.
Save document:
1. Create empty, memory-IStream object by CreateStreamOnHGlobal(NULL, TRUE, StreamOut);
2. Pass this IStream-object to our 'SaveDocument(DocID)' routine.
3. Copy all content from this IStream-object to ADODB.Stream
Open document:
1. Create empty, memory-IStream object by CreateStreamOnHGlobal(NULL, TRUE, StreamOut);
2. Load binary data from ADODB.Stream into this memory-IStream.
3. Pass filled IStream-object to our 'OpenDocument' routine.
Save document:
1. Create empty, memory-IStream object by CreateStreamOnHGlobal(NULL, TRUE, StreamOut);
2. Pass this IStream-object to our 'SaveDocument(DocID)' routine.
3. Copy all content from this IStream-object to ADODB.Stream
PDF-XChange Co. LTD (Project Developer)
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
-
- User
- Posts: 664
- Joined: Tue Nov 14, 2006 12:23 pm
Re: Open PDF for ActiveX-Viewer from stream instead of file
Try to use this procedure:Dorwol wrote:but the question is "how"?
Code: Select all
Private Declare Function CreateStreamOnHGlobal Lib "ole32" (ByVal hGlobal As Long, ByVal fDeleteOnRelease As Long, ppstm As Any) As Long
.........
Public Sub BytesToStream(b() As Byte)
Dim LowerBound As Long
Dim ByteCount As Long
Dim hMem As Long
Dim lpMem As Long
Dim istm As VBStrm.IStream
On Error GoTo Err_Lbl
If UBound(b, 1) < 0 Then
Exit Sub
End If
LowerBound = LBound(b)
ByteCount = (UBound(b) - LowerBound) + 1
hMem = GlobalAlloc(&H2, ByteCount)
If hMem <> 0 Then
lpMem = GlobalLock(hMem)
If lpMem <> 0 Then
CopyMemory ByVal lpMem, b(LowerBound), ByteCount
Call GlobalUnlock(hMem)
If CreateStreamOnHGlobal(hMem, 1, istm) = 0 Then
...........
End If
End If
End If
Exit Sub
Err_Lbl:
MsgBox "Error"
End Sub
-
- User
- Posts: 275
- Joined: Mon Aug 04, 2008 5:04 pm
Re: Open PDF for ActiveX-Viewer from stream instead of file
Thx, will try it!
-
- User
- Posts: 275
- Joined: Mon Aug 04, 2008 5:04 pm
Re: Open PDF for ActiveX-Viewer from stream instead of file
Corwin, U are my HERO!
THANK YOU VERY VERY MUCH!
It WORKS FANTASTIC!
A question is still left now. How does the reversed way go? (I mean "StreamToBytes")...
If you should still have a tip for it for me, this would be wonderful. If not, you are nevertheless my hero!
THANK YOU VERY VERY MUCH!
It WORKS FANTASTIC!
A question is still left now. How does the reversed way go? (I mean "StreamToBytes")...
If you should still have a tip for it for me, this would be wonderful. If not, you are nevertheless my hero!

-
- User
- Posts: 664
- Joined: Tue Nov 14, 2006 12:23 pm
Re: Open PDF for ActiveX-Viewer from stream instead of file
Nice to know, that previous solution helped you 
VBStrm.IStream has methods Stat(where you can get size of stream) and Read(to get bytes from stream). You can try to use these methods to get bytes array from IStream.
For more information of how to use IStream you can read at msdn.

VBStrm.IStream has methods Stat(where you can get size of stream) and Read(to get bytes from stream). You can try to use these methods to get bytes array from IStream.
For more information of how to use IStream you can read at msdn.
-
- User
- Posts: 275
- Joined: Mon Aug 04, 2008 5:04 pm
Re: Open PDF for ActiveX-Viewer from stream instead of file
Great, this will help me!