Open PDF for ActiveX-Viewer from stream instead of file

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

EdWin1409
User
Posts: 24
Joined: Tue May 27, 2008 5:50 am

Open PDF for ActiveX-Viewer from stream instead of file

Post by EdWin1409 »

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
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: Open PDF for ActiveX-Viewer from stream instead of file

Post by John - Tracker Supp »

Hi,

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
KennethAa
User
Posts: 18
Joined: Tue Jun 17, 2008 3:37 am

Re: Open PDF for ActiveX-Viewer from stream instead of file

Post by KennethAa »

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
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3586
Joined: Thu Jul 08, 2004 10:36 pm

Re: Open PDF for ActiveX-Viewer from stream instead of file

Post by Ivan - Tracker Software »

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.
KennethAa
User
Posts: 18
Joined: Tue Jun 17, 2008 3:37 am

Re: Open PDF for ActiveX-Viewer from stream instead of file

Post by KennethAa »

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
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: Open PDF for ActiveX-Viewer from stream instead of file

Post by John - Tracker Supp »

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
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
KennethAa
User
Posts: 18
Joined: Tue Jun 17, 2008 3:37 am

Re: Open PDF for ActiveX-Viewer from stream instead of file

Post by KennethAa »

Got the hint I needed, thanks!

Kenneth
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: Open PDF for ActiveX-Viewer from stream instead of file

Post by John - Tracker Supp »

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
EdWin1409
User
Posts: 24
Joined: Tue May 27, 2008 5:50 am

Re: Open PDF for ActiveX-Viewer from stream instead of file

Post by EdWin1409 »

Nice to see that the open and save funcs now support streams.
Will try it out immediately. Many thanks guys, great work

Juergen
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: Open PDF for ActiveX-Viewer from stream instead of file

Post by John - Tracker Supp »

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
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: Open PDF for ActiveX-Viewer from stream instead of file

Post by Dorwol »

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...! :(
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: Open PDF for ActiveX-Viewer from stream instead of file

Post by Dorwol »

Any way to do this?
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: Open PDF for ActiveX-Viewer from stream instead of file

Post by John - Tracker Supp »

Hi,

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
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: Open PDF for ActiveX-Viewer from stream instead of file

Post by Dorwol »

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!
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: Open PDF for ActiveX-Viewer from stream instead of file

Post by Corwin - Tracker Sup »

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.
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: Open PDF for ActiveX-Viewer from stream instead of file

Post by Dorwol »

Have you tried to use ADODB.Stream instead of VBStrm.IStream? Any luck with that?
Yes, no luck! ;-(
Corwin wrote:Anyway, you can always save ADODB.Stream object to file on disk and then load it directly to ViewerAx.
Yes, I know. That's the way I go at this time (but I don't want the detour to HDD!)
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: Open PDF for ActiveX-Viewer from stream instead of file

Post by Corwin - Tracker Sup »

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.
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: Open PDF for ActiveX-Viewer from stream instead of file

Post by Dorwol »

I'm thinking that there must be a way to get/set binary data (array of bytes) from ADODB.Stream.
Yes, that is correct...and I know this way!
This array can be used to create standard IStream.
Yes, I agree with you - but the question is "how"?
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2449
Joined: Thu Jun 30, 2005 4:11 pm

Re: Open PDF for ActiveX-Viewer from stream instead of file

Post by Vasyl - PDF-XChange »

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
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.
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: Open PDF for ActiveX-Viewer from stream instead of file

Post by Corwin - Tracker Sup »

Dorwol wrote:but the question is "how"?
Try to use this procedure:

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
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: Open PDF for ActiveX-Viewer from stream instead of file

Post by Dorwol »

Thx, will try it!
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: Open PDF for ActiveX-Viewer from stream instead of file

Post by Dorwol »

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! :wink:
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: Open PDF for ActiveX-Viewer from stream instead of file

Post by Corwin - Tracker Sup »

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.
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: Open PDF for ActiveX-Viewer from stream instead of file

Post by Dorwol »

Great, this will help me!