iText character not shown - java

I'm working in java webdynpro. I've created a PDF with iText but not all character are shown in the pdf.
In my case I want to fill the field TextField17Place in my pdf with the value: D'entrée.
form.setField("TextField17Place", StandLocationString);
After creating the pdf, the field is filled but without the single quote.
Result: Dentrée
Do I need to implement a new font or is there a special code provided for single quote?

Related

Why am I getting extra symbols when replacing Arial Narrow?

I'm using iText in my Java application to replace a certain string in a PDF document. I noticed extra symbols appear when the original font used in the PDF doc was Arial Narrow.
As you can see in the example below, the string ##[PORTFOLIO-123456789] was replaced with the string vlopezbo. It worked just fine when the font was Arial or Futura. However, in the case of Arial Narrow, extra square-like symbols where added to the right after the replacement. Trying to figure out why?
Please notice square symbols on the right

Using iText to do text replacement in PDF, first sentence in each paragraph is getting broken up

I'm using version 7.1.3 of the iText library for Java. I'm doing text replacement on a PDF file template, to create a new PDF file, and the first sentence within each paragraph in the new file is getting broken up.
In other words, a line break seems to be getting added somehow to the middle of the first sentence in each paragraph. Also, some text that was centered within the original PDF doesn't get centered within the new PDF.
Any ideas as to how to resolve this?

Blur sensitive text in pdf

I want to blur sensitive information in pdf file. I read about pyPdf in python and PDFBox of java but I could not get how to search and replace text in pdf file. By replacing I mean blur or even asterik character.
I also thought of a step in which I can take image of very page of pdf and then show them in html one by one. But then the same problem is there how to replace text in those images?

how to create persian content in pdf using eclipse

I have a problem with inserting UNICODE characters in a PDF file in eclipse.
There is some solution for this that it is not very efficient for me.
The solution is like this.
document.add(new Paragraph("Unicode: \u0418", new Font(bfComic, 12)));
I want to retrieve data from a database and show them to the user and my characters are in Arabic script and sometimes in Farsi script.
What solution do you suggest?
thanks
You are experiencing different problems:
Encoding of the data:
Please download chapter 2 of my book and go to section 2.2.2 entitled "The Phrase object: a List of Chunks with leading". In this section, look for the title "Database encoding versus the default CharSet used by the JVM".
You will see that database values are retrieved like this:
String name1 = new String(rs.getBytes("given_name"), "UTF-8");
That’s because the database contains different names with special characters. You risk that these special characters are displayed as gibberish if you would retrieve the field like this:
String name2 = rs.getString("given_name")
Encoding of the font:
You create your font like this:
Font font = new Font(bfComic, 12);
You don't show how you create bfComic, but I assume that this object is a BaseFont object using IDENTITY_H as encoding.
Writing from right to left / making ligatures
Although your code will work to show a single character, it won't work to show a sentence correctly.
Suppose that name1 is the Arabic version of the name "Lawrence of Arabia" and that we want to write this name to a PDF. This is done three times in the following screen shot:
The first line is wrong, because the characters are in the wrong order. They are written from left to right whereas they should be written from right to left. This is what will happen when you do:
document.add(name1);
Even if the encoding is correct, you're rendering the text incorrectly.
The second line is also wrong. The characters are now in the correct order, but no ligatures are made: ل followed by و should be combined into a single glyph: لو
You can only achieve this by adding the content to a ColumnText or PdfPCell object, and by setting the run direction to PdfWriter.RUN_DIRECTION_RTL. For instance:
pdfCell.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
Now the text will be rendered correctly.
This is explained in chapter 11 of my book. You can find a full example here: Ligatures2

how to manage formatting of text when read a save file?

i have a java applet application in which i use rich text area . i write URDU the national language of PAKISTAN. i managed to do so with uni codes. the problem is, when i write urdu in text area and select a font and color for each line it do all of this but when i save this file using UTF-8 encoding and then open it again it shows all text formatted as i choose format of last line.
my requirement is to open file as it is saved. i mean each file should have same formatting as i done before saving.
I'm still suffering with this problem even after bounty can any one help! dated 07-06-2010.
See, when you actually format text using some font and color, it will generate some RTF/HTML code right? You should try to get the RTF/HTML of the text area so that all your formatting can be saved in a file.
Basically all its a text file, so you need to get it with all code right?
Check this link for RTF formatted text saving mechanism.
Java JTextPane RTF Save
Also check HTMLEditorKit for more info.
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/text/html/HTMLEditorKit.html
thanks.
UTF-8 is an assignment of codes to characters. For convenience a decision was made that the lowest 127 codes are the same in ASCII and UTF-8. For all characters the codes differ.
UTF-8 Fonts have a character map (cmap) which assigned unicode code to their glyphs. There are very few fonts that cover large portions of the unicode range (Arial Unicode and Gentium i know, there are some others), and to get full coverage in a rendering solution, you have to mix fonts.
To be able to display arbitray Unicode texts, you therefore have to create a set of fonts with one as the default font and fallback fonts for the unicode characters that are not contained the default font. Back to Java and your Textpane: If you select a font for a given part of text in your Textpane, this only means that to render the text glyph are used from the selected font. But the text itself is not associated with the font in any means.
So you have two options:
You don't just store the UTF-8 text,
but also information about the
selected font, or
more interesting:
You store the text simply as UTF-8
and apply fonts after loading the
text into your textpanel!

Categories