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.

PDFFilter.java 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright 1999-2004 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.OutputStream;
  19. import java.io.IOException;
  20. /**
  21. * PDF Filter class.
  22. * This represents a PDF filter object.
  23. * Filter implementations should extend this class.
  24. *
  25. * @author Eric SCHAEFFER, Kelly A. Campbell
  26. */
  27. public abstract class PDFFilter {
  28. /*
  29. * These are no longer needed, but are here as a reminder about what
  30. * filters pdf supports.
  31. * public static final int ASCII_HEX_DECODE = 1;
  32. * public static final int ASCII_85_DECODE = 2;
  33. * public static final int LZW_DECODE = 3;
  34. * public static final int RUN_LENGTH_DECODE = 4;
  35. * public static final int CCITT_FAX_DECODE = 5;
  36. * public static final int DCT_DECODE = 6;
  37. * public static final int FLATE_DECODE = 7;
  38. */
  39. /**
  40. * Marker to know if this filter has already been applied to the data
  41. */
  42. private boolean applied = false;
  43. /**
  44. * Check if this filter has been applied.
  45. *
  46. * @return true if this filter has been applied
  47. */
  48. public boolean isApplied() {
  49. return applied;
  50. }
  51. /**
  52. * Set the applied attribute to the given value. This attribute is
  53. * used to determine if this filter is just a placeholder for the
  54. * decodeparms and dictionary entries, or if the filter needs to
  55. * actually encode the data. For example if the raw data is copied
  56. * out of an image file in it's compressed format, then this
  57. * should be set to true and the filter options should be set to
  58. * those which the raw data was encoded with.
  59. *
  60. * @param b set the applied value to this
  61. */
  62. public void setApplied(boolean b) {
  63. applied = b;
  64. }
  65. /**
  66. * return a PDF string representation of the filter, e.g. /FlateDecode
  67. *
  68. * @return the filter PDF name
  69. */
  70. public abstract String getName();
  71. /**
  72. * Returns true if the filter is an ASCII filter that isn't necessary
  73. * when encryption is active.
  74. * @return boolean True if this filter is an ASCII filter
  75. */
  76. public boolean isASCIIFilter() {
  77. return false;
  78. }
  79. /**
  80. * return a parameter dictionary for this filter, or null
  81. *
  82. * @return the decode params for the filter
  83. */
  84. public abstract String getDecodeParms();
  85. /**
  86. * Applies a filter to an OutputStream.
  87. * @param out contents to be filtered
  88. * @return OutputStream filtered contents
  89. * @throws IOException In case of an I/O problem
  90. */
  91. public abstract OutputStream applyFilter(OutputStream out) throws IOException;
  92. }