These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Need to print colors passed in from data

AKCDogMan
Registered: Jul 9 2008
Posts: 19
Answered

I am very new working with Adobe Professional and can do the basic creation of text fields, buttons, etc. Even though this is not in my job requirements, I am now being required to do some Adobe work. With that said, here is my task that I hope someone can help me with.

I need to display and print RGB colors that are passed in as variables. Example: I think I need to create a table with 36 columns, 1 row, 1 cell and display the RGB color code passed in. So, if variable 'A' contains "0,0,0" I need to print the color "Black" in column 1, row 1, cell 1. If variable 'B' contains "0,0,255" I need to print "blue" column 2, row 1, cell 1.

Now, a table may not be the correct thing to use but I have seen many references in using tables so I am guessing I should. It would be nice just to read the variable and then print the color.

Not sure if these should be text fields, buttons, or what. As stated, I was thrown on this project because I have a programming background. I have minimal experience with Adobe Professional, which is what we are using.

Can someone PLEASE help? I am scheduling classes but I have a time table of next week for this one.

Thank you!!!!!

My Product Information:
Acrobat Pro 7.0.9, Windows
michaelejahn
Registered: Apr 26 2006
Posts: 232
I would build that in Microsoft Excel, then export as a PDF.

Or, learn JavaScript I guess you could build that using JavaScript

Michael Jahn
Application Support Specialist
Compose Systems Inc, USA.
4740 Northgate Blvd. Suite 100
Sacramento, CA 95834
Tel: (916) 920-3838 ext 102
Fax: (916) 923-6776
Email: michaelejahn [at] composeusa [dot] com
Web: www.composeusa.com

AKCDogMan
Registered: Jul 9 2008
Posts: 19
I did not fully describe the problem so let me do that now.

This is just a small portion of what needs to be displayed on this single page PDF. I have a total of 86 variables being passed in and I have all but these 36 done. This is suppose to display a color line of 26 possible colors which all will be passed in with the rest of the data file.

To be exact, this color line will be displaying the DNA genotype of a specific canine. The rest of the document will a family tree of the canine.

So, the response of building it in Excel and exporting it may be possible but with the rest of this information, I think a table would work better.

Here's the kicker...I am trying to learn how to create a table in order to accomplish this task. Thus the statement that a table may not be the correct solution. If there is a better way, the help would be greatly appreciated.

Thank you again!!
AKCDogMan
Registered: Jul 9 2008
Posts: 19
HELP...anyone

I have found that I can use any of the following to change the background color of a text field.

// var f = this.getField("Text1");
f.fillColor = color.red;

// var f = this.getField("Text1");
f.fillColor = ["RGB",0,1,0];

// txtField.fillColor = color.blue;

My issue is the developers want to pass in the TRUE RGB colors (ex: 0 170 170) for me to use.

Is there a way to use the RGB colors as I listed?

Thanks in advance!!
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Yes, that's possible. Exactly how are the color values being passed to you? And you may be able to get the developers to pass values that would be easier for you to deal with, but it's simple enough to manipulate what you're given with JavaScript.

George
AKCDogMan
Registered: Jul 9 2008
Posts: 19
The plan is for them to send me the RGB code in the stated format: 255 255 255. (If HEX can be used they can provide that to me as well but I could not get HEX to work.)

If you have suggestions I can propose them as well. I am on a tight timeline with this one and appreciate the advise/help.
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Are these values being automatically loaded into your form somehow, or are you manually entering them, or something else?

George
AKCDogMan
Registered: Jul 9 2008
Posts: 19
Sorry...

I have a form that will receive data via a data file from a database that will populate these files for printing purposes only. The file contains a Variable named: VAR_DNA_MARKER_1_1 that will contain the RGB code. I have to program the field to interprete the RGB Code passed: 0 170 170 (for instances) and print the actual color.

There are 29 different colors that can be passed in the file and I have 36 fields of these to manipulate. (Example: Last field name is: VAR_DNA_MARKER_18_2).

I hope this explains it to your satisfaction. If not, let me now and I will try again...LOL

Thanks again!
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
We're getting closer, but to suggest a specific solution I'd need more details. You mentioned a data file, but did not describe how the data gets from the file into your form. When the data is somehow imported into your form, are these codes loaded into form fields?

Almost there...

George
AKCDogMan
Registered: Jul 9 2008
Posts: 19
I will reply back once I get this information. Look for it tomorrow and thanks. I will eventually get the correct information for you.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Have you seen this article?

http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/using_colors/

As you've shown above, colors in Acrobat are described by an array of values. For RGB colors there are 4 components to the array. The string "RGB" followed by 3 numbers with a value between 0 and 1. Where each number is the proportion of each color chanel component to use for the whole color. 0 being none, and 1 being 100%. This is about as true RGB as you can get.

The example you give above (0, 170, 170), without any other information, seems to be for 8bit color channels, i.e., the chanel value range is 0-255. 8bit chanel depth is common, but is by no means true RGB (if such a thing even exists).

So you have two tasks. First, to import these values, and second to convert them into a format that can be used by Acrobat.

1. Data is imported in to a PDF as single values (numbers, strings, and booleans), it doesn't matter how it's imported, it's always a single value. but you want an array of values. The solution is simple, pass the data in as a string with an easy to parse format, like this, "0,170,170"

Then your code for extracting the data from the string would look like this.
var rawData = "0,170,170";
var a8bitChanels = rawData.split(",");2. To use this data you have to convert it to the Acrobat JavaScript color format. This is very simple. All you have to do is calculate the proportion represented by each color channel. Since your input is 8bits, you just divide this value by 255.

Here's the full code.

var rawData =  "0,170,170";var a8bitChanels = rawData.split(",");var aPDFColor = [ "RGB", a8bitChanels[0]/255, a8bitChanels[1]/255, a8bitChanels[2]/255 ]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

AKCDogMan
Registered: Jul 9 2008
Posts: 19
Thank you for the assistance, Thomp. I have inserted the code and manipulated to work. I am glad that you were able to help me due to time restraints.

Again, Thank you!

Jim