You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
700 B
C#

2 months ago
using iText.Kernel.Pdf;
namespace DS.Module.Core.Utils
{
/// <summary>
/// PDF处理工具类
/// </summary>
public static class PDFUtil
{
2 months ago
public static async void AddStrampAsync(this Stream stream)
2 months ago
{
2 months ago
ArgumentNullException.ThrowIfNull(stream, nameof(stream));
if (!stream.CanRead)
throw new ArgumentException("流不支持读取", nameof(stream));
var pdfStream = stream;
if (!stream.CanWrite)
{
pdfStream = new MemoryStream();
await stream.CopyToAsync(pdfStream);
}
2 months ago
var pdfReader = new PdfReader(stream);
2 months ago
2 months ago
}
}
}