Skip to content

Commit

Permalink
Added Issue24 sample
Browse files Browse the repository at this point in the history
  • Loading branch information
VahidN committed Feb 11, 2018
1 parent b32a0a8 commit 45e4b53
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions src/iTextSharp.LGPLv2.Core.FunctionalTests/Issues/Issue24.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <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 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(@"<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 (IElement element in objects)
{
document.Add(element);
}

document.Close();
stream.Dispose();

TestUtils.VerifyPdfFileIsReadable(pdfFilePath);
}
}
}

0 comments on commit 45e4b53

Please sign in to comment.