Word控件Spire.Doc 转换教程(十九): 在 C#、VB.NET 中将 RTF 转换为 PDF

本篇文章主要介绍了如何使用 Spire.Doc 在 C#、VB.NET 中将 RTF 转换为 PDF,欢迎查阅!

即使在第三方程序集的帮助下,RTF 到 PDF 的转换也不是一件容易的事,因为它们中的大多数不支持直接加载带有 .rtf 扩展名的文件。但是,您可以在本节中的应用程序中轻松地将 RTF 转换为 PDF,因为只使用了三行代码。

Spire.Doc for .NET 是一个 .NET Word 组件,使您可以直接加载带有 .rtf 扩展名的文件,然后在 C#、VB.NET 中将 RTF 转换为 PDF。目标 PDF 与原始 RTF 文件一样清晰。下面是目标PDF的有效截图。

RTF 转 PDF

随意下载 Spire.Doc for .NET以在 C# 和 VB.NET 中将 RTF 转换为 PDF 或尝试 Spire.doc 的其他功能 。

[C#]

using System;using System.Collections.Generic;using System.Linq;using System.Text;using Spire.Doc;namespace RTF2Pdf{class Program{static void Main(string[] args){Document doc = new Document();doc.LoadFromFile("sample.rtf", FileFormat.Rtf);doc.SaveToFile("test.pdf", FileFormat.PDF);}}}

[VB.NET]

Imports SystemImports System.Collections.GenericImports System.LinqImports System.TextImports Spire.DocNamespace RTF2PdfClass ProgramPrivate Shared Sub Main(ByVal args() As String)Dim doc As Document = New Documentdoc.LoadFromFile("sample.rtf", FileFormat.Rtf)doc.SaveToFile("test.pdf", FileFormat.PDF)End SubEnd ClassEnd Namespace

除了将 RTF 转换为 PDF,Spire.Doc 还可以使用 C#、VB.NET将Word 转换为 PDF、Word 到 Text、Word 到 HTML、Word 到 XML、Word 到 RTF、Word 到 Tiff 。此外,Spire.Doc 支持将HTML 转换为 Word、HTML 到 Image、RTF 到 HTML等。最后,Spire.Doc 使用户能够在没有 Microsoft Office Word 自动化的情况下阅读、编写和操作您的 Word 文档。


欢迎下载|体验更多E-iceblue产品

如需获取更多产品相关信息请咨询在线客服  

aspose最新版合集


标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2022年1月13日
下一篇 2022年1月13日

相关推荐

发表回复

登录后才能评论