| @@ -1,3 +1,4 @@ | |||
| bin/ | |||
| debug/ | |||
| node_modules/ | |||
| node_modules/ | |||
| wwwroot/ | |||
| @@ -0,0 +1,33 @@ | |||
| { | |||
| // Use IntelliSense to learn about possible attributes. | |||
| // Hover to view descriptions of existing attributes. | |||
| // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | |||
| "version": "0.2.0", | |||
| "configurations": [ | |||
| { | |||
| "name": ".NET Core Launch (web)", | |||
| "type": "coreclr", | |||
| "request": "launch", | |||
| "preLaunchTask": "build", | |||
| "program": "${workspaceFolder}/bin/Debug/net6.0/BlackRock.Reporting.API.dll", | |||
| "args": [], | |||
| "cwd": "${workspaceFolder}", | |||
| "stopAtEntry": false, | |||
| "serverReadyAction": { | |||
| "action": "openExternally", | |||
| "pattern": "\\bNow listening on:\\s+(https?://\\S+)" | |||
| }, | |||
| "env": { | |||
| "ASPNETCORE_ENVIRONMENT": "Development" | |||
| }, | |||
| "sourceFileMap": { | |||
| "/Views": "${workspaceFolder}/Views" | |||
| } | |||
| }, | |||
| { | |||
| "name": ".NET Core Attach", | |||
| "type": "coreclr", | |||
| "request": "attach" | |||
| } | |||
| ] | |||
| } | |||
| @@ -0,0 +1,42 @@ | |||
| { | |||
| "version": "2.0.0", | |||
| "tasks": [ | |||
| { | |||
| "label": "build", | |||
| "command": "dotnet", | |||
| "type": "process", | |||
| "args": [ | |||
| "build", | |||
| "${workspaceFolder}/BlackRock.Reporting.API.csproj", | |||
| "/property:GenerateFullPaths=true", | |||
| "/consoleloggerparameters:NoSummary" | |||
| ], | |||
| "problemMatcher": "$msCompile" | |||
| }, | |||
| { | |||
| "label": "publish", | |||
| "command": "dotnet", | |||
| "type": "process", | |||
| "args": [ | |||
| "publish", | |||
| "${workspaceFolder}/BlackRock.Reporting.API.csproj", | |||
| "/property:GenerateFullPaths=true", | |||
| "/consoleloggerparameters:NoSummary" | |||
| ], | |||
| "problemMatcher": "$msCompile" | |||
| }, | |||
| { | |||
| "label": "watch", | |||
| "command": "dotnet", | |||
| "type": "process", | |||
| "args": [ | |||
| "watch", | |||
| "run", | |||
| "${workspaceFolder}/BlackRock.Reporting.API.csproj", | |||
| "/property:GenerateFullPaths=true", | |||
| "/consoleloggerparameters:NoSummary" | |||
| ], | |||
| "problemMatcher": "$msCompile" | |||
| } | |||
| ] | |||
| } | |||
| @@ -4,6 +4,11 @@ using PuppeteerSharp.Media; | |||
| namespace BlackRock.Reporting.API.Core.Models | |||
| { | |||
| public enum PaperFormatType{ | |||
| A4 = 0, | |||
| A3 = 1, | |||
| Letter = 2 | |||
| } | |||
| public class OptionsForPdf | |||
| { | |||
| /// <summary> | |||
| @@ -54,7 +59,7 @@ namespace BlackRock.Reporting.API.Core.Models | |||
| /// <summary> | |||
| /// Paper format. If set, takes priority over <see cref="Width"/> and <see cref="Height"/> | |||
| /// </summary> | |||
| public PaperFormat Format { get; set; }// = PaperFormat.Letter; | |||
| public PaperFormatType PaperFormatType {get; set;} = PaperFormatType.A4; // Paper format from client side | |||
| /// <summary> | |||
| /// Paper width, accepts values labeled with units | |||
| @@ -69,7 +74,11 @@ namespace BlackRock.Reporting.API.Core.Models | |||
| /// <summary> | |||
| /// Paper margins, defaults to none | |||
| /// </summary> | |||
| public MarginOptions MarginOptions { get; set; } = new MarginOptions(){Top="3.0 mm",Right = "3.0 mm",Left="3.0 mm",Bottom="12.7 mm"}; | |||
| //public MarginOptions MarginOptions { get; set; } = new MarginOptions(){Top="3.0 mm",Right = "3.0 mm",Left="3.0 mm",Bottom="12.7 mm"}; | |||
| public string MarginTop {get;set;} ="3.0 mm"; | |||
| public string MarginRight {get;set;} = "3.0 mm"; | |||
| public string MarginLeft {get;set;} ="3.0 mm"; | |||
| public string MarginBottom {get;set;} ="12.7 mm"; | |||
| /// <summary> | |||
| /// Give any CSS <c>@page</c> size declared in the page priority over what is declared in <c>width</c> and <c>height</c> or <c>format</c> options. | |||
| @@ -81,9 +90,5 @@ namespace BlackRock.Reporting.API.Core.Models | |||
| /// Hides default white background and allows generating pdfs with transparency. | |||
| /// </summary> | |||
| public bool OmitBackground { get; set; } | |||
| public OptionsForPdf() | |||
| { | |||
| Format = PuppeteerSharp.Media.PaperFormat.Letter; | |||
| } | |||
| } | |||
| } | |||
| @@ -1,13 +1,60 @@ | |||
| using AutoMapper; | |||
| using PuppeteerSharp; | |||
| using BlackRock.Reporting.API.Core.Models; | |||
| namespace BlackRock.Reporting.API.Profiles | |||
| { | |||
| public class Profiler : Profile | |||
| { | |||
| public Profiler() | |||
| { | |||
| CreateMap<OptionsForPdf, PdfOptions>(); | |||
| 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; | |||
| } | |||
| } | |||
| } | |||
| @@ -1,17 +1,17 @@ | |||
| { | |||
| "format": 1, | |||
| "restore": { | |||
| "C:\\Users\\safet.purkovic\\Desktop\\PDFEngineAPI\\blackrock.reporting.api\\BlackRock.Reporting.API.csproj": {} | |||
| "C:\\Users\\safet.purkovic\\Desktop\\PDFEngineAPI\\BlackRock.Reporting.API\\BlackRock.Reporting.API.csproj": {} | |||
| }, | |||
| "projects": { | |||
| "C:\\Users\\safet.purkovic\\Desktop\\PDFEngineAPI\\blackrock.reporting.api\\BlackRock.Reporting.API.csproj": { | |||
| "C:\\Users\\safet.purkovic\\Desktop\\PDFEngineAPI\\BlackRock.Reporting.API\\BlackRock.Reporting.API.csproj": { | |||
| "version": "1.0.0", | |||
| "restore": { | |||
| "projectUniqueName": "C:\\Users\\safet.purkovic\\Desktop\\PDFEngineAPI\\blackrock.reporting.api\\BlackRock.Reporting.API.csproj", | |||
| "projectUniqueName": "C:\\Users\\safet.purkovic\\Desktop\\PDFEngineAPI\\BlackRock.Reporting.API\\BlackRock.Reporting.API.csproj", | |||
| "projectName": "BlackRock.Reporting.API", | |||
| "projectPath": "C:\\Users\\safet.purkovic\\Desktop\\PDFEngineAPI\\blackrock.reporting.api\\BlackRock.Reporting.API.csproj", | |||
| "projectPath": "C:\\Users\\safet.purkovic\\Desktop\\PDFEngineAPI\\BlackRock.Reporting.API\\BlackRock.Reporting.API.csproj", | |||
| "packagesPath": "C:\\Users\\safet.purkovic\\.nuget\\packages\\", | |||
| "outputPath": "C:\\Users\\safet.purkovic\\Desktop\\PDFEngineAPI\\blackrock.reporting.api\\obj\\", | |||
| "outputPath": "C:\\Users\\safet.purkovic\\Desktop\\PDFEngineAPI\\BlackRock.Reporting.API\\obj\\", | |||
| "projectStyle": "PackageReference", | |||
| "configFilePaths": [ | |||
| "C:\\Users\\safet.purkovic\\AppData\\Roaming\\NuGet\\NuGet.Config", | |||
| @@ -1,8 +1,8 @@ | |||
| { | |||
| "version": 2, | |||
| "dgSpecHash": "u5LCzMsSc98tqejgvIS7vh2sBsOKVmvwB91LkGNhpRK/OTJT4TBibJo14VN9KPzUL1djIsrbKAcg0IlFWE3yWg==", | |||
| "dgSpecHash": "CWZgWYM1eCSk38SuYkv3dxqETT/4ZhBGYJ0BC0Js2XjwANoY+dTh7urgBxbU/o5glmzspiqosf7ZSf+k+lOuyw==", | |||
| "success": true, | |||
| "projectFilePath": "C:\\Users\\safet.purkovic\\Desktop\\PDFEngineAPI\\blackrock.reporting.api\\BlackRock.Reporting.API.csproj", | |||
| "projectFilePath": "C:\\Users\\safet.purkovic\\Desktop\\PDFEngineAPI\\BlackRock.Reporting.API\\BlackRock.Reporting.API.csproj", | |||
| "expectedPackageFiles": [ | |||
| "C:\\Users\\safet.purkovic\\.nuget\\packages\\automapper\\10.1.1\\automapper.10.1.1.nupkg.sha512", | |||
| "C:\\Users\\safet.purkovic\\.nuget\\packages\\automapper.extensions.microsoft.dependencyinjection\\8.1.1\\automapper.extensions.microsoft.dependencyinjection.8.1.1.nupkg.sha512", | |||