Convert docx to HTML using GroupDocs.Viewer only reads first 2 pages

74 views Asked by At

I'm Trying to convert word(.docx) file to HTML. GroupDocs.Viewer package is convert it perfectly within the document images and format, but just for the first 2 pages and I don't understand why it is happen. I had try for many documents but it always takes the only 2 pages. here in the following loop I set it loop 5 times to test the 5 pages at least, but it still read the 2 pages. Is there any additional option I have to add to reads the full document?

    using (var stream = new MemoryStream())
            {
                await model.File.CopyToAsync(stream);

                using (var viewer = new Viewer(stream))
                {
                    var htmlContent = new StringBuilder();
                    var viewInfo = viewer.GetViewInfo(ViewInfoOptions.ForHtmlView());

                    for (int page = 1; page <= 5; page++)
                    {
                        var pageStream = new MemoryStream();
                        var pageViewOptions = HtmlViewOptions.ForEmbeddedResources($"output/page_{page}.html");

                        // Specify the page to render
                     //   pageViewOptions.PageNumbersToRender = new[] { page };

                        viewer.View(pageViewOptions,page);

                        pageStream.Position = 0;
                        using (var reader = new StreamReader(pageStream))
                        {
                            htmlContent.AppendLine(reader.ReadToEnd());
                        }
                    }

                    return Ok(htmlContent.ToString());
                }

            }
1

There are 1 answers

0
Marc Deakin On

According to the readme.txt:

Trial licence limitations:

  • Only first 2 pages can be processed.
  • Trial badges are placed in the document on the top of each page.

You'll need to get a 30-day Temporary Licence or a full one:

Get a temporary license

If you wish to test GroupDocs.Viewer without the limitations of the trial version, you can also request a 30-day Temporary License. For more details, see https://purchase.groupdocs.com/temporary-license page.