Itext pdf – text alignment to right

I am using Itext PDF API to generate a pdf. I am trying to get some text to be aligned to the right-hand side of the pdf. I have tried the manual method of spacing but is not working for some reason (Code shown below). Meanwhile, if there is a way of doing it dynamically that would be great, please!

String dest = "\location\";
    PdfWriter writer;

        writer = new PdfWriter(dest);

        // Creating a PdfDcoument
        PdfDocument pdf = new PdfDocument(writer);

        // Creating a Document
        Document document = new Document(pdf);

        // Creating a String
        String para1 = "TEXT";

        //Spacing length
        while (para1.length() < 50) {

              para1 = " " + para1;


        //Creating Paragraphs
        Paragraph paragraph1 = new Paragraph(para1);


        //Adding Paragraphs to document

        // Closing the document

Thanks in advance!


Class com.itextpdf.layout.element.Paragraph in itext7 has method setTextAlignment. I hope this is what you are looking for: