public static void Run(Document doc, LayoutEnumerator it, string folderPath)
{
// Make sure the enumerator is at the beginning of the document.
it.Reset();
for (int pageIndex = 0; pageIndex < doc.PageCount; pageIndex++)
{
// Use the document class to find information about the current page.
PageInfo pageInfo = doc.GetPageInfo(pageIndex);
const float resolution = 150.0f;
Size pageSize = pageInfo.GetSizeInPixels(1.0f, resolution);
using (Bitmap img = new Bitmap(pageSize.Width, pageSize.Height))
{
img.SetResolution(resolution, resolution);
using (Graphics g = Graphics.FromImage(img))
{
// Make the background white.
g.Clear(Color.White);
// Render the page to the graphics.
doc.RenderToScale(pageIndex, g, 0.0f, 0.0f, 1.0f);
// Add an outline around each element on the page using the graphics object.
AddBoundingBoxToElementsOnPage(it, g);
// Move the enumerator to the next page if there is one.
it.MoveNext();
img.Save(folderPath + string.Format("TestFile Page {0} Out.png", pageIndex + 1));
}
}
}
}