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.

PageDescriptor.java 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright 2006 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.afp.modca;
  18. import java.io.IOException;
  19. import java.io.OutputStream;
  20. import org.apache.fop.render.afp.tools.BinaryUtils;
  21. /**
  22. * The Page Descriptor structured field specifies the size and attributes of
  23. * a page or overlay presentation space.
  24. *
  25. */
  26. public class PageDescriptor extends AbstractAFPObject {
  27. private int _width = 0;
  28. private int _height = 0;
  29. /**
  30. * Construct a page descriptor for the specified page width
  31. * and page height.
  32. * @param width The page width.
  33. * @param height The page height.
  34. */
  35. public PageDescriptor(int width, int height) {
  36. _width = width;
  37. _height = height;
  38. }
  39. /**
  40. * Accessor method to write the AFP datastream for the Page Descriptor
  41. * @param os The stream to write to
  42. * @throws java.io.IOException
  43. */
  44. public void writeDataStream(OutputStream os)
  45. throws IOException {
  46. byte[] data = new byte[] {
  47. 0x5A,
  48. 0x00,
  49. 0x17,
  50. (byte) 0xD3,
  51. (byte) 0xA6,
  52. (byte) 0xAF,
  53. 0x00,
  54. 0x00,
  55. 0x00,
  56. 0x00,
  57. 0x00,
  58. 0x09,
  59. 0x60,
  60. 0x09,
  61. 0x60,
  62. 0x00,
  63. 0x00,
  64. 0x00,
  65. 0x00,
  66. 0x00,
  67. 0x00,
  68. 0x00,
  69. 0x00,
  70. 0x00,
  71. };
  72. byte[] x = BinaryUtils.convert(_width, 3);
  73. data[15] = x[0];
  74. data[16] = x[1];
  75. data[17] = x[2];
  76. byte[] y = BinaryUtils.convert(_height, 3);
  77. data[18] = y[0];
  78. data[19] = y[1];
  79. data[20] = y[2];
  80. os.write(data);
  81. }
  82. }