Try picking a font that supports all the glyphs you need...

Leonard


On 1/21/09 1:11 AM, "Andrew Slavin" <it...@ansarada.com> wrote:

hi,

i'm writing some text into every page of a pdf document, and that text can
be in any language. when i do that, all non-latin characters in my text just
disappear, even when i set the characterset to utf-8. here is the code in
VB.NET (i use iTextSharp v.4.1.2):

'-------------------------------------------------------------
Dim sInFilePath, sOutFilePath, sText, sCharset As String
sInFilePath = "<path to input pdf file>"
sOutFilePath = "<path to output pdf file>"
sText = "<some unicode text>"
sCharset = "utf-8"

Dim outPdf As New System.IO.FileStream(sOutFilePath,
System.IO.FileMode.Create, System.IO.FileAccess.Write)
Dim reader As New iTextSharp.text.pdf.PdfReader(sInFilePath)
Dim stamper As New iTextSharp.text.pdf.PdfStamper(reader, outPdf)
Dim baseFnt As iTextSharp.text.pdf.BaseFont =
iTextSharp.text.pdf.BaseFont.CreateFont("c:\windows\fonts\arial.ttf",
sCharset, True)

For i As Integer = 1 To reader.NumberOfPages()
 With stamper.GetOverContent(i)
  .BeginText()
  .SetFontAndSize(baseFnt, 20)
  .ShowTextAligned(iTextSharp.text.pdf.PdfContentByte.ALIGN_LEFT, sText,
100, 770, 0)
  .EndText()
 End With
Next

stamper.Close()
reader.Close()
outPdf.Close()
'-------------------------------------------------------------

in the above code, if i, for example, use cyrillic characters in sText, and
explicitly set sCharset to the cyrillic characterset "windows-1251", then it
works. but when i go 'sCharset = "utf-8"', the cyrillic characters just do
not appera in the output pdf file.

can anyone help please?


thank you in advance.

Andrew



------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php


--
Leonard Rosenthol
PDF Standards Architect
Adobe Systems Incorporated

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Reply via email to