1 51 package org.apache.fop.pdf; 52 53 import java.io.UnsupportedEncodingException ; 54 55 public class ASCIIHexFilter extends PDFFilter { 56 private static final String ASCIIHEX_EOD = ">"; 57 58 59 public String getName() { 60 return "/ASCIIHexDecode"; 61 } 62 63 public String getDecodeParms() { 64 return null; 65 } 66 67 public byte[] encode(byte[] data) { 68 69 StringBuffer buffer = new StringBuffer (); 70 for (int i = 0; i < data.length; i++) { 71 int val = (int)(data[i] & 0xFF); 72 if (val < 16) 73 buffer.append("0"); 74 buffer.append(Integer.toHexString(val)); 75 } 76 buffer.append(ASCIIHEX_EOD); 77 78 try { 79 return buffer.toString().getBytes(PDFDocument.ENCODING); 80 } catch (UnsupportedEncodingException ue) { 81 return buffer.toString().getBytes(); 82 } 83 } 84 85 } 86 | Popular Tags |