Ejemplo n.º 1
0
        private async Task AddPageForImageWithFittingAsync(ImageDescription image, string pageNavLabel, EpubXmlWriter.ImageFitting fitting)
        {
            var fileNameBase  = Path.GetFileNameWithoutExtension(image.Path);
            var refProperties = default(string);

            switch (fitting)
            {
            case EpubXmlWriter.ImageFitting.LeftHalf:
                fileNameBase += "_L";
                refProperties = "page-spread-left";
                break;

            case EpubXmlWriter.ImageFitting.RightHalf:
                fileNameBase += "_R";
                refProperties = "page-spread-right";
                break;
            }

            var pageItem = new PageDescription($"p_{fileNameBase}", $"{fileNameBase}.xhtml", pageNavLabel, null, refProperties);
            var html     = EpubXmlWriter.GenerateContentPage(image.Path, image.Width, image.Height, fitting);

            await AddTextEntryAsync($"{Strings.EpubContentRoot}{pageItem.Path}", html).ConfigureAwait(false);

            Contents.Add(pageItem);
            Pages.Add(pageItem);
        }
Ejemplo n.º 2
0
        public void ContentPageGenerationWorks()
        {
            var xml = EpubXmlWriter.GenerateContentPage("imagepath.jpg", 400, 300, 0);

            Assert.NotEmpty(xml);
            OutputHelper.WriteLine(xml);
        }