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.

external.fo 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xlink="http://www.w3.org/1999/xlink">
  3. <fo:layout-master-set>
  4. <fo:simple-page-master master-name="first"
  5. margin-right="1.5cm"
  6. margin-left="1.5cm"
  7. margin-bottom="2cm"
  8. margin-top="1cm"
  9. page-width="21cm"
  10. page-height="29.7cm">
  11. <fo:region-body margin-top="1cm"/>
  12. <fo:region-before extent="1cm"/>
  13. <fo:region-after extent="1.5cm"/>
  14. </fo:simple-page-master>
  15. </fo:layout-master-set>
  16. <fo:page-sequence master-reference="first">
  17. <fo:static-content flow-name="xsl-region-before">
  18. <fo:block line-height="14pt" font-size="10pt"
  19. text-align="end">External SVG examples</fo:block>
  20. </fo:static-content>
  21. <fo:static-content flow-name="xsl-region-after">
  22. <fo:block line-height="14pt" font-size="10pt"
  23. text-align="end">Page <fo:page-number/></fo:block>
  24. </fo:static-content>
  25. <fo:flow flow-name="xsl-region-body">
  26. <fo:block text-align="center" font-weight="bold" font-size="14pt" space-before.optimum="3pt" space-after.optimum="15pt">
  27. External SVG
  28. </fo:block>
  29. <fo:block space-before.optimum="3pt" space-after.optimum="20pt">
  30. </fo:block>
  31. <fo:block text-align="center">
  32. Some examples of how to reference external SVG images in your FO documents
  33. </fo:block>
  34. <fo:block break-before="page" space-after.optimum="10pt" font-weight="bold" font-size="12pt">
  35. Introduction
  36. </fo:block>
  37. <fo:block>
  38. This document shows some examples of how an SVG document can be in an external svg file
  39. which is referenced using the fo:external-graphic.
  40. </fo:block>
  41. <fo:block>
  42. </fo:block>
  43. <fo:block space-after.optimum="10pt" font-weight="bold" font-size="12pt">
  44. Examples
  45. </fo:block>
  46. <fo:block>
  47. The following svg document is obtained from an external file using the fo:external-graphic.
  48. </fo:block>
  49. <fo:block>
  50. <fo:external-graphic src="file:boxes.svg"/>
  51. </fo:block>
  52. <fo:block>
  53. This svg document (<fo:external-graphic src="file:multi.svg"/>) is also obtained from
  54. an external file using the fo:external-graphic. It has another svg image inside and references
  55. part of another svg image.
  56. </fo:block>
  57. <fo:block>
  58. This inline svg document (
  59. <fo:instream-foreign-object>
  60. <svg xmlns="http://www.w3.org/2000/svg" width="60" height="40" xml:space="preserve">
  61. <g style="fill:none;stroke:yellow">
  62. <rect x="0" y="0" width="25" height="25"/>
  63. <image xlink:href="file:boxes.svg" x="10" y="10" width="20" height="20"/>
  64. </g>
  65. <g>
  66. <use xlink:href="file:ref.svg#FOP" transform="scale(1.5)" x="12" y="25"/>
  67. </g>
  68. </svg>
  69. </fo:instream-foreign-object>
  70. ) has an external svg image inside and references part of another svg image.
  71. </fo:block>
  72. <fo:block>
  73. Apart from this external svg images should behave in the same way that other types of
  74. external graphics do.
  75. </fo:block>
  76. <fo:block space-before.optimum="10pt">
  77. The following example shows how you could scale an external svg file.
  78. </fo:block>
  79. <fo:block>
  80. <fo:instream-foreign-object>
  81. <svg xmlns="http://www.w3.org/2000/svg" width="20mm" height="20mm" xml:space="preserve">
  82. <svg viewBox="0 0 20 20" preserveAspectRatio="none">
  83. <image xlink:href="file:boxes.svg" x="0" y="0" width="20mm" height="20mm"/>
  84. </svg>
  85. </svg>
  86. </fo:instream-foreign-object>
  87. and
  88. <fo:instream-foreign-object>
  89. <svg xmlns="http://www.w3.org/2000/svg" width="20mm" height="20mm" xml:space="preserve">
  90. <g transform="scale(3.7)">
  91. <image xlink:href="file:boxes.svg" x="0" y="0" width="20mm" height="20mm"/>
  92. </g>
  93. </svg>
  94. </fo:instream-foreign-object>
  95. and
  96. <fo:instream-foreign-object>
  97. <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" width="20mm" height="20mm" xml:space="preserve">
  98. <image preserveAspectRatio="xMidYMid" xlink:href="file:boxes.svg" x="0" y="0" width="10mm" height="10mm"/>
  99. </svg>
  100. </fo:instream-foreign-object>
  101. </fo:block>
  102. <fo:block space-before.optimum="10pt">
  103. This example is an svg from an external image:
  104. <fo:external-graphic src="file:view.svg"/>
  105. it has a viewbox that resizes the contents.
  106. </fo:block>
  107. </fo:flow>
  108. </fo:page-sequence>
  109. </fo:root>