统一美元的iTextSharp的C $Ç符号 [英] Unicode symbols in iTextSharp

查看:457
本文介绍了统一美元的iTextSharp的C $Ç符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用一个统一code符号在我的PDF文件 iTextSharp的

I'm trying to use a Unicode symbol in my PDF file with iTextSharp.

Dim base As BaseFont = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\WINGDING.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)

Dim wd As Font = New Font(base, 12, Font.NORMAL, BaseColor.BLACK)
phrase = New Phrase("q", wd)

这是在喝酒聚会的Q.Key。但是,在PDF文件中它不工作。 它只是打印再好的字符应该的。

It's the Q.Key in Wingding. But in the PDF file it's not working. It just prints nothing where the Char should be.

在哪里错误?

推荐答案

我只是做以下和它的工作正是因为它应该。 Wingdings字体两个词作为一个右下角阴影方盒之间出现研究。唯一的一点是,我不能真正得到Wingdings字体实际嵌入自己,我相信它的一个iTextSharp的隐含规则,因为它的假设是无处不在。我试着用 WINGDNG2.TTF 和嵌入式正确。

I just did the following and it worked exactly as it should. The Wingdings font appears in between the two words as a square box with a bottom-right drop shadow. The only thing is that I can't actually get the Wingdings font to actually embed itself and I believe that its an iTextSharp implicit rule because its assumed to be everywhere. I tried with WINGDNG2.TTF and that embedded correctly.

您也许不添加短语是否正确?没有Wingdings也许一台机器上或者,你打开的?

Are you maybe not adding the Phrase correctly? Or are you opening this on a machine without Wingdings maybe?

    ''//Create a new document
    Dim Doc As New iTextSharp.text.Document(PageSize.LETTER, 20, 20, 20, 20)
    ''//Store the document on the desktop
    Dim writer = PdfWriter.GetInstance(Doc, New FileStream(Path.Combine(My.Computer.FileSystem.SpecialDirectories.Desktop, "Output.pdf"), FileMode.Create, FileAccess.Write, FileShare.Read))

    ''//Open the PDF for writing
    Doc.Open()

    ''//Insert a page
    Doc.NewPage()

    ''//Add a regular text block using the default font
    Dim Phrase = New Phrase("Hello")
    Doc.Add(Phrase)


    ''//Create our base font
    Dim base As BaseFont = BaseFont.CreateFont("C:\Windows\Fonts\wingding.ttf", BaseFont.CP1252, BaseFont.EMBEDDED)
    ''//Create our usable font
    Dim wd As Font = New Font(base, 12, iTextSharp.text.Font.NORMAL, BaseColor.BLACK)

    ''//Add a text block using Wingdings
    Phrase = New Phrase("q", wd)
    Doc.Add(Phrase)

    ''//Add a trailing text block using the default font again
    Phrase = New Phrase("Bye")
    Doc.Add(Phrase)

    ''//Close the PDF
    Doc.Close()

这篇关于统一美元的iTextSharp的C $Ç符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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