You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PDFOutputIntent.java 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. /* $Id$ */
  18. package org.apache.fop.pdf;
  19. import java.io.IOException;
  20. import org.apache.commons.io.output.ByteArrayOutputStream;
  21. /**
  22. * Represents the OutputIntent dictionary.
  23. * @since PDF 1.4
  24. */
  25. public class PDFOutputIntent extends PDFObject {
  26. /** Subtype for PDF/X output intents */
  27. public static final String GTS_PDFX = "GTS_PDFX";
  28. /** Subtype for PDF/A-1 output intents */
  29. public static final String GTS_PDFA1 = "GTS_PDFA1";
  30. private String subtype; //S in the PDF spec
  31. private String outputCondition;
  32. private String outputConditionIdentifier;
  33. private String registryName;
  34. private String info;
  35. private PDFICCStream destOutputProfile;
  36. /** @return the output intent subtype. */
  37. public String getSubtype() {
  38. return subtype;
  39. }
  40. /**
  41. * Sets the output intent subtype.
  42. * @param subtype the subtype (usually "GTS_PDFX")
  43. */
  44. public void setSubtype(String subtype) {
  45. this.subtype = subtype;
  46. }
  47. /** @return the OutputCondition field */
  48. public String getOutputCondition() {
  49. return outputCondition;
  50. }
  51. /**
  52. * Sets the human-readable form of the output condition.
  53. * @param outputCondition A text string concisely identifying the intended output
  54. * device or production condition in human-readable form.
  55. */
  56. public void setOutputCondition(String outputCondition) {
  57. this.outputCondition = outputCondition;
  58. }
  59. /** @return the OutputConditionIdentifier field */
  60. public String getOutputConditionIdentifier() {
  61. return outputConditionIdentifier;
  62. }
  63. /**
  64. * Sets the identifier for the output condition.
  65. * @param outputConditionIdentifier A string identifying the intended output device or
  66. * production condition in human- or machine-readable form.
  67. */
  68. public void setOutputConditionIdentifier(String outputConditionIdentifier) {
  69. this.outputConditionIdentifier = outputConditionIdentifier;
  70. }
  71. /** @return the RegistryName field */
  72. public String getRegistryName() {
  73. return registryName;
  74. }
  75. /**
  76. * Sets the registry name.
  77. * @param registryName A string (conventionally a uniform resource identifier,
  78. * or URI) identifying the registry in which the condition designated
  79. * by OutputConditionIdentifier is defined.
  80. */
  81. public void setRegistryName(String registryName) {
  82. this.registryName = registryName;
  83. }
  84. /** @return the Info field */
  85. public String getInfo() {
  86. return info;
  87. }
  88. /**
  89. * Sets the Info field.
  90. * @param info A human-readable text string containing additional information or comments about
  91. * the intended target device or production condition.
  92. */
  93. public void setInfo(String info) {
  94. this.info = info;
  95. }
  96. /** @return the DestOutputProfile */
  97. public PDFICCStream getDestOutputProfile() {
  98. return destOutputProfile;
  99. }
  100. /**
  101. * Sets the destination ICC profile.
  102. * @param destOutputProfile An ICC profile stream defining the transformation from the PDF
  103. * document's source colors to output device colorants.
  104. */
  105. public void setDestOutputProfile(PDFICCStream destOutputProfile) {
  106. this.destOutputProfile = destOutputProfile;
  107. }
  108. /** {@inheritDoc} */
  109. public byte[] toPDF() {
  110. ByteArrayOutputStream bout = new ByteArrayOutputStream(128);
  111. try {
  112. bout.write(encode("<<\n"));
  113. bout.write(encode("/Type /OutputIntent\n"));
  114. bout.write(encode("/S /"));
  115. bout.write(encode(this.subtype));
  116. bout.write(encode("\n"));
  117. if (outputCondition != null) {
  118. bout.write(encode("/OutputCondition "));
  119. bout.write(encodeText(this.outputCondition));
  120. bout.write(encode("\n"));
  121. }
  122. bout.write(encode("/OutputConditionIdentifier "));
  123. bout.write(encodeText(this.outputConditionIdentifier));
  124. bout.write(encode("\n"));
  125. if (registryName != null) {
  126. bout.write(encode("/RegistryName "));
  127. bout.write(encodeText(this.registryName));
  128. bout.write(encode("\n"));
  129. }
  130. if (info != null) {
  131. bout.write(encode("/Info "));
  132. bout.write(encodeText(this.info));
  133. bout.write(encode("\n"));
  134. }
  135. if (destOutputProfile != null) {
  136. bout.write(encode("/DestOutputProfile " + destOutputProfile.referencePDF() + "\n"));
  137. }
  138. bout.write(encode(">>"));
  139. } catch (IOException ioe) {
  140. log.error("Ignored I/O exception", ioe);
  141. }
  142. return bout.toByteArray();
  143. }
  144. }