Khmer Unicode in iText - java

I'm very new in iText.
Now I want to display Khmer Unicode in iText, but I can't do it.
Does any one know how to do it?
Please advise me.
Regards,
LeeJava

According to you, the owner of the question in another post, iText is not support Khmer Unicode.
I made summarize on this again as well on my blog: http://ask.osify.com/qa/287
Only we have to modify the source code of iText but until now no one claim that they will work on it so iText is not the right choice for us with Khmer Unicode yet until the source modify.
Another alternative solution, we have to use Openoffice doc with JODConverter, for me, I'm still in experiment this one but with quick test, it's working fine.
We just have another issue with creating the openoffice doc that could put Khmer unicode rendering as stated shortly in http://ask.osify.com/qa/318
Updated 13/01/2016
I have added the source code sample for the rendering: http://ask.osify.com/qa/613
The rendering customization with iText for Khmer Unicode added in github: https://github.com/Seuksa/iTextKhmer

if its anything like a normal font
your gonna want something like
Font myfont= new Font(BaseFont.createFont("Font location", "encoding, "embedded"));
most fonts are located under c:\windows\fonts

Font font = new Font("khmer", Font.PLAIN ,33);
iText.setFont(font);

Related

How do I setup custom fonts for use in mxGraph's pdf/image export features to support UTF-8 encoded asian language text?

I'm successfully exporting from mxGraph (Java) using the approach presented in the mxGraph exportPdf example.
However I'd like to specify a font that can support more asian-languag utf-8 encoded text, as the default font does not seem to be able to do so.
I came across this other SO question. An answer states the following "Note that you need to setup iText to map every font you need in the PDF" Can anyone provide any information as to the process involved to set up iText fonts for use by mxGraph java?
I've never tried it, but my understanding is that you need to pull in iTextAsian.jar and follow the CJK example, the key part of which is:
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);

PDF/iText : replace font defs

I'm using iText (Java lib) to process an already created PDF file.
What I would like to achieve is to replace fonts that are metric-compatible with a PDF base font with that PDF base font. This would make the PDF more "compliant" and potentially also smaller.
Here's how it would go:
Loop through the fonts used in the PDF.
If font is metric-compatible
with a PDF base font then replace font name with that font (but maintain the PDF resource name, e.g. /F13, so that we do not need to touch any text
objects). Since iText embeds in its jar the AFM files for the PDF
base fonts I'm assuming that iText actually has enough knowledge to
make this assesment. I would probably have to look at
serif/sans-serif and monotype flags as well to know if I should swap
in Helvetica, Times or Courier.
Further if metric-compatible: Remove
any font embeds for that font. (since we've replaced with a PDF base
font there's no need to embed anything .. size matters!)
An example:
An existing PDF file uses "Calibri", "Arial" and "Times". Here's how each of those should be handled.
Calibri. This font doesn't have a metric-compatible cousin among the PDF base fonts so processing for this font resource will be skipped.
Arial. This font has a metric-compatible cousin among the PDF base fonts, namely "Helvetica". The name of the font resource (attribute BaseFont I suppose) will be changed to "Helvetica" and any potential embeds will be removed.
Times. This font is already a PDF base font. Skip processing. (we may consider unembedding here if there's something to unembed, but I already know how to do that so not part of the question)
I basically get stuck on the step which is to determine metric-compatibility. Any help is greatly appreciated.
(Note: An answer based on iText 5.x is perfectly ok as I feel the recent iText 7 is still somewhat undocumented)
UPDATE
As pointed out a number of checks would need to be carried out in addition in order to do a safe replacement:
Font encoding compatibility. Not really a problem for me as fonts in the documents I'll be processing will be using WinAnsiEncoding.
Available chars in font. Not really a problem for me as I'll only be processing documents that use only ISO 8859-1 chars. Furthermore: If the PDF contains an embedded subset of a font then I'll have easily accessible knowledge about exactly which chars is used in the document for that font.
I'm sure I can figure out to check for both these conditions. (I'm blissfully naive)
I'm not trying to do a general tool. I know where the PDF's I'll be processing comes from. In any case I guess it is possible to have enough information from the PDF to skip the font substitution if it can't be determined that the substitution will be "safe".

Java iText - Get Font size and family of a text selected from a pdf file

I'm writing to inquire a bout a problem when I'm using iText library to extract text contents from PDF file.I would able to extract all the text, but couldn't find the method to extract font styles.
First you need to read the answer to this question: how can i get text formatting with iTextSharp
In this question, you'll discover that the TextRenderInfo has a getFont() method that allows you to get the PostScriptFontName. If you are in luck, this PostScriptFontName will give you information about the style.
Note that this won't always work. Please read the answer to this question: What are the ways of checking if piece of text in PDF documernt is bold using iTextSharp
That question shows an example of a font that doesn't reveal anything about its style.
To get the fontsize of a font in itext, use this code:
renderInfo.getAscentLine().getStartPoint().get(1)-
renderInfo.getDescentLine().getStartPoint().get(1)
This will give you the exact fontsize.

Apache FOP - PDF creation russian text

I have a small Java application that creates (besides other stuff) a PDF file using Apache's FOP 1.0.
Everything works fine when using latin letters. But it doesn't when there are others - e.g. cyrillic.
I don't think, it is the default problem of missing fonts, since the bookmarks within the PDF file are alright (unfortunately I can't add pics to this post).
Any ideas, what I'm doing wrong?
Thanks for your help!
Andreas
in your f:block you need to specify the font you want to use
<fo:block font-family="MS Mincho" font-size="12pt" font-weight="normal" space-after="5mm" background-color="#8BAF3F" color="white">
Of course the font should be available as well.
Thanks for the hints.
I've had set the font-family to 'Verdana', which may or may not have cyrillic letters.
Additionally I set the font-family in 'simple-page-master', so all pages using this master should be using this font.
On basis of your hints I changed the font-family to 'Arial'.
I also set the font-family in one block explicitly, just for a simple test.
I tried even a change of the system language to russian.
Unfortunately nothing worked. The changes of the font-family can be seen each and every time (Arial, Courier, Times, MS Mincho, MAC C Times) on the changed style, but there are always '#' shown.
And, most confusing, the bookmarks are alright...

add header to pdf using iText

how i can add header to each PDF page using iText 5.0.5.
This is covered in chapter 5 of iText In Action, 2nd ed. The code examples are all freely available online. In particular MovieCountries1 and MovieHistory2 both deal with page headers and footers.
It boils down to using a PdfPageEvent implementation (usually derived from PdfPageEventHelper to cut down on boilerplate) to draw into the page's Direct Content during an EndPage (or BeginPage I suppose) event.
You have to know where you want them, and you have to draw using a PdfContentByte instance, so you can't use the high-level Paragraph/Chapter/Chunk/Image/etc classes. You have to draw-this-there, draw-that-here. ColumnText can help a bit... but only for Plain Text. Anything even remotely fancy and you're on your own.
See the below link having video to show you.
http://itextpdf.com/book/chapter.php?id=4
For Header-Footer:
http://kuujinbo.info/cs/itext.aspx
http://www.codeproject.com/KB/graphics/ITextSharpHelperClass.aspx
Please Vote if this helps to you.

Categories