[EMAIL PROTECTED] wrote:
In com.lowagie.text.pdf there is a method PdfAnnotation.createMarkup which could possibly be helpful.
I did some grocery shopping between writing the code sample in my previous post and this mail. While waiting in the queue I figured out that the annotation rectangle shows up in an unexpected way, but that it might be possible to change the order of the quadpoints so that it shows up correctly. So when I got home, I wrote the example you'll find in attachment. Note that MARKUP_SQUIGGLY has just been added to SVN, so it will only work starting with the next iText version. -- This answer is provided by 1T3XT BVBA
import java.awt.Color;
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfAnnotation;
import com.lowagie.text.pdf.PdfWriter;
public class MarkupExample {
public static void main ( String[] args ) throws IOException,
DocumentException
{
Document document = new Document () ;
PdfWriter writer = PdfWriter.getInstance ( document, new
FileOutputStream ( "markup.pdf" ) ) ;
document.open () ;
document.add(new Paragraph("highlight"));
Rectangle rect = new Rectangle(36, 785, 81, 798);
float[] quad = new float[]{ 36, 798, 81, 798, 36, 785, 81, 785 };
PdfAnnotation highlight = PdfAnnotation.createMarkup(writer, rect,
null, PdfAnnotation.MARKUP_HIGHLIGHT, quad);
highlight.setColor(Color.YELLOW);
highlight.setFlags(PdfAnnotation.FLAGS_PRINT);
writer.addAnnotation(highlight);
document.add(new Paragraph("underline"));
rect = new Rectangle(36, 767, 85, 780);
quad = new float[]{ 36, 780, 85, 780, 36, 767, 85, 767 };
PdfAnnotation underline = PdfAnnotation.createMarkup(writer, rect,
null, PdfAnnotation.MARKUP_UNDERLINE, quad);
underline.setColor(Color.GREEN);
underline.setFlags(PdfAnnotation.FLAGS_PRINT);
writer.addAnnotation(underline);
document.add(new Paragraph("strikeout"));
rect = new Rectangle(36, 749, 82, 762);
quad = new float[]{ 36, 762, 82, 762, 36, 749, 82, 749 };
PdfAnnotation strikeout = PdfAnnotation.createMarkup(writer, rect,
null, PdfAnnotation.MARKUP_STRIKEOUT, quad);
strikeout.setColor(Color.RED);
strikeout.setFlags(PdfAnnotation.FLAGS_PRINT);
writer.addAnnotation(strikeout);
document.add(new Paragraph("squiggly"));
rect = new Rectangle(36, 731, 80, 744);
quad = new float[]{ 36, 744, 80, 744, 36, 731, 80, 731 };
PdfAnnotation squiggly = PdfAnnotation.createMarkup(writer, rect, null,
PdfAnnotation.MARKUP_SQUIGGLY, quad);
squiggly.setColor(Color.ORANGE);
squiggly.setFlags(PdfAnnotation.FLAGS_PRINT);
writer.addAnnotation(squiggly);
document.close () ;
}
}
markup.pdf
Description: Adobe PDF document
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Do you like iText? Buy the iText book: http://www.1t3xt.com/docs/book.php Or leave a tip: https://tipit.to/itexttipjar
