c# wpf 如何预览附件(word,pdf) 不使用office online, Microsoft.Office.Interop

问题描述 投票:0回答:1

我想在我的 wpf 应用程序中预览附件

我无法使用网络,我在本地网络中使用此应用程序

我尝试了GemBox.Pdf、spire和aspose,有收费的,谢谢3 我想预览我的 wpf 应用程序中的附件

我无法使用网络,我在本地网络中使用此应用程序

我尝试了GemBox.Pdf、spire和aspose,有收费的,谢谢3

c# wpf attachment
1个回答
0
投票

您可以使用 GroupDocs.Viewer for .NET 渲染/预览电子邮件附件(例如 Word、PDF),如下所示(API 允许渲染或生成 HTML、PDF 或 Image 格式的源文件预览):

// Specify attachment.
Attachment attachment = new Attachment("attachment-word.doc", @"C:\Output\attachment-word.doc"); 
// Create a stream for attachment.
MemoryStream attachmentStream = new MemoryStream();
//Save attachment
using (Viewer viewer = new Viewer("sample.msg"))
{
    viewer.SaveAttachment(attachment, attachmentStream); 
}
// Render attachment
using (Viewer viewer = new Viewer(attachmentStream))
{
    HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources();
    viewer.View(options);
}

API 还支持列出和提取/保存附件。它是一个独立的后端 API,可以集成到您的 C# WPF 应用程序中。请看看这个开源控制台应用程序

PS。我在 GroupDocs 担任支持开发人员/布道者。

© www.soinside.com 2019 - 2024. All rights reserved.