Hello Diane,

If you're just starting, then use 2.0.11 and not 1.8 from which this example is coming. There get the 2.0.11 source download, there go to the example subdirectory, and get AddAnnotations.java. Get it to run. If you get it running, delete all that you don't need so that only one link annotation is left.

If the annotation is to be black, then the color is

PDColor black = new PDColor(new float[] { 0, 0, 0 }, PDDeviceRGB.INSTANCE);

In RGB colorspace, the colors are red green blue and 0 0 0 is black and 1 1 1 is white. 1 0 0 isĀ  red. 1 1 0 is yellow.

In the gray colorspace, 0 is black and 1 is white.

The coordinates start at the bottom left. (unlike java imaging where it starts at the top left).

An A4 Page is about 600 x 800. (this is not exact, it's probably more like 650 x 750)

Are you creating a PDF completely from scratch or do you need to modify an existing PDF, i.e. just add the unline and the link destination?

Tilman

Am 03.10.2018 um 22:27 schrieb Haddy, Diane E:
Hello

I have a task to create a hyperlink on a pdf page.  I googled and found some 
code.  I am not good with coordinates and do not know anything about pdfbox 
PDGamma class and how to add the color black to the text.   Can you please help 
me?

CODE:

PDBorderStyleDictionary psd = new PDBorderStyleDictionary();
             psd.setStyle(PDBorderStyleDictionary.STYLE_UNDERLINE);
             PDAnnotationLink txtLink = new PDAnnotationLink();
             txtLink.setBorderStyle(psd);
            // txtLink.setColour(PDGamma  colourBlack);

              //add action
             PDActionURI action = new PDActionURI();
             action.setURI("http://mycode.here.com";);
             txtLink.setAction(action);

              //populate the url using these coordinates
             PDRectangle rec = new PDRectangle();
             rec.setLowerLeftX(10);
             rec.setLowerLeftY(20);
             rec.setUpperRightX(100);
             rec.setUpperRightY(10);
             txtLink.setRectangle(rec);
             page.getAnnotations().add(txtLink);


thank you,
Diane



Diane Haddy

Health Care Information Systems
Application Developer


________________________________
Notice: This UI Health Care e-mail (including attachments) is covered by the 
Electronic Communications Privacy Act, 18 U.S.C. 2510-2521 and is intended only 
for the use of the individual or entity to which it is addressed, and may 
contain information that is privileged, confidential, and exempt from 
disclosure under applicable law. If you are not the intended recipient, any 
dissemination, distribution or copying of this communication is strictly 
prohibited. If you have received this communication in error, please notify the 
sender immediately and delete or destroy all copies of the original message and 
attachments thereto. Email sent to or from UI Health Care may be retained as 
required by law or regulation. Thank you.
________________________________



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to