Skip to content

Commit dd202b5

Browse files
committed
Merge branch 'release/2.5.0'
2 parents 45bcdac + 6813c91 commit dd202b5

22 files changed

+529
-358
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ public void ConfigureServices(IServiceCollection services)
6565
var builder = new HtmlRequestBuilder()
6666
.AddDocument(doc =>
6767
doc.SetBody(GetBody()).SetFooter(GetFooter())
68-
).WithDimensions(dims =>
68+
).WithPageProperties(pp =>
6969
{
70-
dims.SetPaperSize(PaperSizes.A3)
70+
pp.SetPaperSize(PaperSizes.A3)
7171
.SetMargins(Margins.None)
7272
.SetScale(.99);
7373
}).WithAsyncAssets(async assets => assets.AddItem("some-image.jpg", await GetImageBytes()));
@@ -95,12 +95,12 @@ public async Task<Stream> CreateFromUrl(string headerPath, string footerPath)
9595
.AddAsyncHeaderFooter(async
9696
doc => doc.SetHeader(await File.ReadAllTextAsync(headerPath))
9797
.SetFooter(await File.ReadAllBytesAsync(footerPath)
98-
)).WithDimensions(dims =>
98+
)).WithPageProperties(pp =>
9999
{
100-
dims.SetPaperSize(PaperSizes.A4)
100+
pp.SetPaperSize(PaperSizes.A4)
101101
.SetMargins(Margins.None)
102102
.SetScale(.90)
103-
.LandScape();
103+
.SetLandscape();
104104
});
105105

106106
var request = await builder.BuildAsync();
@@ -130,14 +130,14 @@ public async Task<Stream> CreateFromMarkdown()
130130
.AddAsyncDocument(async
131131
doc => doc.SetHeader(await this.GetHeaderAsync())
132132
.SetBody(await GetBodyAsync())
133-
.ContainsMarkdown()
133+
.SetContainsMarkdown()
134134
.SetFooter(await GetFooterAsync())
135-
).WithDimensions(dims =>
135+
).WithPageProperties(pp =>
136136
{
137-
dims.UseChromeDefaults().LandScape().SetScale(.90);
137+
pp.UseChromeDefaults().SetLandscape().SetScale(.90);
138138
}).WithAsyncAssets(async
139139
a => a.AddItems(await GetMarkdownAssets())
140-
));
140+
);
141141

142142
var request = await builder.BuildAsync();
143143
return await _sharpClient.HtmlToPdfAsync(request);
@@ -169,7 +169,7 @@ public async Task<Stream> CreateFromMarkdown()
169169
dimBuilder.SetPaperSize(PaperSizes.A4)
170170
.SetMargins(Margins.None)
171171
.SetScale(.90)
172-
.LandScape();
172+
.SetLandscape();
173173
});
174174

175175
var request = await builder.BuildAsync();
@@ -217,9 +217,9 @@ IEnumerable<UrlRequestBuilder> CreateBuilders(IEnumerable<Uri> uris)
217217
{
218218
dimBuilder.UseChromeDefaults()
219219
.SetScale(.90)
220-
.LandScape()
221-
.MarginLeft(.5)
222-
.MarginRight(.5);
220+
.SetLandscape()
221+
.SetMarginLeft(.5)
222+
.SetMarginRight(.5);
223223
});
224224
}
225225

