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.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. * Copyright 2006 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* $Id$ */
  17. package org.apache.fop.pdf;
  18. import java.io.ByteArrayOutputStream;
  19. import java.io.IOException;
  20. /**
  21. * Represents the OutputIntent dictionary.
  22. * @since PDF 1.4
  23. */
  24. public class PDFOutputIntent extends PDFObject {
  25. /** Subtype for PDF/X output intents */
  26. public static final String GTS_PDFX = "GTS_PDFX";
  27. /** Subtype for PDF/A-1 output intents */
  28. public static final String GTS_PDFA1 = "GTS_PDFA1";
  29. private String subtype; //S in the PDF spec
  30. private String outputCondition;
  31. private String outputConditionIdentifier;
  32. private String registryName;
  33. private String info;
  34. private PDFICCStream destOutputProfile;
  35. /** @return the output intent subtype. */
  36. public String getSubtype() {
  37. return subtype;
  38. }
  39. /**
  40. * Sets the output intent subtype.
  41. * @param subtype the subtype (usually "GTS_PDFX")
  42. */
  43. public void setSubtype(String subtype) {
  44. this.subtype = subtype;
  45. }
  46. /** @return the OutputCondition field */
  47. public String getOutputCondition() {
  48. return outputCondition;
  49. }
  50. /**
  51. * Sets the human-readable form of the output condition.
  52. * @param outputCondition A text string concisely identifying the intended output
  53. * device or production condition in human-readable form.
  54. */
  55. public void setOutputCondition(String outputCondition) {
  56. this.outputCondition = outputCondition;
  57. }
  58. /** @return the OutputConditionIdentifier field */
  59. public String getOutputConditionIdentifier() {
  60. return outputConditionIdentifier;
  61. }
  62. /**
  63. * Sets the identifier for the output condition.
  64. * @param outputConditionIdentifier A string identifying the intended output device or
  65. * production condition in human- or machine-readable form.
  66. */
  67. public void setOutputConditionIdentifier(String outputConditionIdentifier) {
  68. this.outputConditionIdentifier = outputConditionIdentifier;
  69. }
  70. /** @return the RegistryName field */
  71. public String getRegistryName() {
  72. return registryName;
  73. }
  74. /**
  75. * Sets the registry name.
  76. * @param registryName A string (conventionally a uniform resource identifier,
  77. * or URI) identifying the registry in which the condition designated
  78. * by OutputConditionIdentifier is defined.
  79. */
  80. public void setRegistryName(String registryName) {
  81. this.registryName = registryName;
  82. }
  83. /** @return the Info field */
  84. public String getInfo() {
  85. return info;
  86. }
  87. /**
  88. * Sets the Info field.
  89. * @param info A human-readable text string containing additional information or comments about
  90. * the intended target device or production condition.
  91. */
  92. public void setInfo(String info) {
  93. this.info = info;
  94. }
  95. /** @return the DestOutputProfile */
  96. public PDFICCStream getDestOutputProfile() {
  97. return destOutputProfile;
  98. }
  99. /**
  100. * Sets the destination ICC profile.
  101. * @param destOutputProfile An ICC profile stream defining the transformation from the PDF
  102. * document’s source colors to output device colorants.
  103. */
  104. public void setDestOutputProfile(PDFICCStream destOutputProfile) {
  105. this.destOutputProfile = destOutputProfile;
  106. }
  107. /** @see org.apache.fop.pdf.PDFObject#toPDF() */
  108. public byte[] toPDF() {
  109. ByteArrayOutputStream bout = new ByteArrayOutputStream(128);
  110. try {
  111. bout.write(encode(getObjectID()));
  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(">>\nendobj\n"));
  139. } catch (IOException ioe) {
  140. log.error("Ignored I/O exception", ioe);
  141. }
  142. return bout.toByteArray();
  143. }
  144. }