Exemplo n.º 1
0
        private PageBacking LoadBackground(TemplateProject project, int sourcePageIndex, TemplatePage pageDef)
        {
            var backing = new PageBacking();

            if (_basePdf is null && !string.IsNullOrWhiteSpace(project.BasePdfFile !))
            {
                using var fileStream = _files.Load(project.BasePdfFile);
                _basePdf             = PdfReader.Open(fileStream, PdfDocumentOpenMode.Import); // Must use import mode to copy pages across
            }

            if (_basePdf != null)
            {
                backing.ExistingPage = _basePdf.Pages[sourcePageIndex];
            }

            if (!string.IsNullOrWhiteSpace(pageDef.BackgroundImage !))
            {
                using var fileStream    = _files.Load(project.BasePdfFile);
                backing.BackgroundImage = XImage.FromStream(fileStream);
            }

            return(backing);
        }