1 51 package org.apache.fop.pdf; 52 53 import java.awt.Rectangle ; 55 import java.io.UnsupportedEncodingException ; 56 57 60 public class PDFLink extends PDFObject { 61 62 float ulx; 63 float uly; 64 float brx; 65 float bry; 66 String color; 67 PDFAction action; 68 69 75 public PDFLink(int number, Rectangle r) { 76 77 super(number); 78 79 this.ulx = r.x; 80 this.uly = r.y; 81 this.brx = r.x + r.width; 82 this.bry = r.y - r.height; 83 this.color = "0 0 0"; 85 } 86 87 public void setAction(PDFAction action) { 88 this.action = action; 89 } 90 91 96 public byte[] toPDF() { 97 String p = this.number + " " + this.generation + " obj\n" 98 + "<< /Type /Annot\n" + "/Subtype /Link\n" + "/Rect [ " 99 + (ulx / 1000f) + " " + (uly / 1000f) + " " 100 + (brx / 1000f) + " " + (bry / 1000f) + " ]\n" + "/C [ " 101 + this.color + " ]\n" + "/Border [ 0 0 0 ]\n" + "/A " 102 + this.action.getAction() + "\n" + "/H /I\n>>\nendobj\n"; 103 104 try { 105 return p.getBytes(PDFDocument.ENCODING); 106 } catch (UnsupportedEncodingException ue) { 107 return p.getBytes(); 108 } 109 } 110 111 125 } 126 | Popular Tags |