您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

PDFImage.java 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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 java.io.OutputStream;
  21. /**
  22. * Interface for a PDF image.
  23. * This is used for inserting an image into PDF.
  24. */
  25. public interface PDFImage {
  26. /**
  27. * Key to look up XObject.
  28. * This should be a unique key to refer to the image.
  29. *
  30. * @return the key for this image
  31. */
  32. String getKey();
  33. /**
  34. * Setup the PDF image for the current document.
  35. * Some image formats may need to access the document (for example to
  36. * add an ICC profile to the document).
  37. *
  38. * @param doc the PDF parent document
  39. * (todo) Remove this and delegate to the XObject
  40. */
  41. void setup(PDFDocument doc);
  42. /**
  43. * Get the image width in pixels.
  44. *
  45. * @return the image width
  46. */
  47. int getWidth();
  48. /**
  49. * Get the image height in pixels.
  50. *
  51. * @return the image height
  52. */
  53. int getHeight();
  54. /**
  55. * Get the color space for this image.
  56. * Possible results are: DeviceGray, DeviceRGB, or DeviceCMYK
  57. *
  58. * @return the color space
  59. */
  60. PDFDeviceColorSpace getColorSpace();
  61. /**
  62. * Get the bits per color component for this image.
  63. *
  64. * @return the bits per component
  65. */
  66. int getBitsPerComponent();
  67. /**
  68. * Check if this image is a PostScript image.
  69. *
  70. * @return true if this is a PostScript image
  71. */
  72. boolean isPS();
  73. /**
  74. * Check if this image has a transparent color transparency.
  75. *
  76. * @return true if it has transparency
  77. */
  78. boolean isTransparent();
  79. /**
  80. * Get the transparent color.
  81. *
  82. * @return the transparent color for this image
  83. */
  84. PDFColor getTransparentColor();
  85. /**
  86. * Get the PDF reference for a bitmap mask.
  87. *
  88. * @return the PDF reference for the mask image
  89. */
  90. String getMask();
  91. /**
  92. * Get the PDF reference for a soft mask.
  93. * @return the PDF reference for a soft mask image (or null if there's no soft mask)
  94. */
  95. PDFReference getSoftMaskReference();
  96. /** @return true for CMYK images generated by Adobe Photoshop */
  97. boolean isInverted();
  98. /**
  99. * Get the PDF Filter to be applied to the image.
  100. *
  101. * @return the PDF Filter or null
  102. */
  103. PDFFilter getPDFFilter();
  104. // get the image bytes, and bytes properties
  105. /**
  106. * Writes the raw, unencoded contents of the image to a given output stream.
  107. *
  108. * @param out OutputStream to write to
  109. * @throws IOException if there creating stream
  110. */
  111. void outputContents(OutputStream out) throws IOException;
  112. /**
  113. * Populates the XObject's dictionary with additional values. The values are added to the
  114. * dictionary after all the values obtained from other methods from this interface have
  115. * been put into the dictionary. That allows to override certain values.
  116. * @param dict the dictionary to fill
  117. */
  118. void populateXObjectDictionary(PDFDictionary dict);
  119. /**
  120. * Get the ICC stream for this image.
  121. *
  122. * @return the ICC stream for this image if any
  123. */
  124. PDFICCStream getICCStream();
  125. /**
  126. * Returns a hint in form of a String (Possible values from PDFFilterList)
  127. * indicating which filter setup should be used to encode the object.
  128. * @return the filter setup hint
  129. */
  130. String getFilterHint();
  131. /**
  132. * Indicates whether multiple image filters are allowed; this is implemented because Adobe
  133. * Reader does not like multiple FlateDecode filters applied to an image even though that
  134. * allowed by the PDF spec; this is probable due to security concerns since many PDF malware
  135. * exploits, like zip bombs, make use of a chain of FlateDecode filters.
  136. */
  137. boolean multipleFiltersAllowed();
  138. }