Skip to content

Commit 686d30d

Browse files
committed
refactor: 增加 PdfOptions 配置项
1 parent a55507d commit 686d30d

File tree

3 files changed

+145
-0
lines changed

3 files changed

+145
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the Apache 2.0 License
3+
// See the LICENSE file in the project root for more information.
4+
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
5+
6+
namespace BootstrapBlazor.Components;
7+
8+
/// <summary>
9+
/// 页面边距选项
10+
/// </summary>
11+
public record MarginOptions
12+
{
13+
/// <summary>
14+
/// Top margin, accepts values labeled with units.
15+
/// </summary>
16+
public object? Top { get; set; }
17+
18+
/// <summary>
19+
/// Left margin, accepts values labeled with units.
20+
/// </summary>
21+
public object? Left { get; set; }
22+
23+
/// <summary>
24+
/// Bottom margin, accepts values labeled with units.
25+
/// </summary>
26+
public object? Bottom { get; set; }
27+
28+
/// <summary>
29+
/// Right margin, accepts values labeled with units.
30+
/// </summary>
31+
public object? Right { get; set; }
32+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the Apache 2.0 License
3+
// See the LICENSE file in the project root for more information.
4+
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
5+
6+
namespace BootstrapBlazor.Components;
7+
8+
/// <summary>
9+
/// 纸张规格配置类
10+
/// </summary>
11+
public record PaperFormat
12+
{
13+
/// <summary>
14+
///
15+
/// </summary>
16+
public static PaperFormat Letter => new(8.5m, 11m);
17+
18+
/// <summary>
19+
///
20+
/// </summary>
21+
public static PaperFormat Legal => new(8.5m, 14m);
22+
23+
/// <summary>
24+
///
25+
/// </summary>
26+
public static PaperFormat Tabloid => new(11m, 17m);
27+
28+
/// <summary>
29+
///
30+
/// </summary>
31+
public static PaperFormat Ledger => new(17m, 11m);
32+
33+
/// <summary>
34+
///
35+
/// </summary>
36+
public static PaperFormat A0 => new(33.1102m, 46.811m);
37+
38+
/// <summary>
39+
///
40+
/// </summary>
41+
public static PaperFormat A1 => new(23.3858m, 33.1102m);
42+
43+
/// <summary>
44+
///
45+
/// </summary>
46+
public static PaperFormat A2 => new(16.5354m, 23.3858m);
47+
48+
/// <summary>
49+
///
50+
/// </summary>
51+
public static PaperFormat A3 => new(11.6929m, 16.5354m);
52+
53+
/// <summary>
54+
///
55+
/// </summary>
56+
public static PaperFormat A4 => new(8.2677m, 11.6929m);
57+
58+
/// <summary>
59+
///
60+
/// </summary>
61+
public static PaperFormat A5 => new(5.8268m, 8.2677m);
62+
63+
/// <summary>
64+
///
65+
/// </summary>
66+
public static PaperFormat A6 => new(4.1339m, 5.8268m);
67+
68+
/// <summary>
69+
///
70+
/// </summary>
71+
public decimal Width { get; set; }
72+
73+
/// <summary>
74+
///
75+
/// </summary>
76+
public decimal Height { get; set; }
77+
78+
/// <summary>
79+
///
80+
/// </summary>
81+
/// <param name="width"></param>
82+
/// <param name="height"></param>
83+
public PaperFormat(decimal width, decimal height)
84+
{
85+
Width = width;
86+
Height = height;
87+
}
88+
}

src/BootstrapBlazor/Options/PdfOptions.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,29 @@ public class PdfOptions
1414
/// 获得/设置 是否横向打印 默认 false
1515
/// </summary>
1616
public bool Landscape { get; set; }
17+
18+
/// <summary>
19+
/// 获得/设置 是否打印背景色 默认 false
20+
/// </summary>
21+
public bool PrintBackground { get; set; }
22+
23+
/// <summary>
24+
/// 获得/设置 纸张格式 默认 A4
25+
/// </summary>
26+
public PaperFormat Format { get; set; } = PaperFormat.A4;
27+
28+
/// <summary>
29+
/// 获得/设置 是否显示页眉页脚 默认 false
30+
/// </summary>
31+
public bool DisplayHeaderFooter { get; set; }
32+
33+
/// <summary>
34+
/// 获得/设置 放大比例 默认 1 取值 0.1 到 2 之间
35+
/// </summary>
36+
public decimal Scale { get; set; } = 1;
37+
38+
/// <summary>
39+
/// 获得/设置 页面边距 默认 none
40+
/// </summary>
41+
public MarginOptions MarginOptions { get; set; } = new();
1742
}

0 commit comments

Comments
 (0)