You don't have to calculate anything. Try:

cb.showTextAligned(PdfContentByte.ALIGN_CENTER, watermarkText,
PageSize.A4.width() / 2, PageSize.A4.height() / 2,45);

Best Regards,
Paulo Soares

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Sherlock Simon
> Sent: Tuesday, March 23, 2004 3:35 PM
> To: [EMAIL PROTECTED]
> Subject: [iText-questions] Centring watermark
> 
> I'm using the following to display my watermark (text) rotated at 45
> degrees.
> 
> BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA_BOLD, 
> BaseFont.CP1252,
>       
> BaseFont.NOT_EMBEDDED);
> PdfContentByte cb = docWriter.getDirectContentUnder();
> cb.beginText();
> cb.setFontAndSize(bf, 38);
> cb.setColorFill(Color.lightGray);
> cb.showTextAligned(PdfContentByte.ALIGN_CENTER, 
> watermarkText, 250, 350,
> 45);
> cb.endText();
> 
> What I want to do is make sure it is centred on the page.  I 
> saw an example
> of calculating the attributes depending on the degree of 
> rotation but cannot
> find it.  Could anybody give me some pointers?
> 
> Thanks, Simon
> 
> 
> 
> **************************************************************
> **********************
> Internet email is not to be treated as a secure means of 
> communication.
> PITO monitors all internet email activity and content.
> This communication is intended for the addressee(s) only.
> Please notify the sender if received in error. Unauthorised use or
> disclosure of the content may be unlawful. Opinions expressed in this
> document may not be official policy.
> Thank you for your co-operation.
> **************************************************************
> **********************
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: IBM Linux Tutorials
> Free Linux tutorial presented by Daniel Robbins, President and CEO of
> GenToo technologies. Learn everything from fundamentals to system
> administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
> _______________________________________________
> iText-questions mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 
> 


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to