![]() Step 6: Setting the title and contents of the annotation ![]() To this method, pass the color object representing the color of the annotation as a parameter. Set color to the annotation using the setColor() method of the PdfAnnotation class. Step 5: Setting the color of the annotation PdfAnnotation ann = new PdfTextAnnotation(rect) Rectangle rect = new Rectangle(20, 800, 0, 0) Create an object of this class as shown below. The PdfAnnotation class of the package .annot represents the superclass of all the annotations.Īmong its derived classes, PdfTextAnnotation class represents the text annotation. Instantiate the Document class by passing the object of the class PdfDocument created in the previous steps, as shown below.ĭocument document = new Document(pdfDoc) One of the constructors of this class accepts an object of the class PdfDocument. The Document class of the package is the root element while creating a self-sufficient PDF. Once a PdfDocument object is created, you can add various elements like page, font, file attachment, and event handler using the respective methods provided by its class. PdfDocument pdfDoc = new PdfDocument(writer) Instantiate the PdfDocument class by passing the PdfWriter object to its constructor, as shown below. To instantiate this class (in writing mode), you need to pass an object of the class PdfWriter to its constructor. The PdfDocument class is the class that represents the PDF Document in iText. When an object of this type is passed to a PdfDocument (class), every element added to this document will be written to the file specified. String dest = "C:/itextExamples/textAnnotation.pdf" Instantiate the PdfWriter class by passing a string value (representing the path where you need to create a PDF) to its constructor, as shown below. The constructor of this class accepts a string, representing the path of the file where the PDF is to be created. The PdfWriter class represents the DocWriter for a PDF. To use text annotation in your PDF document, you need to create an object of PdfTextAnnotation class and add this to the PdfPage.įollowing are the steps to use text annotation in the PDF document. While instantiating this class, you need to pass a PdfDocument object as a parameter to its constructor. You can create an empty PDF Document by instantiating the Document class. In this chapter, we will see how to add text annotation to a PDF document using iText library.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |