I am generating pdf using FOP, and I want to include border for every page in pdf. I am using XSLT 2.0.
Is there any way or any attribute or any tags to create a border for every page in XSL?
You can add a border
attribute to the fo:region-*
elements (and padding
too, if needed).
Note that, strictly speaking, this is not allowed by the XSL recommendation:
The values of the padding and border-width traits must be "0".
and the standard behaviour of FOP would be to end with a validation error:
SEVERE: Exception javax.xml.transform.TransformerException:
org.apache.fop.fo.ValidationException: Border and padding for fo:region-body
"xsl-region-body" should be '0' (See 6.4.14 in XSL 1.1); non-standard values
are allowed if relaxed validation is enabled. (See position ...)
However, as this is after all a common use case and other formatters allow this too, you can run FOP with relaxed validation and get the desired output:
-r
if you are running FOP from the command lineFopFactoryBuilder.setStrictFOValidation()
method in the Java codeYou still get a warning about the non-standard behaviour, but the processing continues normally:
WARNING: Border and padding for fo:region-body "xsl-region-body" should be '0'
(See 6.4.14 in XSL 1.1); non-standard values are allowed if relaxed validation
is enabled. (See position ...)