Discussion:
[iText-questions] iText and Asian Bitmap Fonts?
Andreas Schildbach
2005-12-16 10:27:03 UTC
Permalink
Hi all,

are there any known problems with iText and asian bitmap fonts, like
Chinese, Korean or Janapese?

I'm trying to put asian text in a PDF document, using the corresponding
asian fonts. The characters do not appear in the document unfortunately.

Regards,

Andreas
Vineet Reynolds
2005-12-16 10:33:07 UTC
Permalink
Have you made yourslef doubly sure that you have put the Asian fonts jar in
the classpath ?
I mean - do you have the iTextAsian.jar / iTextAsianCMaps.jar in the same
directory as iText.jar ?
That is first problem which people face. There is more about this in the
online tutorial.
Post by Andreas Schildbach
Hi all,
are there any known problems with iText and asian bitmap fonts, like
Chinese, Korean or Janapese?
I'm trying to put asian text in a PDF document, using the corresponding
asian fonts. The characters do not appear in the document unfortunately.
Regards,
Andreas
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log
files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
iText-questions mailing list
https://lists.sourceforge.net/lists/listinfo/itext-questions
Andreas Schildbach
2005-12-16 10:54:05 UTC
Permalink
Post by Vineet Reynolds
Have you made yourslef doubly sure that you have put the Asian fonts jar
in the classpath ?
I mean - do you have the iTextAsian.jar / iTextAsianCMaps.jar in the
same directory as iText.jar ?
I must admit that I was not aware of these files. However, I suspecting
that they just contain asian fonts, do they?

Up to this point, I am bringing my own font(s). Do I need iTextAsian.jar
at all?

Here is how I am getting the font:

Font font = new
Font(BaseFont.createFont(getClass().getResource("/classpath/ARIALUNI.TTF").getFile(),
BaseFont.WINANSI, false), PDF_FONTSIZE);

ARIALUNI.TTF is Arial Unicode and it is in the classpath.

Regards,

Andreas
Vineet Reynolds
2005-12-16 12:12:28 UTC
Permalink
I suggest that you use the CJK fonts present in iTextAsian.jar
Please do go through the tutorial. It should solve most of your problems.
As far as bitmapped fonts are concerned, they are a definite "no-no". They
usually have problems in reproducability for different font sizes; you may
end up blaming PDF when the problem is with the font. It's not for no reason
that Leonard has said they're of poor quality [ I would hardly go against
his wisdom].

And again I would recommend going through the part of the tutorial that
talks about CJK fonts.
Here is a sample PDF generated by an example in the tutorial:
http://itextdocs.lowagie.com/tutorial/fonts/getting/cjk.pdf


Make sure you have the Adobe CJK fontmap obtained at:
http://www.adobe.com/products/acrobat/acrrasianfontpack.html


An excerpt of interest for you:
If you want to use CJK fonts in iText, you need an extra jar:
iTextAsian.jar<http://itextdocs.lowagie.com/downloads/iTextAsian.jar>.
If you want to be able to read the text you generated with iText using CJK
fonts, you will also need to download and install a special font pack for
Acrobat Reader<http://www.adobe.com/products/acrobat/acrrasianfontpack.html>(or
maybe your Reader will ask you to install such a font pack upon
opening
a PDF file with CJK fonts). For the rest, creating a CJK font supported by
the iTextAsian.jar is as easy as using any other font:

BaseFont bfChinese = BaseFont.createFont("STSong-Light",
"UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
Font FontChinese = new Font(bfChinese, 12, Font.NORMAL);
Paragraph p = new Paragraph(chinese, FontChinese);
document.add(p);

Skip to the direction<http://itextdocs.lowagie.com/tutorial/fonts/styles/index.html#direction>-section
if you want to know how to write vertical text! Example: java
com.lowagie.examples.fonts.getting.ChineseJapaneseKorean<http://itextdocs.lowagie.com/examples/com/lowagie/examples/fonts/getting/ChineseJapaneseKorean.java>
Using CJK Fonts: see
cjk.pdf<http://itextdocs.lowagie.com/tutorial/fonts/getting/cjk.pdf>
Extra jars needed in your CLASSPATH: iTextAsian.jar
This is the list of fonts supported in the iTextAsian.jar:

- *Chinese Simplified:*
STSong-Light and STSongStd-Light with the encodings UniGB-UCS2-H and
UniGB-UCS2-V
- *Chinese Traditional:*
MHei-Medium, MSung-Light and MSungStd-Light with the encodings
UniCNS-UCS2-H and UniCNS-UCS2-V
- *Japanese:*
HeiseiMin-W3, HeiseiKakuGo-W5 and KozMinPro-Regular with the encodings
UniJIS-UCS2-H, UniJIS-UCS2-V, UniJIS-UCS2-HW-H and UniJIS-UCS2-HW-V
- *Korean:*
HYGoThic-Medium, HYSMyeongJo-Medium and HYSMyeongJoStd with the
encodings UniKS-UCS2-H and UniKS-UCS2-V
Andreas Schildbach
2005-12-16 12:37:02 UTC
Permalink
Post by Vineet Reynolds
I suggest that you use the CJK fonts present in iTextAsian.jar
Please do go through the tutorial. It should solve most of your problems.
As far as bitmapped fonts are concerned, they are a definite "no-no".
Thanks a lot for your help, and thanks for your advice against using
bitmapped fonts.
Post by Vineet Reynolds
If you want to be able to read the text you generated with iText using
CJK fonts, you will also need to download and install a special font
pack for Acrobat Reader
<http://www.adobe.com/products/acrobat/acrrasianfontpack.html> (or maybe
your Reader will ask you to install such a font pack upon opening a PDF
file with CJK fonts).
Isn't it possible to embed the fonts into the document? The need for
extra downloading may spoil the whole project for me, as "my" users may
not install any additional packages.

Also, did anyone make any experiences with Arial Unicode (which isn't a
bitmapped font but vector based)? Could that be used as a replacement
for the above CJK fonts? Arial Unicode is installed on the systems of my
users, because it comes with MS Office.

Regards,

Andreas
Bruno Lowagie
2005-12-16 12:50:06 UTC
Permalink
Post by Andreas Schildbach
Also, did anyone make any experiences with Arial Unicode (which isn't
a bitmapped font but vector based)?
Of course, just try the examples in the tutorial.
On the MS Windows CD you'll also find some True Type Collection (ttc files).
I'm sure there's a ttc made especially for Chinese Ideographs.
That may give you better results and more flexibility than arialuni.ttf.
Post by Andreas Schildbach
Could that be used as a replacement for the above CJK fonts?
Yes, and a subset of the font will be embedded into the PDF.
Post by Andreas Schildbach
Arial Unicode is installed on the systems of my users, because it
comes with MS Office.
Don't count on that. There's always that one user that has Linux
or some other OS. Don't exclude that user.
br,
Bruno
Vineet Reynolds
2005-12-16 12:58:07 UTC
Permalink
There is an embed flag when registering a font. You could use that. You will
need the JARs only while making the pdf, not while viewing them. The Adobe
CJK font map is to be installed at the client system only when you dont
embed the fonts. So just relax and let iText do it's job.
Paulo Soares
2005-12-16 10:35:09 UTC
Permalink
-----Original Message-----
Behalf Of Andreas Schildbach
Sent: Monday, December 12, 2005 4:00 PM
Subject: [iText-questions] iText and Asian Bitmap Fonts?
Hi all,
are there any known problems with iText and asian bitmap fonts, like
Chinese, Korean or Janapese?
Asian bitmap fonts??!!
Andreas Schildbach
2005-12-16 10:50:14 UTC
Permalink
Post by Paulo Soares
Post by Andreas Schildbach
are there any known problems with iText and asian bitmap fonts, like
Chinese, Korean or Janapese?
Asian bitmap fonts??!!
The requirement would be to use existing fonts for Chinese, Korean and
Japanese. There fonts are bitmapped and contain 18 and 24 point sizes. I
don't know if PDF is capable of using bitmapped fonts, because PDF is
mostly vector based. However, you can embed bitmapped images like JPG or
PNG.

Regards,

Andreas
Leonard Rosenthol
2005-12-16 11:57:17 UTC
Permalink
Post by Andreas Schildbach
The requirement would be to use existing fonts for Chinese, Korean
and Japanese. There fonts are bitmapped and contain 18 and 24 point sizes.
Ouch!! Sounds like a silly requirement given the poor
quality of bitmap fonts.
Post by Andreas Schildbach
I don't know if PDF is capable of using bitmapped fonts, because PDF
is mostly vector based.
It is capable via a mechanism called Type3 fonts.


Leonard

