Optional Content

Top Previous Topic Next Topic  Print this topic

The xf:optional-content annotation property is used to specify content that should be skipped when printing the generated PDF document.

 

Example of usage:

 

 

<?xml version="1.0" encoding="utf-8" ?>

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xf="http://www.ecrion.com/xf/1.0">

       <xf:annotation id="7">

               <xf:optional-content show-in-print="false" name="DoNotPrint"/>

       </xf:annotation>

       <fo:layout-master-set>

               <fo:simple-page-master master-name="all-pages" page-width="8.5in" page-height="11in">

                       <fo:region-body region-name="xsl-region-body" margin="0.7in" column-gap="0.25in" padding="6pt" />

                       <fo:region-before region-name="xsl-region-before" extent="0.7in" display-align="after" padding="6pt" />

                       <fo:region-after region-name="xsl-region-after" extent="0.7in" display-align="before" padding="6pt" />

                       <fo:region-start region-name="xsl-region-start" extent="0.7in"/>

                       <fo:region-end region-name="xsl-region-end" extent="0.7in"/>

               </fo:simple-page-master>

               <fo:page-sequence-master master-name="default-sequence">

                       <fo:repeatable-page-master-reference master-reference="all-pages" />

               </fo:page-sequence-master>

       </fo:layout-master-set>

       

       <fo:page-sequence master-reference="default-sequence">

               <fo:flow flow-name="xsl-region-body" font-size="12pt">

               <fo:block>

                       <fo:block font-family="Times" xf:annotation-reference="7" background-color="blue">

                               This block will not be printed and will only be visible on screen.

                       </fo:block>

                       <fo:block break-after="page" font-family="Times" background-color="red">

                               This block will be printed and will also be visible on screen.

                       </fo:block>

               </fo:block>

               </fo:flow>

       </fo:page-sequence>

</fo:root>

 

 

The code above will produce a PDF in which the first (blue) block is an optional content which will not be visible when printing. It will still be visible on screen when opening the document in a PDF viewer, while the second (red) block will be visible both on screen and when printing. This is because the first block references annotation with id 7, which specifies that the content is optional and therefore should not be visible when printing.

 

The following traits apply to the xf:optional-content annotation property:

 

·name - allows the user to specify a name for the annotation; value is a string
·show-in-print - specifies whether or not the content should be visible when printing; possible values are true or false (default is false)