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.

EPSDocumentGraphics2D.java 3.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright 2003-2005 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.render.ps;
  18. import java.io.IOException;
  19. import org.apache.fop.Version;
  20. /**
  21. * This class is a wrapper for the <tt>AbstractPSDocumentGraphics2D</tt> that
  22. * is used to create EPS (Encapsulated PostScript) files instead of PS file.
  23. *
  24. * @version $Id$
  25. * @see org.apache.fop.render.ps.PSGraphics2D
  26. * @see org.apache.fop.render.ps.AbstractPSDocumentGraphics2D
  27. */
  28. public class EPSDocumentGraphics2D extends AbstractPSDocumentGraphics2D {
  29. /**
  30. * Create a new EPSDocumentGraphics2D.
  31. * This is used to create a new EPS document, the height,
  32. * width and output stream can be setup later.
  33. * For use by the transcoder which needs font information
  34. * for the bridge before the document size is known.
  35. * The resulting document is written to the stream after rendering.
  36. *
  37. * @param textAsShapes set this to true so that text will be rendered
  38. * using curves and not the font.
  39. */
  40. public EPSDocumentGraphics2D(boolean textAsShapes) {
  41. super(textAsShapes);
  42. }
  43. protected void writeFileHeader() throws IOException {
  44. final Long pagewidth = new Long(this.width);
  45. final Long pageheight = new Long(this.height);
  46. //PostScript Header
  47. gen.writeln(DSCConstants.PS_ADOBE_30 + " " + DSCConstants.EPSF_30);
  48. gen.writeDSCComment(DSCConstants.CREATOR,
  49. new String[] {"Apache FOP " + Version.getVersion()
  50. + ": EPS Transcoder for SVG"});
  51. gen.writeDSCComment(DSCConstants.CREATION_DATE,
  52. new Object[] {new java.util.Date()});
  53. gen.writeDSCComment(DSCConstants.PAGES, new Integer(0));
  54. gen.writeDSCComment(DSCConstants.BBOX, new Object[]
  55. {ZERO, ZERO, pagewidth, pageheight});
  56. gen.writeDSCComment(DSCConstants.LANGUAGE_LEVEL, new Integer(gen.getPSLevel()));
  57. gen.writeDSCComment(DSCConstants.END_COMMENTS);
  58. //Prolog
  59. gen.writeDSCComment(DSCConstants.BEGIN_PROLOG);
  60. PSProcSets.writeFOPStdProcSet(gen);
  61. PSProcSets.writeFOPEPSProcSet(gen);
  62. if (fontInfo != null) {
  63. PSFontUtils.writeFontDict(gen, fontInfo);
  64. }
  65. gen.writeDSCComment(DSCConstants.END_PROLOG);
  66. }
  67. protected void writePageHeader() throws IOException {
  68. Integer pageNumber = new Integer(this.pagecount);
  69. gen.writeDSCComment(DSCConstants.PAGE, new Object[]
  70. {pageNumber.toString(), pageNumber});
  71. gen.writeDSCComment(DSCConstants.PAGE_BBOX, new Object[]
  72. {ZERO, ZERO, new Integer(width), new Integer(height)});
  73. gen.writeDSCComment(DSCConstants.BEGIN_PAGE_SETUP);
  74. if (fontInfo != null) {
  75. gen.writeln("FOPFonts begin");
  76. }
  77. }
  78. protected void writePageTrailer() throws IOException {
  79. gen.writeDSCComment(DSCConstants.PAGE_TRAILER);
  80. gen.writeDSCComment(DSCConstants.END_PAGE);
  81. }
  82. }