This website uses cookies to improve your experience. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are as essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.

Author:Arajinn Mazuramar
Language:English (Spanish)
Published (Last):8 July 2004
PDF File Size:16.78 Mb
ePub File Size:2.97 Mb
Price:Free* [*Free Regsitration Required]

In this chapter, we will see how to set color and font to text in a PDF document using the iText library. While instantiating this class, you need to pass a PdfDocument object as a parameter to its constructor. To add a paragraph to the document, you need to instantiate the Paragraph class and add this object to the document using the add method.

You can set color and font to the text using the methods setFontColor and setFont respectively. Following are the steps to set color and font to text in a pdf document. This class belongs to the package com.

The constructor of this class accepts a string, representing the path of the file where the PDF is to be created. 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. To instantiate this class in writing mode , you need to pass an object of the class PdfWriter to its constructor. Instantiate the PdfDocument class by passing the PdfWriter object to its constructor, as shown below. Step 3: Creating the Document class The Document class of the package com.

One of the constructors of this class accepts an object of the class PdfDocument. Instantiate the Document class by passing the object of the class PdfDocument created in the previous steps, as shown below. Pass the PdfFont object as a parameter, as shown below. It creates a PDF document with the name fonts. FontConstants; import com. Color; import com.

PdfFontFactory; import com. PdfFont; import com. PdfDocument; import com. PdfWriter; import com. Document; import com. Paragraph; import com. Text added to pdf..


Subscribe to RSS

Milkis ExceptionConverter ; import com. PdfWriter ; import itet. There are also varying numbers of parameters passed, which ilustrates some of the different overloads available. SAXParser ; import javax. Skip to main content. Would you like to answer one of these unanswered questions instead?


iText - Setting Font

Neshura ExceptionConverter ; import com. Ajay Jayavarapu itest My site uses cookies to personalise content and adverts, to provide social media features and to analyse traffic. Font ; import com. You will just have to ensure your font file is distributed alongwith.


iTextSharp - Working with Fonts


Related Articles