| | |
Change string color
![]() |
•
•
Join Date: Dec 2006
Posts: 20
Reputation:
Solved Threads: 0
I have a string "Hello World"
I want to change the color of Hello to red using the setCMYKColorFillF function. I'm writing the string to a PDF file
I know I'll use to write to the pdf:
private PdfContentByte WriteTxt = null;
WriteTxt.setCMYKColorFillF(float Cyan, float Magenta, float Yellow, float Black);
WriteTxt.showTextAligned(int Align ,"Hello World", float x Position, float y Position, 0f);
I want to change the color of Hello to red using the setCMYKColorFillF function. I'm writing the string to a PDF file
I know I'll use to write to the pdf:
private PdfContentByte WriteTxt = null;
WriteTxt.setCMYKColorFillF(float Cyan, float Magenta, float Yellow, float Black);
WriteTxt.showTextAligned(int Align ,"Hello World", float x Position, float y Position, 0f);
Is there a question in there somewhere?
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Dec 2006
Posts: 20
Reputation:
Solved Threads: 0
Oh please. I was so excited when I saw that there is at least 1 response to my post.
Anyway since if I write:
WriteTxt.setCMYKColorFillF(00, 00, 00, 00);
The output will be "Hello World" in black, but I want to change it to:
Hello World
My question is "How do I do make Hello red and leave the rest as it is?"
Anyway since if I write:
WriteTxt.setCMYKColorFillF(00, 00, 00, 00);
The output will be "Hello World" in black, but I want to change it to:
Hello World
My question is "How do I do make Hello red and leave the rest as it is?"
Do Hello in red, then world in black.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
•
•
Join Date: Dec 2006
Posts: 20
Reputation:
Solved Threads: 0
That's now how I wanted to do it.
I know iwould have to do this
WriteTxt.setCMYKColorFillF(00, 99, 100, 00);
WriteTxt.showTextAligned(0 ,"Hello", 100, 20, 0f);
WriteTxt.setCMYKColorFillF(00, 00, 00, 00);
WriteTxt.showTextAligned(0 ,"World", 120, 20, 0f);
The problem with setCMYKColorFillF is that u can't specify what text of string you want to change.
It should be like WriteTxt.setCMYKColorFillF(00, 00, 00, 00, "World") or something like that.
I know iwould have to do this
WriteTxt.setCMYKColorFillF(00, 99, 100, 00);
WriteTxt.showTextAligned(0 ,"Hello", 100, 20, 0f);
WriteTxt.setCMYKColorFillF(00, 00, 00, 00);
WriteTxt.showTextAligned(0 ,"World", 120, 20, 0f);
The problem with setCMYKColorFillF is that u can't specify what text of string you want to change.
It should be like WriteTxt.setCMYKColorFillF(00, 00, 00, 00, "World") or something like that.
Could you write a small class that extends PdfContentByte and write a new method with the parameters that you want to pass that simply calls the original setCMYKColorFillF method followed by the showTextAligned method? Then you can call that new method as you need.
There are no stupid questions, only those too stupid to ask for help.
echo is a web developer's best friend. •
•
•
•
That's now how I wanted to do it.
I know iwould have to do this
WriteTxt.setCMYKColorFillF(00, 99, 100, 00);
WriteTxt.showTextAligned(0 ,"Hello", 100, 20, 0f);
WriteTxt.setCMYKColorFillF(00, 00, 00, 00);
WriteTxt.showTextAligned(0 ,"World", 120, 20, 0f);
The problem with setCMYKColorFillF is that u can't specify what text of string you want to change.
It should be like WriteTxt.setCMYKColorFillF(00, 00, 00, 00, "World") or something like that.
Well, I'm sorry. There are a lot of things I don't like, that doesn't mean I don't have to do them. darkagn has it correct, create one of your own. Or, search the library you're using (I don't know which one it is) and see if there is a another method (or simply an overloaded version of the same) that does what you want, if not, as already said, implement a "convenience" method, yourself. If the method your using doesn't allow what you want, directly, then you aren't going to be able change that (you could always suggest an enhancement to whoever produced the library, though).
Last edited by masijade; Jan 7th, 2008 at 7:43 am. Reason: typo, not that its the only one though ;-)
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
![]() |
Similar Threads
- Pointers (archived tutorial) (C++)
- how to change the colour of rows in a datasheet (VB.NET)
- Not able to set the background color of JComponent (Java)
- change the font/color of the selected text on a web page through javascript (JavaScript / DHTML / AJAX)
- Input String to Integer (Java)
- VS 2005 ListViews not holding background color (C#)
- I can't figure out how to change my jbutton font and color ( heres the code ) (Java)
- Reversive Array/Integer (C)
- change statement (JSP)
Other Threads in the Java Forum
- Previous Thread: pseudocode
- Next Thread: Repeating An Action [Moving An Object Every Couple Of Secs..]
Views: 6677 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for Java
access actionlistener add android applet application arguments array arrays build c# c++ chat class classes client code combobox compile component constructor convert data database desktop eclipse error event exception file filei/o forloop game givemetehcodez graphics gui helpwithhomework html ide image images inheritance input interface j2me java jframe jpanel jtable jtextarea jtextfield julia lazy linked linked-list list loop looping method methods mobile netbeans newbie node number object output page pattern problem program programming project read recursion regex remove return robot scanner screen search server service set size sms socket software source sql string swing text text-file threads time timer tree url






