Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

PDFFilter.java 3.3KB

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