Hello,
When previewing the Word file, we’re having problems with the images in the documents.
After a few investigations and tests on the parameters of the images in the Word file, nothing was really conclusive.
Please find enclosed:
You can see the problem on page 9 and 10 of the file R2401.0013.docx.
Here’s the code used for the preview
using GroupDocs.Viewer.Options;
using GroupDocs.Viewer.Results;
using System;
using System.IO;
namespace Web.code.Lib.GroupDocsViewer
{
public class HtmlViewer : IDisposable
{
private readonly GroupDocs.Viewer.Viewer viewer;
private readonly HtmlViewOptions htmlViewOptions;
private readonly ViewInfoOptions viewInfoOptions;
private Stream stream;
public HtmlViewer(string filePath, LoadOptions loadOptions)
{
viewer = new GroupDocs.Viewer.Viewer(filePath, loadOptions);
htmlViewOptions = CreateHtmlViewOptions();
viewInfoOptions = ViewInfoOptions.FromHtmlViewOptions(htmlViewOptions);
}
private HtmlViewOptions CreateHtmlViewOptions()
{
HtmlViewOptions htmlViewOptions = HtmlViewOptions.ForEmbeddedResources(
// The action that will be done before each page informations is read
pageNumber =>
{
Stream pageStream = new MemoryStream();
stream = pageStream;
return pageStream;
},
// The action to do after each page information is read.
// Must be there otherwise the stream is disposed and we can't used it anymore
(pageNumber, stream) =>
{
});
htmlViewOptions.SpreadsheetOptions = SpreadsheetOptions.ForOnePagePerSheet();
htmlViewOptions.SpreadsheetOptions.TextOverflowMode = TextOverflowMode.HideText;
htmlViewOptions.SpreadsheetOptions.RenderHeadings = true;
htmlViewOptions.ExcludeFonts = false;
return htmlViewOptions;
}
public string GetPageContent(int pageNumber)
{
viewer.View(htmlViewOptions, pageNumber);
stream.Position = 0;
using (StreamReader reader = new StreamReader(stream))
{
string htmlContent = reader.ReadToEnd();
stream.Dispose();
return htmlContent;
}
}
public void Dispose()
{
viewer.Dispose();
}
}
}
Version of GroupDocs.Viewer used 24.3.0 (latest).
We’re developing a web application and your solution is being used by our application for customers who want to be able to preview and convert their files correctly.
Thanks in advance
I thinks related to Images are not in the right place when converting pdf for net
R2401.0013.docx (2.61 MB)
@BASSETTI
Thank you for adding the code snippet and source file. I have reproduced this issue. It is a bug. We’ll investigate this issue and update you. The issue ID for reference is VIEWERNET-4792.
@BASSETTI
This issue was fixed see pages-8-9-10.zip (1.2 MB). The fix will be included in GroupDocs.Viewer for .NET 24.4 that is planned to publish by the end of this month. We’ll notify you here when the version will be available.
@BASSETTI
GroupDocs.Viewer for .NET 24.4 was published. This version includes fix for this issue. The new version can be found at NuGet and GroupDocs Releases.
Have a nice day!
Thanks for the package.
I have try to update it on own solution but when I have update the package, I have the following error :
Msg: Could not load file or assembly 'System.Text.Encoding.CodePages, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).
StackTrace: at .()
at . (String , Stream , LoadOptions , BaseViewOptions , CancellationToken )
at GroupDocs.Viewer.Viewer.(LoadOptions , BaseViewOptions , CancellationToken )
at GroupDocs.Viewer.Viewer.(BaseViewOptions , CancellationToken )
at GroupDocs.Viewer.Viewer.(ViewInfoOptions , CancellationToken )
at GroupDocs.Viewer.Viewer.GetViewInfo(ViewInfoOptions options)
at Web.code.Lib.GroupDocsViewer.HtmlViewer.GetViewInfo()
When I execute the following code :
var viewer = new GroupDocs.Viewer.Viewer(filePath, loadOptions);
var htmlViewOptions = CreateHtmlViewOptions();
var viewInfoOptions = ViewInfoOptions.FromHtmlViewOptions(htmlViewOptions);
ViewInfo viewInfo = viewer.GetViewInfo(viewInfoOptions);
return viewInfo;
I can demo you if you want.
Thanks by advanced.
@BASSETTI
May you please share sample app to reproduce this issue?
@vladimir.litvinchik
Providing you with an example application would take too much time to redo.
Can I demonstrate the error in a meeting?
@BASSETTI
Unfortunately, we can only provide textual responses in Free Forum. Please share target framework, and OS that you’re running the app.
@vladimir.litvinchik
OK sure no problem.
We use a web application using .NET Framework 4.7.2 like target framework. For the OS, using IIS on Windows server.
The problem occurs when try to use the method viewer.GetViewInfo(viewInfoOptions);
The package System.Text.Encoding.CodePages is on version 6.0.0.0 when dowloading your GroupDocs.Viewer Nuget package .
@BASSETTI
Thank you for sharing the details. We’ll take a look and update you.
@vladimir.litvinchik
Do you have any update of the subject ?
@BASSETTI
The issue was planned for investigation for this week. As soon as we have any updates we’ll let you know.
@BASSETTI
I’m sorry for the delayed response. I have created the sample Web Forms application to reproduce this issue - WebApplication1.zip (84.2 KB) and it works well. It is likely that the package with dependencies was not properly installed when you updated to the later version. May you please try removing GroupDocs.Viewer and installing the package back? You can use packages.json
and WebApplication1.csproj
to compare the list of dependencies and their versions.
@vladimir.litvinchik
Hello,
Thank you for your feedback and your solution works.
However, we can’t use what you’ve done in our application. Because we have other dependencies and we wouldn’t be able to control the impact it could have.
The compilation in GroupDocs would have to correctly embed the CodePages dependency, which would allow us to better manage the dependencies in our application.
Thanks in advance
@BASSETTI
Please note that I didn’t make any manual changes in csproj
and packages.json
files. Visual Studio is automatically handles dependencies that are properly declared in NuGet package
It is possible that the dependencies won’t be installed automatically. Please check the output window in Visual Studio to check for the issues.
@BASSETTI
Please share if you managed to resolve this issue?
@BASSETTI
This issue was fixed in GroupDocs.Viewer for .NET 24.8. The packages are available at:
Have a nice day!