Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/BootstrapBlazor/BootstrapBlazor.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup Condition="'$(VisualStudioVersion)' == '17.0'">
<Version>9.11.5-beta06</Version>
<Version>9.11.5-beta07</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(VisualStudioVersion)' == '18.0'">
<Version>10.0.0-rc.2.1.5</Version>
<Version>10.0.0-rc.2.1.6</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
17 changes: 17 additions & 0 deletions src/BootstrapBlazor/Options/PdfOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone

namespace BootstrapBlazor.Components;

/// <summary>
/// PdfOptions 实例用于设置导出 Pdf 相关选项
/// </summary>
public class PdfOptions
{
/// <summary>
/// 获得/设置 是否横向打印 默认 false
/// </summary>
public bool Landscape { get; set; }
}
26 changes: 4 additions & 22 deletions src/BootstrapBlazor/Services/DefaultHtml2PdfService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,11 @@ class DefaultHtml2PdfService : IHtml2Pdf
{
private const string ErrorMessage = "请增加依赖包 BootstrapBlazor.Html2Pdf 通过 AddBootstrapBlazorHtml2PdfService 进行服务注入; Please add BootstrapBlazor.Html2Pdf package and use AddBootstrapBlazorHtml2PdfService inject service";

/// <summary>
/// <inheritdoc/>
/// </summary>
public Task<byte[]> PdfDataAsync(string url) => throw new NotImplementedException(ErrorMessage);
public Task<byte[]> PdfDataAsync(string url, PdfOptions? options = null) => throw new NotImplementedException(ErrorMessage);

/// <summary>
/// <inheritdoc/>
/// </summary>
public Task<Stream> PdfStreamAsync(string url) => throw new NotImplementedException(ErrorMessage);
public Task<Stream> PdfStreamAsync(string url, PdfOptions? options = null) => throw new NotImplementedException(ErrorMessage);

/// <summary>
/// Export method
/// </summary>
/// <param name="html">html raw string</param>
/// <param name="links"></param>
/// <param name="scripts"></param>
public Task<byte[]> PdfDataFromHtmlAsync(string html, IEnumerable<string>? links = null, IEnumerable<string>? scripts = null) => throw new NotImplementedException(ErrorMessage);
public Task<byte[]> PdfDataFromHtmlAsync(string html, IEnumerable<string>? links = null, IEnumerable<string>? scripts = null, PdfOptions? options = null) => throw new NotImplementedException(ErrorMessage);

/// <summary>
/// Export method
/// </summary>
/// <param name="html">html raw string</param>
/// <param name="links"></param>
/// <param name="scripts"></param>
public Task<Stream> PdfStreamFromHtmlAsync(string html, IEnumerable<string>? links = null, IEnumerable<string>? scripts = null) => throw new NotImplementedException(ErrorMessage);
public Task<Stream> PdfStreamFromHtmlAsync(string html, IEnumerable<string>? links = null, IEnumerable<string>? scripts = null, PdfOptions? options = null) => throw new NotImplementedException(ErrorMessage);
}
12 changes: 8 additions & 4 deletions src/BootstrapBlazor/Services/IHtml2Pdf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,31 @@ public interface IHtml2Pdf
/// Export method
/// </summary>
/// <param name="url">url</param>
Task<byte[]> PdfDataAsync(string url);
/// <param name="options"></param>
Task<byte[]> PdfDataAsync(string url, PdfOptions? options = null);

/// <summary>
/// Export method
/// </summary>
/// <param name="url">url</param>
Task<Stream> PdfStreamAsync(string url);
/// <param name="options"></param>
Task<Stream> PdfStreamAsync(string url, PdfOptions? options = null);

/// <summary>
/// Export method
/// </summary>
/// <param name="html">html raw string</param>
/// <param name="links"></param>
/// <param name="scripts"></param>
Task<byte[]> PdfDataFromHtmlAsync(string html, IEnumerable<string>? links = null, IEnumerable<string>? scripts = null);
/// <param name="options"></param>
Task<byte[]> PdfDataFromHtmlAsync(string html, IEnumerable<string>? links = null, IEnumerable<string>? scripts = null, PdfOptions? options = null);

/// <summary>
/// Export method
/// </summary>
/// <param name="html">html raw string</param>
/// <param name="links"></param>
/// <param name="scripts"></param>
Task<Stream> PdfStreamFromHtmlAsync(string html, IEnumerable<string>? links = null, IEnumerable<string>? scripts = null);
/// <param name="options"></param>
Task<Stream> PdfStreamFromHtmlAsync(string html, IEnumerable<string>? links = null, IEnumerable<string>? scripts = null, PdfOptions? options = null);
}
Loading