Bloom.BookThumbNailer.GetThumbnailForPage C# (CSharp) Method

GetThumbnailForPage() public method

Currently used by the image server to get thumbnails that are used in the add page dialog. Since this dialog can show an enlarged version of the page, we generate these at a higher resolution than usual. Also, to make more realistic views of template pages we insert fake text wherever there is an empty edit block. The result is cached for possible future use so the caller should not dispose of it.
public GetThumbnailForPage ( Book book, IPage page, bool isLandscape ) : Image
book Bloom.Book.Book
page IPage
isLandscape bool
return Image
        public Image GetThumbnailForPage(Book.Book book, IPage page, bool isLandscape)
        {
            var pageDom = book.GetThumbnailXmlDocumentForPage(page);
            var thumbnailOptions = new HtmlThumbNailer.ThumbnailOptions()
            {
                BackgroundColor = Color.White,// matches the hand-made previews.
                BorderStyle = HtmlThumbNailer.ThumbnailOptions.BorderStyles.None, // allows the HTML to add its preferred border in the larger preview
                CenterImageUsingTransparentPadding = true
            };
            var pageDiv = pageDom.RawDom.SafeSelectNodes("descendant-or-self::div[contains(@class,'bloom-page')]").Cast<XmlElement>().FirstOrDefault();
            // The actual page size is rather arbitrary, but we want the right ratio for A4.
            // Using the actual A4 sizes in mm makes a big enough image to look good in the larger
            // preview box on the right as well as giving exactly the ratio we want.
            // We need to make the image the right shape to avoid some sort of shadow/box effects
            // that I can't otherwise find a way to get rid of.
            if (isLandscape)
            {
                thumbnailOptions.Width = 297;
                thumbnailOptions.Height = 210;
                pageDiv.SetAttribute("class", pageDiv.Attributes["class"].Value.Replace("Portrait", "Landscape"));
            }
            else
            {
                thumbnailOptions.Width = 210;
                thumbnailOptions.Height = 297;
                // On the offchance someone makes a template with by-default-landscape pages...
                pageDiv.SetAttribute("class", pageDiv.Attributes["class"].Value.Replace("Landscape", "Portrait"));
            }
            // In different books (or even the same one) in the same session we may have portrait and landscape
            // versions of the same template page. So we must use different IDs.
            return _thumbnailProvider.GetThumbnail(page.Id + (isLandscape ? "L" : ""), pageDom, thumbnailOptions);
        }