-
Notifications
You must be signed in to change notification settings - Fork 149
/
Issue24.cs
64 lines (55 loc) · 2.15 KB
/
Issue24.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
64
using System.IO;
using System.util;
using iTextSharp.text;
using iTextSharp.text.html;
using iTextSharp.text.html.simpleparser;
using iTextSharp.text.pdf;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace iTextSharp.LGPLv2.Core.FunctionalTests.Issues;
/// <summary>
/// https://github.com/VahidN/iTextSharp.LGPLv2.Core/issues/24
/// </summary>
[TestClass]
public class Issue24
{
[TestMethod]
public void Verify_Issue24_CanBe_Processed()
{
var pdfFilePath = TestUtils.GetOutputFileName();
var stream = new FileStream(pdfFilePath, FileMode.Create);
// create a StyleSheet
var styles = new StyleSheet();
// set the default font's properties
styles.LoadTagStyle(HtmlTags.BODY, "encoding", "Identity-H");
styles.LoadTagStyle(HtmlTags.BODY, HtmlTags.FONT, "Tahoma");
styles.LoadTagStyle(HtmlTags.BODY, "size", "16pt");
FontFactory.Register(TestUtils.GetTahomaFontPath());
var unicodeFontProvider = FontFactoryImp.Instance;
unicodeFontProvider.DefaultEmbedding = BaseFont.EMBEDDED;
unicodeFontProvider.DefaultEncoding = BaseFont.IDENTITY_H;
var props = new NullValueDictionary<string, object>
{
{ "font_factory", unicodeFontProvider },
};
var document = new Document();
PdfWriter.GetInstance(document, stream);
document.AddAuthor(TestUtils.Author);
document.Open();
var objects = HtmlWorker.ParseToList(
new StringReader(@"<b>This is a test</b>
<br/>
<span style='color:blue;font-size:20pt;font-family:tahoma;font-style:italic;font-weight:bold'>
<b>Hi<b/>
</span>"),
styles,
props
);
foreach (var element in objects)
{
document.Add(element);
}
document.Close();
stream.Dispose();
TestUtils.VerifyPdfFileIsReadable(pdfFilePath);
}
}