Behavior of UseStreamsDirectly and MemoryStreams

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

chrisbunn
User
Posts: 8
Joined: Thu Feb 03, 2011 2:22 pm

Behavior of UseStreamsDirectly and MemoryStreams

Post by chrisbunn »

I am working with the viewer SDK and passing the PDF document contents from my application into a MemoryStream. I then create an IStreamWrapper and pass it the initialized MemoryStream. The document opens quickly and it appears to work well. I have noted that the memory usage for my application, as shown in the Windows Taskmanager, appears to grow when the document is in the viewer, but when I call CloseDocument the process size does not decrease.

My example:

Code: Select all

mstrPDFDoc = new MemoryStream();

// Load PDF document into mstrPDFDoc ..

IStreamWrapper istr = new IStreamWrapper(mstrPDFDoc);
object varg1 = istr;
vArr[0] = varg1;
vDataIn = vArr;        

object OutPar;
axCoPDFXCview1.SetProperty("Documents.UseStreamsDirectly", 1, 0);
axCoPDFXCview1.DoVerb(null, "OpenDocument", vDataIn, out OutPar, 0);

Am I correct that using Documents.UseStreamsDirectly = 1 will cause the viewer to access the document contents using the iStream and not create a temporary copy on the disk?

What does it mean when the documentation says it will “capture the stream object” and use it for any writes that occur?

When I call “CloseDocument” will it release the resources for the stream (including the memory stream)?


Thanks,
Chris
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3586
Joined: Thu Jul 08, 2004 10:36 pm

Re: Behavior of UseStreamsDirectly and MemoryStreams

Post by Ivan - Tracker Software »

“capture the stream object” means viewer calls AddRef() for the stream when document is open, and calls Release() when document is closed.

I don't know what your IStreamWrapper made, but I guess you have to release it too.
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.