How to show pre-cached documents in the viewer ?
Question asked by Iulian Bercovici - 12/9/2019 at 8:33 AM
I couldn't find any code sample that showes how to display, or show in the viewer a pre-cached document.
Is there any code samples for that ?

3 Replies

Reply to Thread
Cem Alacayir Replied
Employee Post
You pass the same parameters (via DocumentOptions) to the DocumentViewer as you passed to DocumentCache then viewer "knows" it's the same document and loads it from the cache. So if you used DocumentOptions.Document property then you set the same value for DocumentViewer. 

For example for files on disk, the cache unique ID is calculated as a string combination of file extension, file size and file date . This way cache collisions do not occur and we can reuse the cached file even if the file name before extension is changed (because it's still the same document).

If you provided a custom unique ID, then provide the same to DocumentViewer.
Iulian Bercovici Replied
I'm using stream for pre-caching, not file path.
Is it the same for stream ?
Cem Alacayir Replied
Employee Post Marked As Answer
Yes same for the stream. However if you are sure the document will be always in the cache, you can pass an empty stream e.g. new MemoryStream(), because stream will be accessed only if the cache item does not exist with the corresponding cache id.

You can also implement IDocumentHandler interface and use it for both your pre-caching application and viewer web application:

Reply to Thread