Using Aspose.Words 15.1
We regularly work with large documents 500 pages +, ideally we want a way to split these pages sequentially page by page so we can display the first pages while it is busy loading the rest of the document.
I have looked at the examples and the DocumentPageSplitter, PageNumberFinder and SectionSplitter is is taking 12 minutes plus to split an 800 page document so this is not acceptable to ask the user to wait for.
so far the quickest way is render each page using Document.GetPageInfo and then using Document.RenderToScale functions the problem is the first page is still taking 1 minute 20 seconds on an i7 machine with an SSD, to render, is there any way to do this faster?
Plus is there a quick way to then get all the nodes that were used to render this page it would be nice if Document.RenderToScale returned an enumerable of the nodes it used to render then you could keep them in memory do highlighting ect then render them again in a new document.
var nodes = Document.RenderToScale(pageNumber - 1, gr, 0, 0, MyScale);
here is the page rendering code:
var sw = new Stopwatch();
sw.Start();
PageInfo pageInfo = Data.Document.GetPageInfo(pageNumber - 1);
sw.Stop();
Trace.Write(string.Format("@@ got page {0} information in {1}ms", pageNumber, sw.Elapsed.TotalMilliseconds));
// Let's say we want the image at 50% zoom.
float MyScale = lowResolution ? 0.50f : 2.0f;
// Let's say we want the image at this resolution.
float MyResolution = lowResolution ? 150.0f : 250.0f;
var pageSize = pageInfo.GetSizeInPixels(MyScale, MyResolution);
using (var docImageStream = new MemoryStream())
using (Bitmap img = new Bitmap(pageSize.Width, pageSize.Height))
{
img.SetResolution(MyResolution, MyResolution);
using (Graphics gr = Graphics.FromImage(img))
{
// You can apply various settings to the Graphics object.
gr.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
// Fill the page background.
gr.FillRectangle(System.Drawing.Brushes.White, 0, 0, pageSize.Width, pageSize.Height);
// Render the page using the zoom.
sw.Reset();
sw.Start();
Data.Document.RenderToScale(pageNumber - 1, gr, 0, 0, MyScale);
sw.Stop();
Trace.Write(string.Format("@@ rendered page {0} in {1}ms", pageNumber, sw.Elapsed.TotalMilliseconds));
}
}