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.

PDFRendererOption.java 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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.render.pdf;
  19. import java.net.URI;
  20. import java.net.URISyntaxException;
  21. import org.apache.fop.apps.io.InternalResourceResolver;
  22. import org.apache.fop.pdf.PDFAMode;
  23. import org.apache.fop.pdf.PDFXMode;
  24. import org.apache.fop.pdf.Version;
  25. import org.apache.fop.render.RendererConfigOption;
  26. public enum PDFRendererOption implements RendererConfigOption {
  27. FILTER_LIST("filterList", null) {
  28. @Override
  29. Object deserialize(String value) {
  30. throw new UnsupportedOperationException();
  31. }
  32. },
  33. /** Rendering Options key for the PDF/A mode, default: {@link PDFAMode#DISABLED} */
  34. PDF_A_MODE("pdf-a-mode", PDFAMode.DISABLED) {
  35. @Override
  36. PDFAMode deserialize(String value) {
  37. return PDFAMode.getValueOf(value);
  38. }
  39. },
  40. /** Rendering Options key for the PDF/X mode, default: {@link PDFXMode#DISABLED} */
  41. PDF_X_MODE("pdf-x-mode", PDFXMode.DISABLED) {
  42. @Override
  43. PDFXMode deserialize(String value) {
  44. return PDFXMode.getValueOf(value);
  45. }
  46. },
  47. /** PDF version entry: specify the version of the PDF document created, datatype: String */
  48. VERSION("version") {
  49. @Override
  50. Version deserialize(String value) {
  51. return Version.getValueOf(value);
  52. }
  53. },
  54. /**
  55. * Rendering Options key for disabling the sRGB color space (only possible if no PDF/A or
  56. * PDF/X profile is active), default: false
  57. */
  58. DISABLE_SRGB_COLORSPACE("disable-srgb-colorspace", false) {
  59. @Override
  60. Boolean deserialize(String value) {
  61. return Boolean.valueOf(value);
  62. }
  63. },
  64. /** Rendering Options key for the ICC profile for the output intent. */
  65. OUTPUT_PROFILE("output-profile") {
  66. @Override
  67. URI deserialize(String value) {
  68. try {
  69. return InternalResourceResolver.cleanURI(value);
  70. } catch (URISyntaxException e) {
  71. throw new RuntimeException(e);
  72. }
  73. }
  74. };
  75. private final String name;
  76. private final Object defaultValue;
  77. private PDFRendererOption(String name, Object defaultValue) {
  78. this.name = name;
  79. this.defaultValue = defaultValue;
  80. }
  81. private PDFRendererOption(String name) {
  82. this(name, null);
  83. }
  84. public String getName() {
  85. return name;
  86. }
  87. public Object getDefaultValue() {
  88. return defaultValue;
  89. }
  90. public Object parse(Object object) {
  91. if (object instanceof String) {
  92. return deserialize((String) object);
  93. } else {
  94. return object;
  95. }
  96. }
  97. abstract Object deserialize(String value);
  98. }