001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: /* $Id$ */
019:
020: package org.apache.fop.pdf;
021:
022: import java.io.IOException;
023:
024: import org.apache.commons.io.output.ByteArrayOutputStream;
025:
026: /**
027: * Represents the OutputIntent dictionary.
028: * @since PDF 1.4
029: */
030: public class PDFOutputIntent extends PDFObject {
031:
032: /** Subtype for PDF/X output intents */
033: public static final String GTS_PDFX = "GTS_PDFX";
034: /** Subtype for PDF/A-1 output intents */
035: public static final String GTS_PDFA1 = "GTS_PDFA1";
036:
037: private String subtype; //S in the PDF spec
038: private String outputCondition;
039: private String outputConditionIdentifier;
040: private String registryName;
041: private String info;
042: private PDFICCStream destOutputProfile;
043:
044: /** @return the output intent subtype. */
045: public String getSubtype() {
046: return subtype;
047: }
048:
049: /**
050: * Sets the output intent subtype.
051: * @param subtype the subtype (usually "GTS_PDFX")
052: */
053: public void setSubtype(String subtype) {
054: this .subtype = subtype;
055: }
056:
057: /** @return the OutputCondition field */
058: public String getOutputCondition() {
059: return outputCondition;
060: }
061:
062: /**
063: * Sets the human-readable form of the output condition.
064: * @param outputCondition A text string concisely identifying the intended output
065: * device or production condition in human-readable form.
066: */
067: public void setOutputCondition(String outputCondition) {
068: this .outputCondition = outputCondition;
069: }
070:
071: /** @return the OutputConditionIdentifier field */
072: public String getOutputConditionIdentifier() {
073: return outputConditionIdentifier;
074: }
075:
076: /**
077: * Sets the identifier for the output condition.
078: * @param outputConditionIdentifier A string identifying the intended output device or
079: * production condition in human- or machine-readable form.
080: */
081: public void setOutputConditionIdentifier(
082: String outputConditionIdentifier) {
083: this .outputConditionIdentifier = outputConditionIdentifier;
084: }
085:
086: /** @return the RegistryName field */
087: public String getRegistryName() {
088: return registryName;
089: }
090:
091: /**
092: * Sets the registry name.
093: * @param registryName A string (conventionally a uniform resource identifier,
094: * or URI) identifying the registry in which the condition designated
095: * by OutputConditionIdentifier is defined.
096: */
097: public void setRegistryName(String registryName) {
098: this .registryName = registryName;
099: }
100:
101: /** @return the Info field */
102: public String getInfo() {
103: return info;
104: }
105:
106: /**
107: * Sets the Info field.
108: * @param info A human-readable text string containing additional information or comments about
109: * the intended target device or production condition.
110: */
111: public void setInfo(String info) {
112: this .info = info;
113: }
114:
115: /** @return the DestOutputProfile */
116: public PDFICCStream getDestOutputProfile() {
117: return destOutputProfile;
118: }
119:
120: /**
121: * Sets the destination ICC profile.
122: * @param destOutputProfile An ICC profile stream defining the transformation from the PDF
123: * document's source colors to output device colorants.
124: */
125: public void setDestOutputProfile(PDFICCStream destOutputProfile) {
126: this .destOutputProfile = destOutputProfile;
127: }
128:
129: /** @see org.apache.fop.pdf.PDFObject#toPDF() */
130: public byte[] toPDF() {
131: ByteArrayOutputStream bout = new ByteArrayOutputStream(128);
132: try {
133: bout.write(encode(getObjectID()));
134: bout.write(encode("<<\n"));
135: bout.write(encode("/Type /OutputIntent\n"));
136:
137: bout.write(encode("/S /"));
138: bout.write(encode(this .subtype));
139: bout.write(encode("\n"));
140:
141: if (outputCondition != null) {
142: bout.write(encode("/OutputCondition "));
143: bout.write(encodeText(this .outputCondition));
144: bout.write(encode("\n"));
145: }
146:
147: bout.write(encode("/OutputConditionIdentifier "));
148: bout.write(encodeText(this .outputConditionIdentifier));
149: bout.write(encode("\n"));
150:
151: if (registryName != null) {
152: bout.write(encode("/RegistryName "));
153: bout.write(encodeText(this .registryName));
154: bout.write(encode("\n"));
155: }
156:
157: if (info != null) {
158: bout.write(encode("/Info "));
159: bout.write(encodeText(this .info));
160: bout.write(encode("\n"));
161: }
162:
163: if (destOutputProfile != null) {
164: bout.write(encode("/DestOutputProfile "
165: + destOutputProfile.referencePDF() + "\n"));
166: }
167:
168: bout.write(encode(">>\nendobj\n"));
169: } catch (IOException ioe) {
170: log.error("Ignored I/O exception", ioe);
171: }
172: return bout.toByteArray();
173: }
174:
175: }
|