forked from VahidN/iTextSharp.LGPLv2.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRtfTests.cs
63 lines (51 loc) · 2.1 KB
/
RtfTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.rtf;
using iTextSharp.text.rtf.parser;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace iTextSharp.LGPLv2.Core.FunctionalTests
{
[TestClass]
public class RtfTests
{
/// <summary>
/// The RtfWriter allows the creation of rtf documents via the iText system
/// </summary>
[TestMethod]
public void Verify_PDF_To_RTF_File_CanBeCreated()
{
var rtfFilePath = Path.Combine(TestUtils.GetOutputFolder(), $"{nameof(Verify_PDF_To_RTF_File_CanBeCreated)}.rtf");
var document = new Document();
var fileStream = new FileStream(rtfFilePath, FileMode.Create);
RtfWriter2.GetInstance(document, fileStream);
document.AddAuthor(TestUtils.Author);
document.Open();
var font = FontFactory.GetFont(FontFactory.HELVETICA, 16, Font.BOLD);
var parTitle = new Paragraph("This is a new document", font);
document.Add(parTitle);
document.Close();
fileStream.Dispose();
}
/// <summary>
/// RTF to PDF using iTextSharp
/// </summary>
[TestMethod]
public void Verify_RTF_To_PDF_File_CanBeCreated()
{
Verify_PDF_To_RTF_File_CanBeCreated(); // Create a sample .rtf file first
var rtfFilePath = Path.Combine(TestUtils.GetOutputFolder(), $"{nameof(Verify_PDF_To_RTF_File_CanBeCreated)}.rtf");
var inputStream = new FileStream(rtfFilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
var pdfFilePath = TestUtils.GetOutputFileName();
var outputStream = new FileStream(pdfFilePath, FileMode.Create);
var document = new Document();
PdfWriter.GetInstance(document, outputStream);
document.Open();
var parser = new RtfParser(null);
parser.ConvertRtfDocument(inputStream, document);
document.Close();
outputStream.Dispose();
inputStream.Dispose();
}
}
}