Knowledgebase (2345)
Children categories
Whatever solution you use to convert RTF to PDF before, the solution that will be introduced is the easiest method to clearly realize your RTF to PDF conversion task. The whole process can be accomplished through three lines of key code in your WPF application via a Word component Spire.Doc for WPF.

Now, please download Spire.Doc for WPF and convert your RTF to PDF by the code below:
using Spire.Doc;
namespace WPFRTFtoPDF
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
Document doc = new Document();
doc.LoadFromFile(@"..\WPFRTFtoPDF.rtf", FileFormat.Rtf);
doc.SaveToFile("test.pdf", FileFormat.PDF);
}
}
}
Imports Spire.Doc
Namespace WPFRTFtoPDF
Public Partial Class MainWindow
Inherits Window
Public Sub New()
InitializeComponent()
End Sub
Private Sub button1_Click(sender As Object, e As RoutedEventArgs)
Dim doc As New Document()
doc.LoadFromFile("..\WPFRTFtoPDF.rtf", FileFormat.Rtf)
doc.SaveToFile("test.pdf", FileFormat.PDF)
End Sub
End Class
End Namespace
For comparison, I put the original RTF file below:

Spire.Doc is a standalone word component, which enables users to perform a wide range of word document processing tasks in WPF, .NET and Silverlight without installing MS Word on system.
Word Find function can enable users to search for specific text or phrase quickly. Generally speaking, the found text will be highlighted automatically in order to distinguish from other contents. Also, users can format found text, such as set it as italic, bold etc.
Spire.Doc for WPF, a professional WPF component on manipulating Word, enables users to find and highlight text in Word with WPF. With this Word WPF component, developers can invoke doc.FindAllString(text string, bool caseSensitive, bool wholeWord) method directly to find text in Word. And for highlighting found text, developers need Firstly, use TextSelection, the class Spire.Doc for WPF provides, to save found string. Then, use foreach sentence to get each selection in this TextSelection. Finally, set HighlightColor, one properties of TextRange.CharacterFormat, for text in selection.
Below, the screenshot shows a Word document whose specified text has be found and highlighted.

Download and install Spire.Doc for WPF and then use the codes below to Find and Highlight Text in Word
Code Sample:
using Spire.Doc;
using Spire.Doc.Documents;
using System.Drawing;
using System.Windows;
namespace WpfApplication1
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
//Load Document
Document doc = new Document();
doc.LoadFromFile(@"E:\work\Documents\A GOOD MAN IS HARD TO FIND.docx");
//Find Text
TextSelection[] textSelections = doc.FindAllString("Bailey", true, true);
//Highlight Text
foreach (TextSelection selection in textSelections)
{
selection.GetAsOneRange().CharacterFormat.HighlightColor = Color.Green;
}
//Save Document
doc.SaveToFile("FindText.docx", FileFormat.Docx2010);
System.Diagnostics.Process.Start("FindText.docx");
}
}
}
Imports Spire.Doc
Imports Spire.Doc.Documents
Imports System.Drawing
Imports System.Windows
Namespace WpfApplication1
Public Partial Class MainWindow
Inherits Window
Public Sub New()
InitializeComponent()
End Sub
Private Sub button1_Click(sender As Object, e As RoutedEventArgs)
'Load Document
Dim doc As New Document()
doc.LoadFromFile("E:\work\Documents\A GOOD MAN IS HARD TO FIND.docx")
'Find Text
Dim textSelections As TextSelection() = doc.FindAllString("Bailey", True, True)
'Highlight Text
For Each selection As TextSelection In textSelections
selection.GetAsOneRange().CharacterFormat.HighlightColor = Color.Green
Next
'Save Document
doc.SaveToFile("FindText.docx", FileFormat.Docx2010)
System.Diagnostics.Process.Start("FindText.docx")
End Sub
End Class
End Namespace
Spire.Doc is a Microsoft Word component, which enables users to perform a wide range of Word document processing tasks directly, such as generate, read, write and modify Word document in WPF, .NET and Silverlight.
PDF Split is always needed by programmers and developers. It is very convenient to split a PDF file to multiple files by using online PDF split tools, you can split PDF in a page range as well as only extract a unique page. However, if you want to split a huge PDF document to hundreds of files, you have to try at least dozens of times, which, undoubtedly, takes too much time. Furthermore, when the network goes slowly, an error is likely to occur, sometimes, the file is reported to be damaged or corrupted. While using Spire.PDF for WPF, you can easily split huge PDF document up to hundreds of pages without any worry of the document safety in your WPF application.
By using Spire.PDF, you can achieve the effect as below:

Spire.PDF for WPF, as a WPF PDF component, allows users to create, read, write and manipulate PDF documents without using Adobe Acrobat or any third party component library. As for PDF split task, you can realize it by below methods:
doc.Split(pattern):
When splitting a PDF document to multiple PDF files, each PDF file is made of one page from the original PDF file. Split method works well since it can quickly split your PDF file and there is only one parameter passed to provide a template name of the destination PDF file.
String.Format(pattern, doc.Pages.Count - 1):
"String.Format" method provides great convenience for you to preview an existing file by returning the PDF file name that you want to process. The second parameter String.Format method is used to point out the index item which starts from 0.
The key step of PDF split task only requires four lines of code, before your start your PDF split project, please download Spirel.PDF for WPF first, then you can invoke the key code below to split any PDF you want.
String pattern = "SplitDocument-{0}.pdf";
doc.Split(pattern);
String lastPageFileName= String.Format(pattern, doc.Pages.Count - 1);
doc.Close();
Dim pattern As String = "SplitDocument-{0}.pdf"
doc.Split(pattern)
Dim lastPageFileName As String = String.Format(pattern, doc.Pages.Count - 1)
doc.Close()
Obviously, using this WPF PDF component, PDF can be split absolutely according to your requirements. Enjoy fast speed, high quality and free choices to build your application to split PDF right now.