| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- using AutoMapper;
- using PuppeteerSharp;
- using BlackRock.Reporting.API.Core.Models;
- using BlackRock.Reporting.API.Mediator.UserMediator.Model;
- using BlackRock.Reporting.API.Mediator.UserMediator.Dto;
-
- namespace BlackRock.Reporting.API.Mediator.Mapping.DTOToEntity
- {
-
- public class PDFMapping : Profile
- {
- public PDFMapping()
- {
- CreateMap<OptionsForPdf, PdfOptions>().ConvertUsing<OptionsForPdfConverter>();
- }
- }
-
- public class OptionsForPdfConverter : ITypeConverter<OptionsForPdf, PdfOptions>
- {
- public PdfOptions Convert(OptionsForPdf source, PdfOptions destination, ResolutionContext context)
- {
- if (source == null) return destination;
- if (destination == null)
- destination = new PdfOptions();
-
- destination.DisplayHeaderFooter = source.DisplayHeaderFooter;
- destination.HeaderTemplate = source.HeaderTemplate;
- destination.Height = source.Height;
- destination.Landscape = source.Landscape;
- destination.OmitBackground = source.OmitBackground;
- destination.PageRanges = source.PageRanges;
- destination.PreferCSSPageSize = source.PreferCSSPageSize;
- destination.PrintBackground = source.PrintBackground;
- destination.Scale = source.Scale;
- destination.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;
- }
- }
- }
|