Преглед изворни кода

Feature / Added options for sending Format and Margins from client to API

Feature
Safet Purkovic пре 4 година
родитељ
комит
923ad070ee

+ 2
- 1
.gitignore Прегледај датотеку

bin/ bin/
debug/ debug/
node_modules/
node_modules/
wwwroot/

+ 33
- 0
BlackRock.Reporting.API/.vscode/launch.json Прегледај датотеку

{
// 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"
}
]
}

+ 42
- 0
BlackRock.Reporting.API/.vscode/tasks.json Прегледај датотеку

{
"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"
}
]
}

+ 11
- 6
BlackRock.Reporting.API/Core/Models/OptionsForPdf.cs Прегледај датотеку



namespace BlackRock.Reporting.API.Core.Models namespace BlackRock.Reporting.API.Core.Models
{ {
public enum PaperFormatType{
A4 = 0,
A3 = 1,
Letter = 2
}
public class OptionsForPdf public class OptionsForPdf
{ {
/// <summary> /// <summary>
/// <summary> /// <summary>
/// Paper format. If set, takes priority over <see cref="Width"/> and <see cref="Height"/> /// Paper format. If set, takes priority over <see cref="Width"/> and <see cref="Height"/>
/// </summary> /// </summary>
public PaperFormat Format { get; set; }// = PaperFormat.Letter;
public PaperFormatType PaperFormatType {get; set;} = PaperFormatType.A4; // Paper format from client side


/// <summary> /// <summary>
/// Paper width, accepts values labeled with units /// Paper width, accepts values labeled with units
/// <summary> /// <summary>
/// Paper margins, defaults to none /// Paper margins, defaults to none
/// </summary> /// </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> /// <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. /// 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.
/// Hides default white background and allows generating pdfs with transparency. /// Hides default white background and allows generating pdfs with transparency.
/// </summary> /// </summary>
public bool OmitBackground { get; set; } public bool OmitBackground { get; set; }
public OptionsForPdf()
{
Format = PuppeteerSharp.Media.PaperFormat.Letter;
}
} }
} }

+ 48
- 1
BlackRock.Reporting.API/Profiles/Profiler.cs Прегледај датотеку

using AutoMapper; using AutoMapper;
using PuppeteerSharp; using PuppeteerSharp;
using BlackRock.Reporting.API.Core.Models; using BlackRock.Reporting.API.Core.Models;

namespace BlackRock.Reporting.API.Profiles namespace BlackRock.Reporting.API.Profiles
{ {
public class Profiler : Profile public class Profiler : Profile
{ {
public Profiler() 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
- 1
BlackRock.Reporting.API/dist/main.js
Разлика између датотеке није приказан због своје велике величине
Прегледај датотеку


+ 5
- 5
BlackRock.Reporting.API/obj/BlackRock.Reporting.API.csproj.nuget.dgspec.json Прегледај датотеку

{ {
"format": 1, "format": 1,
"restore": { "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": { "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", "version": "1.0.0",
"restore": { "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", "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\\", "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", "projectStyle": "PackageReference",
"configFilePaths": [ "configFilePaths": [
"C:\\Users\\safet.purkovic\\AppData\\Roaming\\NuGet\\NuGet.Config", "C:\\Users\\safet.purkovic\\AppData\\Roaming\\NuGet\\NuGet.Config",

+ 2
- 2
BlackRock.Reporting.API/obj/project.nuget.cache Прегледај датотеку

{ {
"version": 2, "version": 2,
"dgSpecHash": "u5LCzMsSc98tqejgvIS7vh2sBsOKVmvwB91LkGNhpRK/OTJT4TBibJo14VN9KPzUL1djIsrbKAcg0IlFWE3yWg==",
"dgSpecHash": "CWZgWYM1eCSk38SuYkv3dxqETT/4ZhBGYJ0BC0Js2XjwANoY+dTh7urgBxbU/o5glmzspiqosf7ZSf+k+lOuyw==",
"success": true, "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": [ "expectedPackageFiles": [
"C:\\Users\\safet.purkovic\\.nuget\\packages\\automapper\\10.1.1\\automapper.10.1.1.nupkg.sha512", "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", "C:\\Users\\safet.purkovic\\.nuget\\packages\\automapper.extensions.microsoft.dependencyinjection\\8.1.1\\automapper.extensions.microsoft.dependencyinjection.8.1.1.nupkg.sha512",

Loading…
Откажи
Сачувај