Viewer is not rendering all pages on Azure deployment. It works fine when running local the first debug time through, then the local also stops rendering any page after 1. Rendering pages also takes a significant amount of time using embedded resources.
Please provide accurate sample code to render an entire document, regardless of type to the viewer. We do not have the option to use pagination or cache as these are classified documents, and the URLs cannot be exposed publicly so all data must be sent back via the API.
It appears as though sometimes the logic to returnValue += Encoding.UTF8.GetString(bytes) only gets called once, and does not iterate through the streams pages. This is inconsistent as other times it does. What am I doing wrong?
using (MemoryStream fileStream = new MemoryStream())
{
await cloudBlockBlob.DownloadToStreamAsync(fileStream, accessCondition, blobRequestOptions, operationContext);
fileStream.Position = 0;
fileStream.Flush();
cloudBlobContainer = null;
cloudBlockBlob = null;
fileStream.Position = 0;
fileStream.Flush();
LoadOptions loadOptions = new LoadOptions(FileType.FromExtension(Path.GetExtension(attachment.FilePath)));
using (Viewer viewer = new Viewer(fileStream, loadOptions))
{
HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources(
(_) => new MemoryStream(),
(int pageNumber, Stream pageStream) =>
{
var bytes = ((MemoryStream)pageStream).ToArray();
returnValue += Encoding.UTF8.GetString(bytes);
});
viewOptions.Minify = true;
viewOptions.RenderToSinglePage = false;
viewOptions.SpreadsheetOptions = SpreadsheetOptions.ForOnePagePerSheet();
viewOptions.SpreadsheetOptions.SkipEmptyColumns = true;
viewOptions.SpreadsheetOptions.SkipEmptyRows = true;
viewOptions.SpreadsheetOptions.RenderGridLines = true;
viewOptions.SpreadsheetOptions.RenderHeadings = true;
viewOptions.SpreadsheetOptions.TextOverflowMode = TextOverflowMode.AutoFitColumn;
viewOptions.RenderResponsive = true;
viewer.View(viewOptions);
}
}
**********************
This Topic is created by vladimir.litvinchik using Email to Topic tool.
It depends on the count of document pages that are going to be exported to HTML. You can try to Set up logging to check how many pages are actually processed.
As soon as we have a sample code we’ll update you.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): VIEWERNET-4213
You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.
This is reproducible in both word and excel files. We are able to make it happen with a simple word doc and a few characters and pages. One notable attribute is these word documents do have headers and footers and images in them, such as a company logo at the top and basic page numbers, etc.
Can you please attach the sample file you’re able to reproduce this issue?
We do not recommend using OpenReadAsync since it reads just a part of a stream and affects the performance. But, as I can see from your code snippet you’re already using DownloadToStreamAsync that reads a stream into memory.
I can share a document if I remove some PI from it but I’m not sure it will help. I am experiencing this with every doc in the system that has more than 1 page. Randomly, and I mean randomly, all pages render in my local IDE but it seems to happen once then it never happens again.
Could it be a cache problem, or something directly related to the embedded resources running out of memory or anything? Trying to think of anything outside of the realm of normalcy.
I should note we just had another customer report this issue, as it was not happening previously and we did not make any production updates. This leads me to think its a server side caching issue.
[TRACE] Rendering into HTML with embedded resources.
[TRACE] Opening document.
[TRACE] Document is loaded.
[TRACE] Applying options.
[TRACE] Converting page 1.
[TRACE] Page 1 conversion completed.
[TRACE] Releasing resources.
It does not appear to ever go for any more pages in the document. I can confirm the file is correct coming into memory at 122190 bytes and only ever renders the first page.
Is there a way to clear the existing cache? I did not setup a file cache or anything specific for this yet, and just using whatever defaults exist.
One more tid bit of information: This occurred after I made the move to .net core 6 from 5. I can confirm this issue still persists in older code branches which is no help.
Looking for suggestions on how to clear any temp files you may generate from the server and also how to prevent this going forward.
I removed Azure from the equation and used a local copy of the file. The same issue exists, it does not do more than one page.
However, another file I have watermarks on it from the Watermarker API and the Viewer errored saying the file was corrupt when using local disk. I do not get that error when using a memory stream, as in my production code we download the memory stream, pass it through your watermarker first, then into the viewer. These are not related as I have removed the watermarking code entirely and the code i sent is what I am running locally.
I have attached the specific file I have been reproducing this with. thedoc2.docx (18.7 KB)