The first one will give you 6 characters and has nothing to do with Unicode.
The second one will give you a single and correct character.
Paulo
----- Original Message -----
From: "Alan" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, May 03, 2006 12:51 AM
Subject: RE: [iText-questions] TrueTypeFont displays wrong characters
string uCode = String.Format("\\u{0:x4}", cms.CharacterIndex);
and
string uCode = new String((char) cms.CharacterIndex, 1);
give entirely different results from:
template.ShowTextAligned(PdfContentByte.ALIGN_CENTER, uCode, width/2, 0,
0);
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paulo
Soares
Sent: Wednesday, 3 May 2006 9:28 AM
To: [email protected]
Subject: Re: [iText-questions] TrueTypeFont displays wrong characters
In this case it's the same, the font really covers iso-8859-1.
Paulo
----- Original Message -----
From: "Alan" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, May 02, 2006 11:41 PM
Subject: RE: [iText-questions] TrueTypeFont displays wrong characters
Okay, I've got it: use the string from character index not the Unicode.
D'oh!
Thanks again Paulo
AlanK
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paulo
Soares
Sent: Wednesday, 3 May 2006 7:57 AM
To: [email protected]
Subject: Re: [iText-questions] TrueTypeFont displays wrong characters
I don't see where's the problem. Some character will produce a glyph. Did
you expect another glyph? And if so why?
Paulo
----- Original Message -----
From: "Alan" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, May 02, 2006 10:14 PM
Subject: RE: [iText-questions] TrueTypeFont displays wrong characters
Thank you for looking at this Paulo.
I still can't see how to set the font's symbolic flag - I can't find a
method for "setting" a Font font in PdfContentByte. Is it sufficient to
just
create a Font from the BaseFont? Should I be using some other means of
adding the character to the template?
Cheers
AlanK
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paulo
Soares
Sent: Wednesday, 3 May 2006 2:01 AM
To: [email protected]
Subject: RE: [iText-questions] TrueTypeFont displays wrong characters
Looks good to me although the font should be symbolic. This code:
Document doc = new Document(PageSize.A4);
PdfWriter writer = PdfWriter.GetInstance(doc, new
FileStream("c:\\test456.pdf",FileMode.Create));
doc.Open();
BaseFont bf = BaseFont.CreateFont("c:\\esri_12.ttf",
BaseFont.IDENTITY_H, true);
Font ff = new Font(bf, 24);
PdfPTable t = new PdfPTable(16);
t.WidthPercentage = 100;
t.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
for (int k = 0; k < 256; ++k) {
String s = new String((char)k, 1);
t.AddCell(new Phrase(s, ff));
}
doc.Add(t);
doc.Close();
produces the attached pdf. There's one other char at \u2219 that is not
represented here.
Paulo
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Alan
Sent: Monday, May 01, 2006 11:24 PM
To: [email protected]
Subject: RE: [iText-questions] TrueTypeFont displays wrong characters
Thanks Paulo,
I've been looking closer at the PDF spec and now realise where the six
characters are coming from.
My code is creating templates from individual characters and
then painting
the templates multiple times.
The font code is below:
PdfTemplate template = cb.CreateTemplate(100, 100);
BaseFont bf = BaseFont.CreateFont(pathBuilder.ToString(),
BaseFont.IDENTITY_H , BaseFont.EMBEDDED);
string uCode = String.Format(@"\u{0:x4}", cms.CharacterIndex);
float size = (float)fnt.Size;
float width = bf.GetWidthPoint(uCode, size);
template.BeginText();
template.SetFontAndSize(bf,size);
template.SetRGBColorFill(rgbColour.Red, rgbColour.Green,
rgbColour.Blue);
template.SetTextMatrix(0,0);
template.ShowTextAligned(PdfContentByte.ALIGN_CENTER, uCode,
50, 50,0);
template.EndText();
Cheers
AlanK
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On
Behalf Of Paulo
Soares
Sent: Tuesday, 2 May 2006 7:40 AM
To: [email protected]
Subject: Re: [iText-questions] TrueTypeFont displays wrong characters
----- Original Message -----
From: "Alan" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, May 01, 2006 10:33 AM
Subject: [iText-questions] TrueTypeFont displays wrong characters
>I am writing various symbol characters from a number of True
Type Fonts as
> templates to a PDF page.
>
>
>
> The code is finding the correct file and Unicode character
but the wrong
> character is being painted to the page - the characters
being painted
> don't
> even appear in the font.
>
> The only clue I have is that the font names in the FONTS
Dictionary have a
> BaseFont Name "TNGJDP+ESRINIMADNCPT" while the font
identifies itself as
> "ESRI NIMA DNC PT".
>
>
>
> Does anyone have any ideas on what I'm doing wrong?
>
You'd be amazed at the number of TT fonts, even from
reputable sources, that
have broken cmaps. You'll have to post the font and the way
you are using it
so that another hack can be put in iText.
Paulo
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web
services, security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on
Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&
dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services,
security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job
easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions