Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

Merged revisions 636407-637074,637076-637118,637120-637790,637792-637856,637858-637992,637994-638047,638049-638307,638309-638315,638318-664698 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_95 ........ r638937 | jeremias | 2008-03-19 18:08:57 +0100 (Mi, 19 Mrz 2008) | 1 line A nit. ........ r640889 | vhennebert | 2008-03-25 17:43:55 +0100 (Di, 25 Mrz 2008) | 2 lines Set the final release date and added a news item about the 0.95beta release (the change was made before updating the website) ........ r642906 | jeremias | 2008-03-31 09:12:40 +0200 (Mo, 31 Mrz 2008) | 3 lines Added version number to xml-apis-ext (as suggested by Karel Vervaeke). Moved xml-apis to same version as xml-apis-ext. Added missing licensing info about xml-apis-ext. ........ r647403 | jeremias | 2008-04-12 11:02:01 +0200 (Sa, 12 Apr 2008) | 1 line Fixed NullPointerException when loading a TrueType font using XML font metric files. ........ r647537 | jeremias | 2008-04-13 09:36:00 +0200 (So, 13 Apr 2008) | 1 line Performance improvement when encoding images: Fixed an important hotspot by extending CloseBlocker from ProxyOutputStream instead of FilterOutputStream as the latter routes all write(byte[]) calls through write(int). ........ r648984 | jeremias | 2008-04-17 09:00:22 +0200 (Do, 17 Apr 2008) | 1 line HeadURL was missing in the properties. ........ r649006 | jeremias | 2008-04-17 10:42:52 +0200 (Do, 17 Apr 2008) | 1 line Fixed text extraction problem with ZapfDingbats and Symbol font in PDF output. These fonts are symbolic and must not use an Encoding value in PDF. Applies to the built-in base 14 variant and to the case where these fonts are explicitely embedded. ........ r649014 | jeremias | 2008-04-17 11:10:15 +0200 (Do, 17 Apr 2008) | 1 line Added missing change information. ........ r650550 | vhennebert | 2008-04-22 17:22:31 +0200 (Di, 22 Apr 2008) | 4 lines Bugzilla 41621: - length of the penalty now correctly computed; - AssertionError fixed. ........ r651302 | jeremias | 2008-04-24 18:08:53 +0200 (Do, 24 Apr 2008) | 3 lines Fixed regression causing bad positioning of block-containers if used as descendant of a table-cell. This was not caught because of the lack of a test case that would have shown the problem in visual testing with BatchDiffer. See also: http://mail-archives.apache.org/mod_mbox/xmlgraphics-fop-users/200804.mbox/%3c20080424164128.973A.DEV@jeremias-maerki.ch%3e ........ r653537 | vhennebert | 2008-05-05 19:47:28 +0200 (Mo, 05 Mai 2008) | 2 lines Bugfix: the before border of cells below a column-spanning cell had their value taken from the leading case, instead of the normal one. ........ r654453 | jeremias | 2008-05-08 11:14:04 +0200 (Do, 08 Mai 2008) | 2 lines Added /usr/local/share/fonts as additional possible location for fonts on Unixes. ........ r656286 | jeremias | 2008-05-14 16:16:49 +0200 (Mi, 14 Mai 2008) | 1 line Restored plug-in API compatibility with FOP 0.94. Fixes a NoSuchMethodError when Barcode4J is run. ........ r656524 | jeremias | 2008-05-15 09:07:18 +0200 (Do, 15 Mai 2008) | 1 line Fixed rendering of fixed block-containers in AFP output. The break-out was actually never implemented which is necessary for supporting fixed positioned viewports. ........ r657520 | maxberger | 2008-05-18 11:38:45 +0200 (So, 18 Mai 2008) | 1 line Updated as per suggestions in bug 45019 ........ r661580 | maxberger | 2008-05-30 08:42:17 +0200 (Fr, 30 Mai 2008) | 1 line added my key to KEYS, it is used for signing mvn artifacts ........ r663482 | jeremias | 2008-06-05 09:06:37 +0200 (Do, 05 Jun 2008) | 1 line Fixed positioning of absolutely positioned block-containers in multi-column documents. ........ r664692 | jeremias | 2008-06-09 14:49:45 +0200 (Mo, 09 Jun 2008) | 1 line Restored PSImageUtils. I had deleted it prematurely. Extensions like Barcode4J rely on this class. ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@665691 13f79535-47bb-0310-9956-ffa450edef68
16 роки тому
Merged revisions 636407-637074,637076-637118,637120-637790,637792-637856,637858-637992,637994-638047,638049-638307,638309-638315,638318-664698 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_95 ........ r638937 | jeremias | 2008-03-19 18:08:57 +0100 (Mi, 19 Mrz 2008) | 1 line A nit. ........ r640889 | vhennebert | 2008-03-25 17:43:55 +0100 (Di, 25 Mrz 2008) | 2 lines Set the final release date and added a news item about the 0.95beta release (the change was made before updating the website) ........ r642906 | jeremias | 2008-03-31 09:12:40 +0200 (Mo, 31 Mrz 2008) | 3 lines Added version number to xml-apis-ext (as suggested by Karel Vervaeke). Moved xml-apis to same version as xml-apis-ext. Added missing licensing info about xml-apis-ext. ........ r647403 | jeremias | 2008-04-12 11:02:01 +0200 (Sa, 12 Apr 2008) | 1 line Fixed NullPointerException when loading a TrueType font using XML font metric files. ........ r647537 | jeremias | 2008-04-13 09:36:00 +0200 (So, 13 Apr 2008) | 1 line Performance improvement when encoding images: Fixed an important hotspot by extending CloseBlocker from ProxyOutputStream instead of FilterOutputStream as the latter routes all write(byte[]) calls through write(int). ........ r648984 | jeremias | 2008-04-17 09:00:22 +0200 (Do, 17 Apr 2008) | 1 line HeadURL was missing in the properties. ........ r649006 | jeremias | 2008-04-17 10:42:52 +0200 (Do, 17 Apr 2008) | 1 line Fixed text extraction problem with ZapfDingbats and Symbol font in PDF output. These fonts are symbolic and must not use an Encoding value in PDF. Applies to the built-in base 14 variant and to the case where these fonts are explicitely embedded. ........ r649014 | jeremias | 2008-04-17 11:10:15 +0200 (Do, 17 Apr 2008) | 1 line Added missing change information. ........ r650550 | vhennebert | 2008-04-22 17:22:31 +0200 (Di, 22 Apr 2008) | 4 lines Bugzilla 41621: - length of the penalty now correctly computed; - AssertionError fixed. ........ r651302 | jeremias | 2008-04-24 18:08:53 +0200 (Do, 24 Apr 2008) | 3 lines Fixed regression causing bad positioning of block-containers if used as descendant of a table-cell. This was not caught because of the lack of a test case that would have shown the problem in visual testing with BatchDiffer. See also: http://mail-archives.apache.org/mod_mbox/xmlgraphics-fop-users/200804.mbox/%3c20080424164128.973A.DEV@jeremias-maerki.ch%3e ........ r653537 | vhennebert | 2008-05-05 19:47:28 +0200 (Mo, 05 Mai 2008) | 2 lines Bugfix: the before border of cells below a column-spanning cell had their value taken from the leading case, instead of the normal one. ........ r654453 | jeremias | 2008-05-08 11:14:04 +0200 (Do, 08 Mai 2008) | 2 lines Added /usr/local/share/fonts as additional possible location for fonts on Unixes. ........ r656286 | jeremias | 2008-05-14 16:16:49 +0200 (Mi, 14 Mai 2008) | 1 line Restored plug-in API compatibility with FOP 0.94. Fixes a NoSuchMethodError when Barcode4J is run. ........ r656524 | jeremias | 2008-05-15 09:07:18 +0200 (Do, 15 Mai 2008) | 1 line Fixed rendering of fixed block-containers in AFP output. The break-out was actually never implemented which is necessary for supporting fixed positioned viewports. ........ r657520 | maxberger | 2008-05-18 11:38:45 +0200 (So, 18 Mai 2008) | 1 line Updated as per suggestions in bug 45019 ........ r661580 | maxberger | 2008-05-30 08:42:17 +0200 (Fr, 30 Mai 2008) | 1 line added my key to KEYS, it is used for signing mvn artifacts ........ r663482 | jeremias | 2008-06-05 09:06:37 +0200 (Do, 05 Jun 2008) | 1 line Fixed positioning of absolutely positioned block-containers in multi-column documents. ........ r664692 | jeremias | 2008-06-09 14:49:45 +0200 (Mo, 09 Jun 2008) | 1 line Restored PSImageUtils. I had deleted it prematurely. Extensions like Barcode4J rely on this class. ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@665691 13f79535-47bb-0310-9956-ffa450edef68
16 роки тому
Merged revisions 636407-637074,637076-637118,637120-637790,637792-637856,637858-637992,637994-638047,638049-638307,638309-638315,638318-664698 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_95 ........ r638937 | jeremias | 2008-03-19 18:08:57 +0100 (Mi, 19 Mrz 2008) | 1 line A nit. ........ r640889 | vhennebert | 2008-03-25 17:43:55 +0100 (Di, 25 Mrz 2008) | 2 lines Set the final release date and added a news item about the 0.95beta release (the change was made before updating the website) ........ r642906 | jeremias | 2008-03-31 09:12:40 +0200 (Mo, 31 Mrz 2008) | 3 lines Added version number to xml-apis-ext (as suggested by Karel Vervaeke). Moved xml-apis to same version as xml-apis-ext. Added missing licensing info about xml-apis-ext. ........ r647403 | jeremias | 2008-04-12 11:02:01 +0200 (Sa, 12 Apr 2008) | 1 line Fixed NullPointerException when loading a TrueType font using XML font metric files. ........ r647537 | jeremias | 2008-04-13 09:36:00 +0200 (So, 13 Apr 2008) | 1 line Performance improvement when encoding images: Fixed an important hotspot by extending CloseBlocker from ProxyOutputStream instead of FilterOutputStream as the latter routes all write(byte[]) calls through write(int). ........ r648984 | jeremias | 2008-04-17 09:00:22 +0200 (Do, 17 Apr 2008) | 1 line HeadURL was missing in the properties. ........ r649006 | jeremias | 2008-04-17 10:42:52 +0200 (Do, 17 Apr 2008) | 1 line Fixed text extraction problem with ZapfDingbats and Symbol font in PDF output. These fonts are symbolic and must not use an Encoding value in PDF. Applies to the built-in base 14 variant and to the case where these fonts are explicitely embedded. ........ r649014 | jeremias | 2008-04-17 11:10:15 +0200 (Do, 17 Apr 2008) | 1 line Added missing change information. ........ r650550 | vhennebert | 2008-04-22 17:22:31 +0200 (Di, 22 Apr 2008) | 4 lines Bugzilla 41621: - length of the penalty now correctly computed; - AssertionError fixed. ........ r651302 | jeremias | 2008-04-24 18:08:53 +0200 (Do, 24 Apr 2008) | 3 lines Fixed regression causing bad positioning of block-containers if used as descendant of a table-cell. This was not caught because of the lack of a test case that would have shown the problem in visual testing with BatchDiffer. See also: http://mail-archives.apache.org/mod_mbox/xmlgraphics-fop-users/200804.mbox/%3c20080424164128.973A.DEV@jeremias-maerki.ch%3e ........ r653537 | vhennebert | 2008-05-05 19:47:28 +0200 (Mo, 05 Mai 2008) | 2 lines Bugfix: the before border of cells below a column-spanning cell had their value taken from the leading case, instead of the normal one. ........ r654453 | jeremias | 2008-05-08 11:14:04 +0200 (Do, 08 Mai 2008) | 2 lines Added /usr/local/share/fonts as additional possible location for fonts on Unixes. ........ r656286 | jeremias | 2008-05-14 16:16:49 +0200 (Mi, 14 Mai 2008) | 1 line Restored plug-in API compatibility with FOP 0.94. Fixes a NoSuchMethodError when Barcode4J is run. ........ r656524 | jeremias | 2008-05-15 09:07:18 +0200 (Do, 15 Mai 2008) | 1 line Fixed rendering of fixed block-containers in AFP output. The break-out was actually never implemented which is necessary for supporting fixed positioned viewports. ........ r657520 | maxberger | 2008-05-18 11:38:45 +0200 (So, 18 Mai 2008) | 1 line Updated as per suggestions in bug 45019 ........ r661580 | maxberger | 2008-05-30 08:42:17 +0200 (Fr, 30 Mai 2008) | 1 line added my key to KEYS, it is used for signing mvn artifacts ........ r663482 | jeremias | 2008-06-05 09:06:37 +0200 (Do, 05 Jun 2008) | 1 line Fixed positioning of absolutely positioned block-containers in multi-column documents. ........ r664692 | jeremias | 2008-06-09 14:49:45 +0200 (Mo, 09 Jun 2008) | 1 line Restored PSImageUtils. I had deleted it prematurely. Extensions like Barcode4J rely on this class. ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@665691 13f79535-47bb-0310-9956-ffa450edef68
16 роки тому
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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. import java.util.HashMap;
  22. import java.util.HashSet;
  23. import java.util.Iterator;
  24. import java.util.Map;
  25. import java.util.Set;
  26. import org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil;
  27. import org.apache.fop.fonts.FontDescriptor;
  28. import org.apache.fop.fonts.FontInfo;
  29. import org.apache.fop.fonts.Typeface;
  30. import org.apache.fop.fonts.base14.Symbol;
  31. import org.apache.fop.fonts.base14.ZapfDingbats;
  32. /**
  33. * Class representing a /Resources object.
  34. *
  35. * /Resources object contain a list of references to the fonts for the
  36. * document
  37. */
  38. public class PDFResources extends PDFDictionary {
  39. /**
  40. * /Font objects keyed by their internal name
  41. */
  42. protected Map fonts = new HashMap();
  43. /**
  44. * Set of XObjects
  45. */
  46. protected Set xObjects = new HashSet();
  47. /**
  48. * Set of patterns
  49. */
  50. protected Set patterns = new HashSet();
  51. /**
  52. * Set of shadings
  53. */
  54. protected Set shadings = new HashSet();
  55. /**
  56. * Set of ExtGStates
  57. */
  58. protected Set gstates = new HashSet();
  59. /** Map of color spaces (key: color space name) */
  60. protected Map colorSpaces = new HashMap();
  61. /** Map of ICC color spaces (key: ICC profile description) */
  62. protected Map iccColorSpaces = new HashMap();
  63. /**
  64. * create a /Resources object.
  65. *
  66. * @param objnum the object's number
  67. */
  68. public PDFResources(int objnum) {
  69. /* generic creation of object */
  70. super();
  71. setObjectNumber(objnum);
  72. }
  73. /**
  74. * add font object to resources list.
  75. *
  76. * @param font the PDFFont to add
  77. */
  78. public void addFont(PDFFont font) {
  79. this.fonts.put(font.getName(), font);
  80. }
  81. /**
  82. * Add the fonts in the font info to this PDF document's Font Resources.
  83. *
  84. * @param doc PDF document to add fonts to
  85. * @param fontInfo font info object to get font information from
  86. */
  87. public void addFonts(PDFDocument doc, FontInfo fontInfo) {
  88. Map<String, Typeface> usedFonts = fontInfo.getUsedFonts();
  89. for (String f : usedFonts.keySet()) {
  90. Typeface font = usedFonts.get(f);
  91. //Check if the font actually had any mapping operations. If not, it is an indication
  92. //that it has never actually been used and therefore doesn't have to be embedded.
  93. if (font.hadMappingOperations()) {
  94. FontDescriptor desc = null;
  95. if (font instanceof FontDescriptor) {
  96. desc = (FontDescriptor)font;
  97. }
  98. String encoding = font.getEncodingName();
  99. if (font instanceof Symbol || font instanceof ZapfDingbats) {
  100. encoding = null; //Symbolic fonts shouldn't specify an encoding value in PDF
  101. }
  102. addFont(doc.getFactory().makeFont(
  103. f, font.getEmbedFontName(), encoding, font, desc));
  104. }
  105. }
  106. }
  107. /**
  108. * Add a PDFGState to the resources.
  109. *
  110. * @param gs the PDFGState to add
  111. */
  112. public void addGState(PDFGState gs) {
  113. this.gstates.add(gs);
  114. }
  115. /**
  116. * Add a Shading to the resources.
  117. *
  118. * @param theShading the shading to add
  119. */
  120. public void addShading(PDFShading theShading) {
  121. this.shadings.add(theShading);
  122. }
  123. /**
  124. * Add the pattern to the resources.
  125. *
  126. * @param thePattern the pattern to add
  127. */
  128. public void addPattern(PDFPattern thePattern) {
  129. this.patterns.add(thePattern);
  130. }
  131. /**
  132. * Add an XObject to the resources.
  133. *
  134. * @param xObject the XObject to add
  135. */
  136. public void addXObject(PDFXObject xObject) {
  137. this.xObjects.add(xObject);
  138. }
  139. /**
  140. * Add a ColorSpace dictionary to the resources.
  141. * @param colorSpace the color space
  142. */
  143. public void addColorSpace(PDFColorSpace colorSpace) {
  144. this.colorSpaces.put(new PDFName(colorSpace.getName()), colorSpace);
  145. if (colorSpace instanceof PDFICCBasedColorSpace) {
  146. PDFICCBasedColorSpace icc = (PDFICCBasedColorSpace)colorSpace;
  147. String desc = ColorProfileUtil.getICCProfileDescription(
  148. icc.getICCStream().getICCProfile());
  149. this.iccColorSpaces.put(desc, colorSpace);
  150. }
  151. }
  152. /**
  153. * Returns a ICCBased color space by profile name.
  154. * @param desc the name of the color space
  155. * @return the requested color space or null if it wasn't found
  156. */
  157. public PDFICCBasedColorSpace getICCColorSpaceByProfileName(String desc) {
  158. PDFICCBasedColorSpace cs = (PDFICCBasedColorSpace)this.iccColorSpaces.get(desc);
  159. return cs;
  160. }
  161. /**
  162. * Returns a color space by name.
  163. * @param name the name of the color space
  164. * @return the requested color space or null if it wasn't found
  165. */
  166. public PDFColorSpace getColorSpace(PDFName name) {
  167. PDFColorSpace cs = (PDFColorSpace)this.colorSpaces.get(name);
  168. return cs;
  169. }
  170. @Override
  171. public int output(OutputStream stream) throws IOException {
  172. populateDictionary();
  173. return super.output(stream);
  174. }
  175. private void populateDictionary() {
  176. if (!this.fonts.isEmpty()) {
  177. PDFDictionary dict = new PDFDictionary(this);
  178. /* construct PDF dictionary of font object references */
  179. Iterator fontIterator = this.fonts.keySet().iterator();
  180. while (fontIterator.hasNext()) {
  181. String fontName = (String)fontIterator.next();
  182. dict.put(fontName, (PDFFont)this.fonts.get(fontName));
  183. }
  184. put("Font", dict);
  185. }
  186. if (!this.shadings.isEmpty()) {
  187. PDFDictionary dict = new PDFDictionary(this);
  188. for (Iterator iter = shadings.iterator(); iter.hasNext();) {
  189. PDFShading currentShading = (PDFShading)iter.next();
  190. dict.put(currentShading.getName(), currentShading);
  191. }
  192. put("Shading", dict);
  193. }
  194. if (!this.patterns.isEmpty()) {
  195. PDFDictionary dict = new PDFDictionary(this);
  196. for (Iterator iter = patterns.iterator(); iter.hasNext();) {
  197. PDFPattern currentPattern = (PDFPattern)iter.next();
  198. dict.put(currentPattern.getName(), currentPattern);
  199. }
  200. put("Pattern", dict);
  201. }
  202. PDFArray procset = new PDFArray(this);
  203. procset.add(new PDFName("PDF"));
  204. procset.add(new PDFName("ImageB"));
  205. procset.add(new PDFName("ImageC"));
  206. procset.add(new PDFName("Text"));
  207. put("ProcSet", procset);
  208. if (this.xObjects != null && !this.xObjects.isEmpty()) {
  209. PDFDictionary dict = new PDFDictionary(this);
  210. for (Iterator iter = xObjects.iterator(); iter.hasNext();) {
  211. PDFXObject xobj = (PDFXObject)iter.next();
  212. dict.put(xobj.getName().toString(), xobj);
  213. }
  214. put("XObject", dict);
  215. }
  216. if (!this.gstates.isEmpty()) {
  217. PDFDictionary dict = new PDFDictionary(this);
  218. for (Iterator iter = gstates.iterator(); iter.hasNext();) {
  219. PDFGState gs = (PDFGState)iter.next();
  220. dict.put(gs.getName(), gs);
  221. }
  222. put("ExtGState", dict);
  223. }
  224. if (!this.colorSpaces.isEmpty()) {
  225. PDFDictionary dict = new PDFDictionary(this);
  226. for (Iterator iter = colorSpaces.values().iterator(); iter.hasNext();) {
  227. PDFColorSpace colorSpace = (PDFColorSpace)iter.next();
  228. dict.put(colorSpace.getName(), colorSpace);
  229. }
  230. put("ColorSpace", dict);
  231. }
  232. }
  233. }