将自定义字体应用于itextsharp中的html [英] Apply custom font to html in itextsharp

查看:63
本文介绍了将自定义字体应用于itextsharp中的html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有代码

FontFactory.Register(Server.MapPath("includes/fonts/Rockwell-Light.ttf"));
    StyleSheet style = new StyleSheet();
    style.LoadTagStyle("div", "face", "customfont");
    style.LoadTagStyle("div","encoding",BaseFont.CP1250);


foreach (IElement element in HTMLWorker.ParseToList(new StringReader("<div>" + getProductDescription((this.Product.Description != null) ? this.Product.Description : "") + "</div>"), style))
    {
        productDescCell.AddElement(element);
    }

我的问题是无法将字体应用于代码

my issue is could not apply font to code

推荐答案

BaseFont rockwellBold = BaseFont.CreateFont(Server.MapPath("includes/fonts/") + "ROCKB.TTF", BaseFont.CP1250, BaseFont.EMBEDDED);
Font rock_11_bold_header = new Font(rockwellBold, 11, Font.NORMAL, new BaseColor(190, 36, 34));
PdfPCell descHeadrCell = new PdfPCell();
descHeadrCell.AddElement(new Phrase("Demo"), rock_11_bold_header));

这篇关于将自定义字体应用于itextsharp中的html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