diff --git a/src/iTextSharp.LGPLv2.Core.FunctionalTests/Issues/Issue24.cs b/src/iTextSharp.LGPLv2.Core.FunctionalTests/Issues/Issue24.cs new file mode 100644 index 0000000..2b9a112 --- /dev/null +++ b/src/iTextSharp.LGPLv2.Core.FunctionalTests/Issues/Issue24.cs @@ -0,0 +1,61 @@ +using System.Collections; +using System.IO; +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 +{ + /// + /// https://github.com/VahidN/iTextSharp.LGPLv2.Core/issues/24 + /// + [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 props = new Hashtable + { + { "font_factory", new UnicodeFontProvider() } // Always use Unicode fonts + }; + + var document = new Document(); + PdfWriter.GetInstance(document, stream); + document.AddAuthor(TestUtils.Author); + document.Open(); + var objects = HtmlWorker.ParseToList( + new StringReader(@"This is a test +
+ + Hi + "), + styles, + props + ); + foreach (IElement element in objects) + { + document.Add(element); + } + + document.Close(); + stream.Dispose(); + + TestUtils.VerifyPdfFileIsReadable(pdfFilePath); + } + } +} \ No newline at end of file