Free Support Forum - groupdocs.com

Advice for usnig ViewerHtmlHelper.GetDocumentInfo() when HTML is cached

Hello,

We have implemented the ICacheDataHandler and IInputDataHandler to store our cached document HTML in S3. When we call ViewerHtmlHelper.GetDocumentHtml() to get the document info (on the initial cache generation and later to render the pages) we use the overload that takes a stream.

We are storing the cache state of each file in our own database, so I’d like to avoid having to re-read the source document stream just to get the number of pages. We could read the fd.xml file directly, but would prefer to use your API for this purpose.

Is there a way I can get the cached results from GetDocumentInfo() without it having to parse the source file again? I know from implementing the ICacheDataHandler that it eventually uses ICacheDataHandler.Exists() to find out if it already has fd.xml for the doc - but it overwrites it again later - suggesting that when a document is cached, GetDocumentInfo() repeats some of the work.

If I know it’s cached already, can I pass just the file information into one of the other GetDocumentInfo() overloads? I’m thinking that I need to use this overload:
public DocumentInfoContainer GetDocumentInfo(
string guid,
DocumentInfoOptions documentInfoOptions
)

Your assistance will be greatly appreciated.

Thanks,
Darryl.

@dbaker1,

Thanks for using GroupDocs.Viewer and sharing your concern with us.

I am afraid that there is no overload of GetDocumentInfo method to get the cached information of a document without processing the source document. The fact is the API checks the source document each time we call GetDocumentInfo because there might be the possibility that the source document is changed and in that case, the cached information may differ from the original document.

However, you can get the cached document information manually without accessing the source document. You can download this sample application that demonstrates an easy and fast way to get document information directly from the cache. Hope it helps.

Thanks. I’ll have a look at that sample.

@dbaker1,

Sure.