Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Thu Sep 05, 2019 10:50 am

I am drawing text in java with this code..
page.getCanvas().drawString(text, font1, PdfBrushes.getBlack(), new Point2D.Float(x, y),frmt,false);


How can i get a custom color using RGB instead of PdfBrushes.getBlack() . Thanks.

Safder
 
Posts: 21
Joined: Fri Sep 28, 2018 8:08 am

Thu Sep 05, 2019 12:05 pm

PdfTrueTypeFont font1 = new PdfTrueTypeFont(new Font(fontName, fontInt, size), true);

page.getCanvas().drawString(text, font1, PdfBrushes.getBlack(), new Point2D.Float(x, y), Aligment, false);

Can i use decimal for the hieght of the text size fontint?

And Normal Java.color (From argb or something) instead of this "PdfBrushes.getBlack()"

Safder
 
Posts: 21
Joined: Fri Sep 28, 2018 8:08 am

Fri Sep 06, 2019 6:53 am

Any Update Please?

Safder
 
Posts: 21
Joined: Fri Sep 28, 2018 8:08 am

Fri Sep 06, 2019 8:58 am

Hi,

Thanks for your inquiry.
Please try the code below to draw text with custom color using RGB.

Code: Select all
PdfRGBColor CustomColor= new PdfRGBColor(172,45,89);
page.getCanvas().drawString("This is a test!", font1, CustomColor, new Point2D.Float(), frmt, false);


And you couldn’t use decimal for the value of “fontInt” here, since this parameter refers to style, and the type of style is “int” in Java.

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Wed Oct 30, 2019 2:33 am

Hi,

Greetings from E-iceblue.
Have you tried the code I offered you last time? Does it solve your issue?
Could you please give us some feedback at your convenience?

Best wishes,
Amber
E-iceblue support team
User avatar

Amber.Gu
 
Posts: 525
Joined: Tue Jun 04, 2019 3:16 am

Return to Spire.PDF