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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. MERGE_FONTS("merge-fonts", false) {
  65. @Override
  66. Boolean deserialize(String value) {
  67. return Boolean.valueOf(value);
  68. }
  69. },
  70. /** Rendering Options key for the ICC profile for the output intent. */
  71. OUTPUT_PROFILE("output-profile") {
  72. @Override
  73. URI deserialize(String value) {
  74. try {
  75. return InternalResourceResolver.cleanURI(value);
  76. } catch (URISyntaxException e) {
  77. throw new RuntimeException(e);
  78. }
  79. }
  80. };
  81. private final String name;
  82. private final Object defaultValue;
  83. private PDFRendererOption(String name, Object defaultValue) {
  84. this.name = name;
  85. this.defaultValue = defaultValue;
  86. }
  87. private PDFRendererOption(String name) {
  88. this(name, null);
  89. }
  90. public String getName() {
  91. return name;
  92. }
  93. public Object getDefaultValue() {
  94. return defaultValue;
  95. }
  96. public Object parse(Object object) {
  97. if (object instanceof String) {
  98. return deserialize((String) object);
  99. } else {
  100. return object;
  101. }
  102. }
  103. abstract Object deserialize(String value);
  104. }