Brodster1281 wrote > I'm using iText 5.5.9 since it seems to have the most information online > on how to use, but I'm trying to figure out the best way to change text > without losing the text's formatting. Its for a pretty basic puzzle > project where every letter is the opposite (a is z, b is y, etc). I'm able > to extract the text from the pdf as a string then create a new string with > the opposite letters, but since its a string, i lose which letters are > bolded, underlined, etc.
First of all, public iText support has been moved to stackoverflow.com <http://stackoverflow.com> . That been said, "only changing the text without losing its formatting" is one of the most complicated things in PDF processing, your "pretty basic puzzle project where every letter is the opposite (a is z, b is y, etc)" for generic documents is no exception from that rule. You have to be aware of the facts that * fonts of the text may be only partially embedded; thus, if you want to replace 'a' by 'z', you might find that the font in question does not have a 'z'; * fonts may not contain the information required to recognize which glyph represents which character; thus, you'll probably not even recognize the glyph been drawn with the form of an 'a'; * your replacement of the original text may be smaller or wider than the original which may result in gaps or overlapping text; * some of "text attributes" you want to keep aren't text attributes in PDF; e.g. underlined text in PDFs is text and a line which by choice of coordinates for their respective drawing operations happen to be positioned one above the other; differentiating a line underlining text from a line dividing text blocks can be impossible; * ... Your project might become implementable if you restrict the PDFs it shall function for, e.g. to use only monospaced fonts with the full alphabet present using a single standard encoding. Regards, Michael -- View this message in context: http://itext.2136553.n4.nabble.com/Best-way-to-alter-text-without-losing-formatting-tp4661051p4661054.html Sent from the iText mailing list archive at Nabble.com. ------------------------------------------------------------------------------ What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. http://pubads.g.doubleclick.net/gampad/clk?id=1444514421&iu=/41014381 _______________________________________________ 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