styles.inc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. // Example styles
  3. // This is an example of how a "style sheet" should be structured
  4. // to asign PHPWord styles to HTML elements, classes, and inline
  5. // styles.
  6. function htmltodocx_styles() {
  7. // Set of default styles -
  8. // to set initially whatever the element is:
  9. // NB - any defaults not set here will be provided by PHPWord.
  10. $styles['default'] =
  11. array (
  12. 'size' => 11,
  13. );
  14. // Element styles:
  15. // The keys of the elements array are valid HTML tags;
  16. // The arrays associated with each of these tags is a set
  17. // of PHPWord style definitions.
  18. $styles['elements'] =
  19. array (
  20. 'h1' => array (
  21. 'bold' => TRUE,
  22. 'size' => 20,
  23. ),
  24. 'h2' => array (
  25. 'bold' => TRUE,
  26. 'size' => 15,
  27. 'spaceAfter' => 150,
  28. ),
  29. 'h3' => array (
  30. 'size' => 12,
  31. 'bold' => TRUE,
  32. 'spaceAfter' => 100,
  33. ),
  34. 'li' => array (
  35. ),
  36. 'ol' => array (
  37. 'spaceBefore' => 200,
  38. ),
  39. 'ul' => array (
  40. 'spaceAfter' => 150,
  41. ),
  42. 'b' => array (
  43. 'bold' => TRUE,
  44. ),
  45. 'em' => array (
  46. 'italic' => TRUE,
  47. ),
  48. 'i' => array (
  49. 'italic' => TRUE,
  50. ),
  51. 'strong' => array (
  52. 'bold' => TRUE,
  53. ),
  54. 'b' => array (
  55. 'bold' => TRUE,
  56. ),
  57. 'sup' => array (
  58. 'superScript' => TRUE,
  59. 'size' => 6,
  60. ), // Superscript not working in PHPWord
  61. 'u' => array (
  62. 'underline' => PHPWord_Style_Font::UNDERLINE_SINGLE,
  63. ),
  64. 'a' => array (
  65. 'color' => '0000FF',
  66. 'underline' => PHPWord_Style_Font::UNDERLINE_SINGLE,
  67. ),
  68. 'table' => array (
  69. // Note that applying a table style in PHPWord applies the relevant style to
  70. // ALL the cells in the table. So, for example, the borderSize applied here
  71. // applies to all the cells, and not just to the outer edges of the table:
  72. 'borderColor' => '000000',
  73. 'borderSize' => 10,
  74. ),
  75. 'th' => array (
  76. 'borderColor' => '000000',
  77. 'borderSize' => 10,
  78. ),
  79. 'td' => array (
  80. 'borderColor' => '000000',
  81. 'borderSize' => 10,
  82. ),
  83. );
  84. // Classes:
  85. // The keys of the classes array are valid CSS classes;
  86. // The array associated with each of these classes is a set
  87. // of PHPWord style definitions.
  88. // Classes will be applied in the order that they appear here if
  89. // more than one class appears on an element.
  90. $styles['classes'] =
  91. array (
  92. 'underline' => array (
  93. 'underline' => PHPWord_Style_Font::UNDERLINE_SINGLE,
  94. ),
  95. 'purple' => array (
  96. 'color' => '901391',
  97. ),
  98. 'green' => array (
  99. 'color' => '00A500',
  100. ),
  101. );
  102. // Inline style definitions, of the form:
  103. // array(css attribute-value - separated by a colon and a single space => array of
  104. // PHPWord attribute value pairs.
  105. $styles['inline'] =
  106. array(
  107. 'text-decoration: underline' => array (
  108. 'underline' => PHPWord_Style_Font::UNDERLINE_SINGLE,
  109. ),
  110. 'vertical-align: left' => array (
  111. 'align' => 'left',
  112. ),
  113. 'vertical-align: middle' => array (
  114. 'align' => 'center',
  115. ),
  116. 'vertical-align: right' => array (
  117. 'align' => 'right',
  118. ),
  119. );
  120. return $styles;
  121. }