Browse Source
- Add the integration of [LibreOffice](https://www.libreoffice.org) PDF export - Add the integration of [Spire.XLS](https://www.e-iceblue.cn/spirexls/spire-xls-for-net-program-guide-content.html) PDF exportpull/1249/head
21 changed files with 496 additions and 3 deletions
@ -0,0 +1,3 @@ |
|||||
|
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
||||
|
<ConfigureAwait /> |
||||
|
</Weavers> |
||||
@ -0,0 +1,30 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
||||
|
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
||||
|
<xs:element name="Weavers"> |
||||
|
<xs:complexType> |
||||
|
<xs:all> |
||||
|
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
||||
|
<xs:complexType> |
||||
|
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:all> |
||||
|
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:schema> |
||||
@ -0,0 +1,21 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\..\..\configureawait.props" /> |
||||
|
<Import Project="..\..\..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFrameworks>net8.0;net9.0</TargetFrameworks> |
||||
|
<AssemblyName>LINGYUN.Abp.Exporter.Pdf.LibreOffice</AssemblyName> |
||||
|
<PackageId>LINGYUN.Abp.Exporter.Pdf.LibreOffice</PackageId> |
||||
|
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
||||
|
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
||||
|
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
||||
|
<Nullable>enable</Nullable> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\LINGYUN.Abp.Exporter.Pdf\LINGYUN.Abp.Exporter.Pdf.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,17 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Exporter.Pdf.LibreOffice; |
||||
|
|
||||
|
[DependsOn(typeof(AbpExporterPdfModule))] |
||||
|
public class AbpExporterPdfLibreOfficeModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
if (!LibreOfficeCommands.IsLibreOffliceInstalled()) |
||||
|
{ |
||||
|
throw new Volo.Abp.AbpInitializationException("Libreoffice not installed in the current operation environment of the host, please refer to the document after installation using ` AbpExporterPdfLibreOfficeModule ` module."); |
||||
|
} |
||||
|
context.Services.AddTransient<IExcelToPdfProvider, LibreOfficeExcelToPdfProvider>(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,103 @@ |
|||||
|
using System; |
||||
|
using System.Diagnostics; |
||||
|
using System.IO; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Exporter.Pdf.LibreOffice; |
||||
|
|
||||
|
public class LibreOfficeCommands |
||||
|
{ |
||||
|
public static string WindowsCli { get; set; } = "soffice.com"; |
||||
|
public static string WindowsCliDir { get; set; } = "C:\\Program Files\\LibreOffice\\program\\"; |
||||
|
|
||||
|
public static string UnixCli { get; set; } = "libreoffice"; |
||||
|
public static string UnixCliDir { get; set; } = ""; |
||||
|
|
||||
|
public static string GetCli() |
||||
|
{ |
||||
|
if (OperatingSystem.IsWindows()) |
||||
|
{ |
||||
|
return Path.Combine(WindowsCliDir, WindowsCli); |
||||
|
} |
||||
|
|
||||
|
// 详细的操作系统版本: https://zh-cn.libreoffice.org/get-help/system-requirements/
|
||||
|
if (OperatingSystem.IsLinux() || OperatingSystem.IsMacOS()) |
||||
|
{ |
||||
|
return Path.Combine(UnixCliDir, UnixCli); |
||||
|
} |
||||
|
|
||||
|
throw new PlatformNotSupportedException($"The current platform {Environment.OSVersion.ToString()} does not support the libreoffice runtime library"); |
||||
|
} |
||||
|
|
||||
|
public static bool IsLibreOffliceInstalled() |
||||
|
{ |
||||
|
return LibreOfficeCommands.IsLibreOfficeAvailable(GetCli()); |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// LibreOffice是否可用
|
||||
|
/// </summary>
|
||||
|
/// <param name="commandFile"></param>
|
||||
|
/// <returns></returns>
|
||||
|
public static bool IsLibreOfficeAvailable(string commandFile) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
var process = new Process |
||||
|
{ |
||||
|
StartInfo = new ProcessStartInfo |
||||
|
{ |
||||
|
FileName = commandFile, |
||||
|
Arguments = "--version", |
||||
|
RedirectStandardOutput = true, |
||||
|
RedirectStandardError = true, |
||||
|
UseShellExecute = false, |
||||
|
CreateNoWindow = true |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
process.Start(); |
||||
|
var output = process.StandardOutput.ReadToEnd(); |
||||
|
|
||||
|
process.WaitForExit(); |
||||
|
|
||||
|
return process.ExitCode == 0 && output.Contains("LibreOffice"); |
||||
|
} |
||||
|
catch |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// Excel转换为Pdf
|
||||
|
/// </summary>
|
||||
|
/// <param name="excelFile"></param>
|
||||
|
/// <param name="outputPath"></param>
|
||||
|
/// <exception cref="Exception"></exception>
|
||||
|
public async static Task ExcelToPdf(string excelFile, string outputPath, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
cancellationToken.ThrowIfCancellationRequested(); |
||||
|
|
||||
|
var start = new ProcessStartInfo |
||||
|
{ |
||||
|
FileName = GetCli(), |
||||
|
Arguments = $"--headless --convert-to pdf \"{excelFile}\" --outdir \"{outputPath}\"", |
||||
|
RedirectStandardOutput = true, |
||||
|
UseShellExecute = false, |
||||
|
CreateNoWindow = true, |
||||
|
}; |
||||
|
|
||||
|
var process = new Process |
||||
|
{ |
||||
|
StartInfo = start, |
||||
|
}; |
||||
|
process.Start(); |
||||
|
|
||||
|
await process.WaitForExitAsync(cancellationToken); |
||||
|
|
||||
|
if (process.ExitCode != 0) |
||||
|
{ |
||||
|
throw new Exception($"Excel failed to convert to PDF. Error code: {process.ExitCode}"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,52 @@ |
|||||
|
using System; |
||||
|
using System.IO; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.IO; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Exporter.Pdf.LibreOffice; |
||||
|
public class LibreOfficeExcelToPdfProvider : IExcelToPdfProvider |
||||
|
{ |
||||
|
public async virtual Task<Stream> ParseAsync(Stream excelStream, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
var outputPath = Path.Combine(Path.GetTempPath(), "excel2pdf"); |
||||
|
|
||||
|
DirectoryHelper.CreateIfNotExists(outputPath); |
||||
|
|
||||
|
var templateFileId = Guid.NewGuid().ToString(); |
||||
|
var tempExcelFile = Path.Combine(outputPath, $"{templateFileId}.xlsx"); |
||||
|
var tempPdfFile = Path.Combine(outputPath, $"{templateFileId}.pdf"); |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
if (!File.Exists(tempExcelFile)) |
||||
|
{ |
||||
|
using (var excelFile = File.Create(tempExcelFile)) |
||||
|
{ |
||||
|
await excelStream.CopyToAsync(excelFile, cancellationToken); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
await LibreOfficeCommands.ExcelToPdf(tempExcelFile, outputPath, cancellationToken); |
||||
|
|
||||
|
var pdfStream = new MemoryStream(); |
||||
|
|
||||
|
using (var pdfFileStream = File.OpenRead(tempPdfFile)) |
||||
|
{ |
||||
|
await pdfFileStream.CopyToAsync(pdfStream, cancellationToken); |
||||
|
pdfStream.Seek(0, SeekOrigin.Begin); |
||||
|
} |
||||
|
|
||||
|
return pdfStream; |
||||
|
} |
||||
|
catch |
||||
|
{ |
||||
|
throw; |
||||
|
} |
||||
|
finally |
||||
|
{ |
||||
|
FileHelper.DeleteIfExists(tempExcelFile); |
||||
|
FileHelper.DeleteIfExists(tempPdfFile); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
# LINGYUN.Abp.Exporter.Pdf.LibreOffice |
||||
|
|
||||
|
> LibreOffice is Free and Open Source Software. Development is open to new talent and new ideas, and our software is tested and used daily by a large and devoted user community. |
||||
|
|
||||
|
此模块使用本地 `LibreOffice` 命令行实现将Excel转换为Pdf, 请引用此模块前确保已安装有 `LibreOffice`, 如未安装在默认目录, 请在使用前手动指定安装目录. |
||||
|
|
||||
|
## 配置使用 |
||||
|
|
||||
|
|
||||
|
```csharp |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AbpExporterPdfLibreOfficeModule) |
||||
|
)] |
||||
|
public class YouProjectModule : AbpModule |
||||
|
{ |
||||
|
public override void PreConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
// 手动指定安装目录 |
||||
|
LibreOfficeCommands.WindowsCliDir = "path\\to\\libreoffice"; |
||||
|
LibreOfficeCommands.UnixCliDir = "path/to/libreoffice"; |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
|
||||
@ -0,0 +1,3 @@ |
|||||
|
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
||||
|
<ConfigureAwait /> |
||||
|
</Weavers> |
||||
@ -0,0 +1,30 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
||||
|
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
||||
|
<xs:element name="Weavers"> |
||||
|
<xs:complexType> |
||||
|
<xs:all> |
||||
|
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
||||
|
<xs:complexType> |
||||
|
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:all> |
||||
|
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:schema> |
||||
@ -0,0 +1,25 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\..\..\configureawait.props" /> |
||||
|
<Import Project="..\..\..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFrameworks>net8.0;net9.0</TargetFrameworks> |
||||
|
<AssemblyName>LINGYUN.Abp.Exporter.Pdf.SpireLib</AssemblyName> |
||||
|
<PackageId>LINGYUN.Abp.Exporter.Pdf.SpireLib</PackageId> |
||||
|
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
||||
|
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
||||
|
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
||||
|
<Nullable>enable</Nullable> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Spire.XLS" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\LINGYUN.Abp.Exporter.Pdf\LINGYUN.Abp.Exporter.Pdf.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,13 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Exporter.Pdf.SpireLib; |
||||
|
|
||||
|
[DependsOn(typeof(AbpExporterPdfModule))] |
||||
|
public class AbpExporterPdfSpireLibModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
context.Services.AddTransient<IExcelToPdfProvider, SpireExcelToPdfProvider>(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
using Spire.Xls; |
||||
|
using System.IO; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Exporter.Pdf.SpireLib; |
||||
|
|
||||
|
public class SpireExcelToPdfProvider : IExcelToPdfProvider |
||||
|
{ |
||||
|
public virtual Task<Stream> ParseAsync(Stream excelStream, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
using var workBook = new Workbook(); |
||||
|
Stream memoryStream = new MemoryStream(); |
||||
|
workBook.LoadFromStream(excelStream); |
||||
|
var workSheet = workBook.Worksheets[0]; |
||||
|
workSheet.SaveToPdfStream(memoryStream); |
||||
|
|
||||
|
return Task.FromResult(memoryStream); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,25 @@ |
|||||
|
# LINGYUN.Abp.Exporter.Pdf.SpireLib |
||||
|
|
||||
|
> Spire.XLS for .NET 是一款专业的 .NET Excel 组件, 它可以用在各种 .NET 框架中,包括 .NET Core、.NET 5.0、.NET 6.0、.NET 7.0、.NET Standard、 Xamarin、Mono Android、ASP.NET 和 Windows Forms 等相关的 .NET 应用程序。Spire.XLS for .NET 提供了一个对象模型 Excel API,使开发人员可以快速地在 .NET 平台上完成对 Excel 的各种编程操作,如根据模板创建新的 Excel 文档,编辑现有 Excel 文档以及对 Excel 文档进行转换。 |
||||
|
|
||||
|
此模块使用 [Spire.XLS](https://www.e-iceblue.cn/spirexls/spire-xls-for-net-program-guide-content.html) 实现将Excel转换为Pdf,请在使用前配置许可. |
||||
|
|
||||
|
## 配置使用 |
||||
|
|
||||
|
|
||||
|
```csharp |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AbpExporterPdfModule) |
||||
|
)] |
||||
|
public class YouProjectModule : AbpModule |
||||
|
{ |
||||
|
public override void PreConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
// 配置许可 |
||||
|
Spire.Xls.License.LicenseProvider.SetLicense("xxx"); |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
|
||||
@ -0,0 +1,3 @@ |
|||||
|
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
||||
|
<ConfigureAwait /> |
||||
|
</Weavers> |
||||
@ -0,0 +1,30 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
||||
|
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
||||
|
<xs:element name="Weavers"> |
||||
|
<xs:complexType> |
||||
|
<xs:all> |
||||
|
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
||||
|
<xs:complexType> |
||||
|
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:all> |
||||
|
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:attribute> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:schema> |
||||
@ -0,0 +1,21 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\..\..\configureawait.props" /> |
||||
|
<Import Project="..\..\..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0;net9.0</TargetFrameworks> |
||||
|
<AssemblyName>LINGYUN.Abp.Exporter.Pdf</AssemblyName> |
||||
|
<PackageId>LINGYUN.Abp.Exporter.Pdf</PackageId> |
||||
|
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
||||
|
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
||||
|
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
||||
|
<Nullable>enable</Nullable> |
||||
|
<RootNamespace /> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Volo.Abp.Core" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,8 @@ |
|||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Exporter.Pdf; |
||||
|
|
||||
|
public class AbpExporterPdfModule : AbpModule |
||||
|
{ |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,10 @@ |
|||||
|
using System.IO; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Exporter.Pdf; |
||||
|
|
||||
|
public interface IExcelToPdfProvider |
||||
|
{ |
||||
|
Task<Stream> ParseAsync(Stream excelStream, CancellationToken cancellationToken = default); |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
using System.IO; |
||||
|
using System.Threading; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace LINGYUN.Abp.Exporter.Pdf; |
||||
|
|
||||
|
[Dependency(TryRegister = true)] |
||||
|
public class NullExcelToPdfProvider : IExcelToPdfProvider, ISingletonDependency |
||||
|
{ |
||||
|
private readonly static Stream _nullStreamCache = Stream.Null; |
||||
|
public virtual Task<Stream> ParseAsync(Stream excelStream, CancellationToken cancellationToken = default) |
||||
|
{ |
||||
|
return Task.FromResult(_nullStreamCache); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,38 @@ |
|||||
|
# LINGYUN.Abp.Exporter.Pdf |
||||
|
|
||||
|
Pdf导出模块 |
||||
|
|
||||
|
## 配置使用 |
||||
|
|
||||
|
|
||||
|
```csharp |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AbpExporterPdfModule) |
||||
|
)] |
||||
|
public class YouProjectModule : AbpModule |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
``` |
||||
|
|
||||
|
> 导出数据 |
||||
|
```csharp |
||||
|
public class ExportDemoClass |
||||
|
{ |
||||
|
private readonly IExcelToPdfProvider _exporterProvider; |
||||
|
|
||||
|
public ExportDemoClass(IExcelToPdfProvider exporterProvider) |
||||
|
{ |
||||
|
_exporterProvider = exporterProvider; |
||||
|
} |
||||
|
|
||||
|
public async virtual Task<IRemoteStreamContent> ExportAsync(Stream excelStream) |
||||
|
{ |
||||
|
var stream = await _exporterProvider.ParseAsync(excelStream); |
||||
|
|
||||
|
return new RemoteStreamContent(stream, "demo.pdf"); |
||||
|
} |
||||
|
} |
||||
|
``` |
||||
|
|
||||
Loading…
Reference in new issue