Hi Rob ,
Please check this example :
- Ex: How to insert colorized text in the pdf :
String file = "C:\\mypdf.pdf"; PDDocument
pdfFile = PDDocument.load( file ); PDPage
newPage = new PDPage();
PDPageContentStream newPageData = new PDPageContentStream( pdfFile,
newPage ); // This is our stream.
newPageData.beginText();
// Set the font settings :
PDSimpleFont font = PDType1Font.TIMES_ITALIC;
int fontSize = 18; newPageData.setFont(
font, fontSize );
newPageData.setNonStrokingColor( 49, 7, 241 ); // That's our target ..
This changes the text color.
newPageData.drawString( "This is blue text." );
--------------------------------------------------
From: "Rob Bradley" <[email protected]>
Date: Tuesday, August 04, 2009 3:38 AM
To: <[email protected]>
Subject: Create PDF Text Color
How to add red text?
I have been struggling with formatting a new PDF.
It is simple text with some hyperlinks and is working fine.
However, I need some of the text to be Red and I have not been able to
figure out how to change the text color.
Can someone give me an example?
Thanks in advance!
Rob Bradley
MIS Manager
Truckee-Tahoe Lumber Co.
Email: [email protected]
Phone: (530) 582-2125
Mobile: (530) 308-6188
Fax: (530) 582-2135