Goal: Stamp text in PDF counting pixels from the right. Basically looking for over.setTextMatrix(x, y) from the right.
Problem: over.showTextAligned(PdfContentByte.ALIGN_RIGHT... does not seem to work (see screenshot).
public void stampTextPDF(PdfContentByte over) throws JRScriptletException, SQLException {
String text = "TEST2TEST2";
over.beginText();
over.setFontAndSize(baseFont, 8);
over.setRGBColorFill(127, 129, 147);
/* Shows text right, left or center aligned with rotation.
* @param alignment the alignment can be ALIGN_CENTER, ALIGN_RIGHT or ALIGN_LEFT
* @param text the text to show
* @param x the x pivot position
* @param y the y pivot position
* @param rotation the rotation to be applied in degrees counterclockwise
*/
over.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Test!!!TEST2", 22, 5, 0);
//over.setTextMatrix(780, 15);
//over.showText(text);
over.endText();
}
My environment is Jasper-Reports 6.5.1 (yes it's old) and following:
import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Image;
import com.lowagie.text.Phrase;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.ColumnText;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfGState;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfStamper;
