Noor Shaker
Noor Shaker

Reputation: 57

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

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());
                }

            }

Upvotes: 0

Views: 202

Answers (1)

Marc Deakin
Marc Deakin

Reputation: 1

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.

Upvotes: 0

Related Questions