KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > pdf > PDFOutputIntent


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$ */
19
20 package org.apache.fop.pdf;
21
22 import java.io.IOException JavaDoc;
23
24 import org.apache.commons.io.output.ByteArrayOutputStream;
25
26 /**
27  * Represents the OutputIntent dictionary.
28  * @since PDF 1.4
29  */

30 public class PDFOutputIntent extends PDFObject {
31
32     /** Subtype for PDF/X output intents */
33     public static final String JavaDoc GTS_PDFX = "GTS_PDFX";
34     /** Subtype for PDF/A-1 output intents */
35     public static final String JavaDoc GTS_PDFA1 = "GTS_PDFA1";
36     
37     private String JavaDoc subtype; //S in the PDF spec
38
private String JavaDoc outputCondition;
39     private String JavaDoc outputConditionIdentifier;
40     private String JavaDoc registryName;
41     private String JavaDoc info;
42     private PDFICCStream destOutputProfile;
43     
44
45     /** @return the output intent subtype. */
46     public String JavaDoc getSubtype() {
47         return subtype;
48     }
49
50     /**
51      * Sets the output intent subtype.
52      * @param subtype the subtype (usually "GTS_PDFX")
53      */

54     public void setSubtype(String JavaDoc subtype) {
55         this.subtype = subtype;
56     }
57
58     /** @return the OutputCondition field */
59     public String JavaDoc getOutputCondition() {
60         return outputCondition;
61     }
62
63     /**
64      * Sets the human-readable form of the output condition.
65      * @param outputCondition A text string concisely identifying the intended output
66      * device or production condition in human-readable form.
67      */

68     public void setOutputCondition(String JavaDoc outputCondition) {
69         this.outputCondition = outputCondition;
70     }
71
72     /** @return the OutputConditionIdentifier field */
73     public String JavaDoc getOutputConditionIdentifier() {
74         return outputConditionIdentifier;
75     }
76
77     /**
78      * Sets the identifier for the output condition.
79      * @param outputConditionIdentifier A string identifying the intended output device or
80      * production condition in human- or machine-readable form.
81      */

82     public void setOutputConditionIdentifier(String JavaDoc outputConditionIdentifier) {
83         this.outputConditionIdentifier = outputConditionIdentifier;
84     }
85
86     /** @return the RegistryName field */
87     public String JavaDoc getRegistryName() {
88         return registryName;
89     }
90
91     /**
92      * Sets the registry name.
93      * @param registryName A string (conventionally a uniform resource identifier,
94      * or URI) identifying the registry in which the condition designated
95      * by OutputConditionIdentifier is defined.
96      */

97     public void setRegistryName(String JavaDoc registryName) {
98         this.registryName = registryName;
99     }
100
101     /** @return the Info field */
102     public String JavaDoc 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 JavaDoc 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 " + destOutputProfile.referencePDF() + "\n"));
165             }
166     
167             bout.write(encode(">>\nendobj\n"));
168         } catch (IOException JavaDoc ioe) {
169             log.error("Ignored I/O exception", ioe);
170         }
171         return bout.toByteArray();
172     }
173
174     
175 }
176
Popular Tags