---------------------------------------------------------------------------
Leonard Rosenthol <mailto:***@pdfsages.com>
Chief Technical Officer <http://www.pdfsages.com>
PDF Sages, Inc. 215-938-7080 (voice)
215-938-0880 (fax)
Paulo Soares
2005-12-16 12:31:04 UTC
Permalink
It's really a silly requirement but the client is always right...
I'm curious about that bitmap format and the way you associate the
Unicode character to the glyph.

Paulo
-----Original Message-----
Behalf Of Leonard Rosenthol
Sent: Friday, December 16, 2005 1:56 PM
Subject: Re: [iText-questions] iText and Asian Bitmap Fonts?
Post by Andreas Schildbach
The requirement would be to use existing fonts for Chinese, Korean
and Japanese. There fonts are bitmapped and contain 18 and
24 point sizes.
Ouch!! Sounds like a silly requirement given the poor
quality of bitmap fonts.
Post by Andreas Schildbach
I don't know if PDF is capable of using bitmapped fonts, because PDF
is mostly vector based.
It is capable via a mechanism called Type3 fonts.
Leonard
--------------------------------------------------------------
-------------
Leonard Rosenthol
Chief Technical Officer <http://www.pdfsages.com>
PDF Sages, Inc. 215-938-7080 (voice)
215-938-0880 (fax)
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep
through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web.
DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
iText-questions mailing list
https://lists.sourceforge.net/lists/listinfo/itext-questions
Paulo Soares
2005-12-16 12:34:06 UTC
Permalink
Use the encoding BaseFont.IDENTITY_H.
-----Original Message-----
Behalf Of Andreas Schildbach
Sent: Friday, December 16, 2005 12:53 PM
Subject: Re: [iText-questions] iText and Asian Bitmap Fonts?
Post by Vineet Reynolds
Have you made yourslef doubly sure that you have put the
Asian fonts jar
Post by Vineet Reynolds
in the classpath ?
I mean - do you have the iTextAsian.jar /
iTextAsianCMaps.jar in the
Post by Vineet Reynolds
same directory as iText.jar ?
I must admit that I was not aware of these files. However, I
suspecting
that they just contain asian fonts, do they?
Up to this point, I am bringing my own font(s). Do I need
iTextAsian.jar
at all?
Font font = new
Font(BaseFont.createFont(getClass().getResource("/classpath/AR
IALUNI.TTF").getFile(),
BaseFont.WINANSI, false), PDF_FONTSIZE);
ARIALUNI.TTF is Arial Unicode and it is in the classpath.
Regards,
Andreas
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep
through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web.
DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
iText-questions mailing list
https://lists.sourceforge.net/lists/listinfo/itext-questions
Andreas Schildbach
2005-12-18 12:06:04 UTC
Permalink
Post by Paulo Soares
Use the encoding BaseFont.IDENTITY_H.
Just for the records: This one did the trick for MS Arial Unicode.

What does this encoding mean? It does not appear to be documented anywhere.

I am also puzzled about the fact that the resulting document is only 4
MB in size, whereas the font is 22 MB. This means that the font can't be
embedded into the document. Also also did not install the font into my
Linux system. Nevertheless, the document displays correctly in Evince.

Regards,

Andreas
Bruno Lowagie
2005-12-18 12:18:08 UTC
Permalink
Post by Andreas Schildbach
Post by Paulo Soares
Use the encoding BaseFont.IDENTITY_H.
Just for the records: This one did the trick for MS Arial Unicode.
What does this encoding mean? It does not appear to be documented anywhere.
It is mentioned in the tutorial and it will be explained in chapter 8 of
the book.
The tutorial has some serious flaws when it comes to fonts, but chapter
8 and 9
of the book will explain everything in much more detail.
Post by Andreas Schildbach
I am also puzzled about the fact that the resulting document is only 4
MB in size, whereas the font is 22 MB. This means that the font can't
be embedded into the document.
Look at the Fonts tab in the Properties window of Adobe Reader.
You will see things as CID Font and 'embedded subset'.
Only the glyphs you have used were added to the PDF;
not the complete font.
(Observe that when you use the encoding IDENTITY_H,
the value of the embedding parameter is ignored.)
Post by Andreas Schildbach
Also also did not install the font into my Linux system. Nevertheless,
the document displays correctly in Evince.
This is what I meant in an earlier reply.
Don't work with fonts that aren't embedded.
That way you don't exclude people that don't have
arialuni.ttf on their system.
br,
Bruno

Loading...