Op 20/04/2011 15:25, M. Vanhanen schreef: > Hello, > > I´ve a problem: I have pdf schematics which consists of pictures and text. > Text is very scattered, here and there and sometimes text are over the > pictures. I would like to automatically change certain text of the pdf to > hyperlinks and write a new pdf.
The word "change" isn't chosen well. In PDF you have content (PDF syntax as described in the imaging model, stored in a content stream object) and annotations (objects as described in the Carousel Object System that not part of the content, but visualized on top of the content). You don't want to change the content, you want to add "Link annotations". > I almost succeeded this with reading the page text to a string with help of > PdfReader, then if matching substring was found, it was replaced by Anchor, > and rest of the string was put into a Chunks. Chunks and Anchors were put > into a Paragraph, which was added to a document. I'm surprised to read you've almost succeeded. I wouldn't (be able to) do what you did. > This resulted that the text was not aligned how it was and the pictures > don´t show. That's no surprise. > Is there are way in iText, that I could just change some text to > hyperlinks without altering anything else of the documents. > > If I read text from a PDF-file, can I somehow get the position of the text > in the page? It depends on the nature of your PDF. You could get information about text snippets such as the ascent and descent line from the PDF parser classes (com.itextpdf.text.pdf.parser) as described in chapter 15. Use the coordinates from those lines to add an annotation at these coordinates as described in chapter 7. ------------------------------------------------------------------------------ Benefiting from Server Virtualization: Beyond Initial Workload Consolidation -- Increasing the use of server virtualization is a top priority.Virtualization can reduce costs, simplify management, and improve application availability and disaster protection. Learn more about boosting the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev _______________________________________________ iText-questions mailing list [email protected] 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
