| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- using AutoMapper;
- using PuppeteerSharp;
- using BlackRock.Reporting.API.Core.Models;
-
- namespace BlackRock.Reporting.API.Profiles
- {
-
- public class Profiler : Profile
- {
- public Profiler()
- {
- CreateMap<OptionsForPdf, PdfOptions>().ConvertUsing<OptionsForPdfConverter>();
- }
- }
-
- public class OptionsForPdfConverter : ITypeConverter<OptionsForPdf, PdfOptions>
- {
- public PdfOptions Convert(OptionsForPdf source, PdfOptions destination, ResolutionContext context)
- {
- if (source == null)
- {
- return null;
- }
- destination = new PdfOptions()
- {
- DisplayHeaderFooter = source.DisplayHeaderFooter,
- HeaderTemplate = source.HeaderTemplate,
- Height = source.Height,
- Landscape = source.Landscape,
- OmitBackground = source.OmitBackground,
- PageRanges = source.PageRanges,
- PreferCSSPageSize = source.PreferCSSPageSize,
- PrintBackground = source.PrintBackground,
- Scale = source.Scale,
- Width = source.Width
- };
- destination.MarginOptions = new PuppeteerSharp.Media.MarginOptions()
- {
- Bottom = source.MarginBottom,
- Top = source.MarginTop,
- Right = source.MarginRight,
- Left = source.MarginLeft
- };
- switch (source.PaperFormatType)
- {
- case PaperFormatType.A4:
- destination.Format = PuppeteerSharp.Media.PaperFormat.A4;
- break;
- case PaperFormatType.A3:
- destination.Format = PuppeteerSharp.Media.PaperFormat.A3;
- break;
- case PaperFormatType.Letter:
- destination.Format = PuppeteerSharp.Media.PaperFormat.Letter;
- break;
-
- }
- return destination;
- }
- }
- }
|