Skip to content

Commit a32761c

Browse files
committed
chore: 更新实现防止报错
1 parent b9c741a commit a32761c

2 files changed

Lines changed: 10 additions & 46 deletions

File tree

src/components/BootstrapBlazor.Html2Pdf.Playwright/Services/DefaultPdfService.cs

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
1+
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33
// Website: https://www.blazor.zone or https://argozhang.github.io/
44

@@ -11,41 +11,23 @@ namespace BootstrapBlazor.Components;
1111
/// </summary>
1212
class DefaultPdfService : IHtml2Pdf
1313
{
14-
/// <summary>
15-
/// <inheritdoc/>
16-
/// </summary>
17-
public Task<byte[]> PdfDataAsync(string url)
14+
public Task<byte[]> PdfDataAsync(string url, PdfOptions? options = null)
1815
{
1916
return GeneratePdfFromUrlAsync(url);
2017
}
2118

22-
/// <summary>
23-
/// <inheritdoc/>
24-
/// </summary>
25-
public async Task<Stream> PdfStreamAsync(string url)
19+
public async Task<Stream> PdfStreamAsync(string url, PdfOptions? options = null)
2620
{
2721
var data = await GeneratePdfFromUrlAsync(url);
2822
return new MemoryStream(data);
2923
}
3024

31-
/// <summary>
32-
/// Export method
33-
/// </summary>
34-
/// <param name="html">html raw string</param>
35-
/// <param name="links"></param>
36-
/// <param name="scripts"></param>
37-
public Task<byte[]> PdfDataFromHtmlAsync(string html, IEnumerable<string>? links = null, IEnumerable<string>? scripts = null)
25+
public Task<byte[]> PdfDataFromHtmlAsync(string html, IEnumerable<string>? links = null, IEnumerable<string>? scripts = null, PdfOptions? options = null)
3826
{
3927
return GeneratePdfFromHtmlAsync(html, links, scripts);
4028
}
4129

42-
/// <summary>
43-
/// Export method
44-
/// </summary>
45-
/// <param name="html">html raw string</param>
46-
/// <param name="links"></param>
47-
/// <param name="scripts"></param>
48-
public async Task<Stream> PdfStreamFromHtmlAsync(string html, IEnumerable<string>? links = null, IEnumerable<string>? scripts = null)
30+
public async Task<Stream> PdfStreamFromHtmlAsync(string html, IEnumerable<string>? links = null, IEnumerable<string>? scripts = null, PdfOptions? options = null)
4931
{
5032
var data = await PdfDataFromHtmlAsync(html, links, scripts);
5133
return new MemoryStream(data);

src/components/BootstrapBlazor.Html2Pdf.Select/Services/DefaultPdfService.cs

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
1+
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33
// Website: https://www.blazor.zone or https://argozhang.github.io/
44

@@ -11,10 +11,7 @@ namespace BootstrapBlazor.Components;
1111
/// </summary>
1212
class DefaultPdfService : IHtml2Pdf
1313
{
14-
/// <summary>
15-
/// <inheritdoc/>
16-
/// </summary>
17-
public Task<byte[]> PdfDataAsync(string url)
14+
public Task<byte[]> PdfDataAsync(string url, PdfOptions? options = null)
1815
{
1916
var converter = new HtmlToPdf();
2017
var doc = converter.ConvertUrl(url);
@@ -23,10 +20,7 @@ public Task<byte[]> PdfDataAsync(string url)
2320
return Task.FromResult(result);
2421
}
2522

26-
/// <summary>
27-
/// <inheritdoc/>
28-
/// </summary>
29-
public Task<Stream> PdfStreamAsync(string url)
23+
public Task<Stream> PdfStreamAsync(string url, PdfOptions? options = null)
3024
{
3125
var stream = new MemoryStream();
3226
var converter = new HtmlToPdf();
@@ -37,13 +31,7 @@ public Task<Stream> PdfStreamAsync(string url)
3731
return Task.FromResult<Stream>(stream);
3832
}
3933

40-
/// <summary>
41-
/// Export method
42-
/// </summary>
43-
/// <param name="html">html raw string</param>
44-
/// <param name="links"></param>
45-
/// <param name="scripts"></param>
46-
public Task<byte[]> PdfDataFromHtmlAsync(string html, IEnumerable<string>? links = null, IEnumerable<string>? scripts = null)
34+
public Task<byte[]> PdfDataFromHtmlAsync(string html, IEnumerable<string>? links = null, IEnumerable<string>? scripts = null, PdfOptions? options = null)
4735
{
4836
var converter = new HtmlToPdf();
4937
var doc = converter.ConvertHtmlString(html);
@@ -52,13 +40,7 @@ public Task<byte[]> PdfDataFromHtmlAsync(string html, IEnumerable<string>? links
5240
return Task.FromResult(result);
5341
}
5442

55-
/// <summary>
56-
/// Export method
57-
/// </summary>
58-
/// <param name="html">html raw string</param>
59-
/// <param name="links"></param>
60-
/// <param name="scripts"></param>
61-
public Task<Stream> PdfStreamFromHtmlAsync(string html, IEnumerable<string>? links = null, IEnumerable<string>? scripts = null)
43+
public Task<Stream> PdfStreamFromHtmlAsync(string html, IEnumerable<string>? links = null, IEnumerable<string>? scripts = null, PdfOptions? options = null)
6244
{
6345
var stream = new MemoryStream();
6446
var converter = new SelectPdf.HtmlToPdf();

0 commit comments

Comments
 (0)