1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 /* $Id: PDFCIDSystemInfo.java 1484190 2013-05-18 22:25:52Z lbernardo $ */ 19 20 package org.apache.fop.pdf; 21 22 import java.io.ByteArrayOutputStream; 23 import java.io.IOException; 24 25 // based on work by Takayuki Takeuchi 26 27 /** 28 * class representing system information for "character identifier" fonts. 29 * 30 * this small object is used in the CID fonts and in the CMaps. 31 */ 32 public class PDFCIDSystemInfo extends PDFObject { 33 private String registry; 34 private String ordering; 35 private int supplement; 36 37 /** 38 * Create a CID system info. 39 * 40 * @param registry the registry value 41 * @param ordering the ordering value 42 * @param supplement the supplement value 43 */ PDFCIDSystemInfo(String registry, String ordering, int supplement)44 public PDFCIDSystemInfo(String registry, String ordering, 45 int supplement) { 46 this.registry = registry; 47 this.ordering = ordering; 48 this.supplement = supplement; 49 } 50 51 /** 52 * Create a string for the CIDSystemInfo dictionary. 53 * The entries are placed as an inline dictionary. 54 * 55 * @return the string for the CIDSystemInfo entry with the inline dictionary 56 */ toPDFString()57 public String toPDFString() { 58 StringBuffer p = new StringBuffer(64); 59 p.setLength(0); 60 p.append("/CIDSystemInfo << /Registry ("); 61 p.append(registry); 62 p.append(") /Ordering ("); 63 p.append(ordering); 64 p.append(") /Supplement "); 65 p.append(supplement); 66 p.append(" >>"); 67 return p.toString(); 68 } 69 70 /** 71 * {@inheritDoc} 72 */ toPDF()73 public byte[] toPDF() { 74 ByteArrayOutputStream bout = new ByteArrayOutputStream(128); 75 try { 76 bout.write(encode("<< /Registry ")); 77 bout.write(encodeText(registry)); 78 bout.write(encode(" /Ordering ")); 79 bout.write(encodeText(ordering)); 80 bout.write(encode(" /Supplement ")); 81 bout.write(encode(Integer.toString(supplement))); 82 bout.write(encode(" >>")); 83 } catch (IOException ioe) { 84 log.error("Ignored I/O exception", ioe); 85 } 86 return bout.toByteArray(); 87 } 88 89 } 90 91