Budokan1987, Budokan1987 wrote > public static String stringFormatoUTF8(String stringIN) > { > try > { > if (stringIN.length() == 0) > { > stringIN = " "; > } > > byte[] arrayAux = stringIN.getBytes("ISO-8859-1"); > String stringOUT = new String(arrayAux, "UTF-8"); > > return stringOUT; > } > catch(IOException error) > { > System.err.println(error.getMessage()); > return ""; > } > } > > And i call it in this way: > > cell = new PdfPCell(new Paragraph( Fmt.stringFormatoUTF8("N° Operación:"), > font12B )); > > But, for each paragraph that i add in the document, i must call the > function. > > Is there a way to set the document encoding?, like, for example, > document.setEncoding("UTF-8");
The fact that you have to apply that stringFormatoUTF8 method to a string before you can properly use it, shows that your initial string contents are broken. Characters in a Java String are expected to be UTF-16 encoded 2-byte entities, not something else which requires re-decoding. If you get those broken strings from your database access layer, either that layer is broken, or the database connection is wrongly configured, or the database is wrongly configured, or the contents of the database already are broken. Anyway it should be fixed as far down in that stack as possible. Regards, Michael -- View this message in context: http://itext-general.2136553.n4.nabble.com/Is-there-a-way-to-set-the-Document-encoding-tp4660577p4660584.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions iText(R) is a registered trademark of 1T3XT BVBA. Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php