lib/Domain/Builders/BaseChromiumBuilder.cs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,44 @@ public abstract class BaseChromiumBuilder<TRequest, TBuilder>(TRequest request)
2020
where TRequest : ChromeRequest
2121
where TBuilder : BaseChromiumBuilder<TRequest, TBuilder>
2222
{
23-
public TBuilder WithDimensions(Action<DimensionBuilder> action)
23+
[Obsolete("Use WithPageProperties")]
24+
public TBuilder WithDimensions(Action<PagePropertyBuilder> action)
2425
{
2526
if (action == null) throw new ArgumentNullException(nameof(action));
2627

27-
var builder = new DimensionBuilder(this.Request.Dimensions);
28+
var builder = new PagePropertyBuilder(this.Request.PageProperties);
2829

2930
action(builder);
3031

31-
this.Request.Dimensions = builder.GetDimensions();
32+
this.Request.PageProperties = builder.GetPageProperties();
3233

3334
return (TBuilder)this;
3435
}
3536

36-
public TBuilder WithDimensions(Dimensions dimensions)
37+
[Obsolete("Use WithPageProperties")]
38+
public TBuilder WithDimensions(PageProperties pageProperties)
3739
{
38-
this.Request.Dimensions = dimensions ?? throw new ArgumentNullException(nameof(dimensions));
40+
this.Request.PageProperties = pageProperties ?? throw new ArgumentNullException(nameof(pageProperties));
41+
return (TBuilder)this;
42+
}
43+
44+
public TBuilder WithPageProperties(Action<PagePropertyBuilder> action)
45+
{
46+
if (action == null) throw new ArgumentNullException(nameof(action));
47+
48+
var builder = new PagePropertyBuilder(this.Request.PageProperties);
49+
50+
action(builder);
51+
52+
this.Request.PageProperties = builder.GetPageProperties();
53+
54+
return (TBuilder)this;
55+
}
56+
57+
public TBuilder WithPageProperties(PageProperties pageProperties)
58+
{
59+
this.Request.PageProperties = pageProperties ?? throw new ArgumentNullException(nameof(pageProperties));
60+
3961
return (TBuilder)this;
4062
}
4163

lib/Domain/Builders/Faceted/DimensionBuilder.cs

Lines changed: 0 additions & 147 deletions
This file was deleted.

lib/Domain/Builders/Faceted/DocumentBuilder.cs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-2024 Chris Mohan, Jaben Cargman
1+
// Copyright 2019-2025 Chris Mohan, Jaben Cargman
22
// and GotenbergSharpApiClient Contributors
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,8 +13,6 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515

16-
17-
1816
namespace Gotenberg.Sharp.API.Client.Domain.Builders.Faceted;
1917

2018
/// <summary>
@@ -36,33 +34,35 @@ public DocumentBuilder(FullDocument content, Action<bool> setContainsMarkdown)
3634

3735
#region body
3836

39-
37+
[Obsolete("Use SetContainsMarkdown()")]
4038
public DocumentBuilder ContainsMarkdown(bool containsMarkdown = true)
4139
{
4240
this._setContainsMarkdown(containsMarkdown);
4341
return this;
4442
}
4543

46-
44+
public DocumentBuilder SetContainsMarkdown(bool containsMarkdown = true)
45+
{
46+
this._setContainsMarkdown(containsMarkdown);
47+
return this;
48+
}
49+
4750
public DocumentBuilder SetBody(ContentItem body)
4851
{
4952
this._content.Body = body ?? throw new ArgumentNullException(nameof(body));
5053
return this;
5154
}
5255

53-
5456
public DocumentBuilder SetBody(string body)
5557
{
5658
return this.SetBody(new ContentItem(body));
5759
}
5860

59-
6061
public DocumentBuilder SetBody(byte[] body)
6162
{
6263
return this.SetBody(new ContentItem(body));
6364
}
6465

65-
6666
public DocumentBuilder SetBody(Stream body)
6767
{
6868
return this.SetBody(new ContentItem(body));
@@ -72,26 +72,22 @@ public DocumentBuilder SetBody(Stream body)
7272

7373
#region header
7474

75-
7675
public DocumentBuilder SetHeader(ContentItem header)
7776
{
7877
this._content.Header = header ?? throw new ArgumentNullException(nameof(header));
7978
return this;
8079
}
8180

82-
8381
public DocumentBuilder SetHeader(string header)
8482
{
8583
return this.SetHeader(new ContentItem(header));
8684
}
8785

88-
8986
public DocumentBuilder SetHeader(byte[] header)
9087
{
9188
return this.SetHeader(new ContentItem(header));
9289
}
9390

94-
9591
public DocumentBuilder SetHeader(Stream header)
9692
{
9793
return this.SetHeader(new ContentItem(header));
@@ -101,26 +97,22 @@ public DocumentBuilder SetHeader(Stream header)
10197

10298
#region footer
10399

104-
105100
public DocumentBuilder SetFooter(ContentItem footer)
106101
{
107102
this._content.Footer = footer ?? throw new ArgumentNullException(nameof(footer));
108103
return this;
109104
}
110105

111-
112106
public DocumentBuilder SetFooter(string footer)
113107
{
114108
return this.SetFooter(new ContentItem(footer));
115109
}
116110

117-
118111
public DocumentBuilder SetFooter(byte[] footer)
119112
{
120113
return this.SetFooter(new ContentItem(footer));
121114
}
122115

123-
124116
public DocumentBuilder SetFooter(Stream footer)
125117
{
126118
return this.SetFooter(new ContentItem(footer));

0 commit comments

Comments
 (0)