Hi,
We are building an application where certain documents get requested a lot. Because they want to view them in PDF’s we use GroupDocs to convert any document to PDF.
Right now the conversion is done via a webApi request, which in turn returns the PDF. Because we know most of our docs will be requested a lot, we’d like to enable caching. However here is where things are going wrong.
Here is what happening:
First request for document A:
Document A gets converted and cache folder get’s created.
Second Request for document A:
Document A cached version get’s returned
First request for Document B:
Document A cached version get’s returned
When looking at the cache folder I see files named i.dat
so I’m thinking that the cache key that’s being generated isn’t working as expected and thus returning the wrong file
This is the code being used:
/// <summary>
/// Renders a document in PDF form
/// </summary>
/// <param name="document">Stream of the document</param>
/// <param name="documentName">Unique name for file</param>
public static RenderResult RenderDocument(Stream document, string documentName)
{
try
{
// Setup Licensing
SetConfigurations();
string filePathFormat = Path.Combine(outputPath, documentName);
outputPath = GeneratorUtilities.OutputPath;
string cachePath = Path.Combine(GeneratorUtilities.OutputPath, GeneratorUtilities.CacheFolder);
FileCache cache = new FileCache(cachePath);
settings = new ViewerSettings(cache);
using (Viewer viewer = new Viewer(() => document, settings))
{
PdfViewOptions options = new PdfViewOptions(filePathFormat);
viewer.View(options);
return new RenderResult(documentName, viewer.GetViewInfo(ViewInfoOptions.ForPngView(false)).Pages.Count);
}
}
catch (Exception e)
{
Log.Error("Wasn't able to render pdf's", e);
throw e;
}
}
Any solutions on fixing this behaviour?