I am trying to use XMLWorker instead of HTMLWorker. My issue is with some
Windows fonts in the CSS file.
Other properties (Font Size, Font Colour, etc) within the CSS are displaying in
the PDF just fine, however the font is incorrect.
For HTMLWorker I used the following:
FontFactory.Register("c:\windows\fonts\gothic.ttf", "Century Gothic")
Dim Styles As StyleSheet = New iTextSharp.text.html.simpleparser.StyleSheet
Styles.LoadStyle("Normal", "face", "Century Gothic")
Styles.LoadStyle("Normal", "size", "10pt")
Dim TheElements = HTMLWorker.ParseToList(New StringReader(RawContent), Styles)
For i = 0 To TheElements.Count - 1
Document.Add(DirectCast(TheElements(i), IElement))
Document.Add(New Phrase(Environment.NewLine))
Next
Which displays the font (Century Gothic) correctly.
For XLMWorker I'm using the following:
FontFactory.Register("c:\windows\fonts\gothic.ttf", "Century Gothic")
Dim BCMiCss As String =
HttpContext.Current.Server.MapPath("~/App_Obout/HTMLEditor/CSS/quickformat.css")
Dim HtmlContext As HtmlPipelineContext = New HtmlPipelineContext
HtmlContext.SetTagFactory(iTextSharp.tool.xml.html.Tags.GetHtmlTagProcessorFactory)
Dim CSSResolver As ICSSResolver =
XMLWorkerHelper.GetInstance().GetDefaultCssResolver(False)
CSSResolver.AddCssFile(BCMiCss, True)
Dim Pipeline As IPipeline = New CssResolverPipeline(CSSResolver, New
HtmlPipeline(htmlContext, New PdfWriterPipeline(Document, PDFWriter)))
Dim Worker As XMLWorker = New XMLWorker(Pipeline, True)
Dim Parser As XMLParser = New XMLParser(Worker)
Parser.Parse(New StringReader(RawContent))
What do I need to do to register the "non standard" font?
Thanks in advance ~ Dean
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php