xsl fo - Gradient background for PDF -
is there way add pdf gradient background using fo? background image well, doesn't matter. add page, not body region.
certainly. on create svg image matches want gradient. example, using linear gradient yellow red, left right.
<svg xmlns="http://www.w3.org/2000/svg" version="1.0" height="1in" width="8.5in"> <defs> <lineargradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%"> <stop offset="0%" style="stop-color:rgb(255,255,0);stop-opacity:1" /> <stop offset="100%" style="stop-color:rgb(255,0,0);stop-opacity:1" /> </lineargradient> </defs> <rect width="8.5in" height="1in" fill="url(#grad1)" /> </svg>
then, insert background image region-before of page , set extent of page full height of page:
<fo:root xmlns:fo="http://www.w3.org/1999/xsl/format" xmlns:svg="http://www.w3.org/2000/svg" font-family="times" font-size="16px"> <fo:layout-master-set> <fo:simple-page-master master-name="backgrad" page-width="8.5in" page-height="11in"> <fo:region-body/> <fo:region-before extent="11in" background-image="backgrad.svg"/> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="backgrad"> <fo:flow flow-name="xsl-region-body"> <fo:block> hello </fo:block> </fo:flow> </fo:page-sequence> </fo:root>
the result this:
Comments
Post a Comment