Search code examples
pdfxsl-foantenna-house

XSL-FO Hyperlinks in PDF - Print Off View On - Antenna House


I am genereating PDF-files with links and want them to be displayed differently when viewing them in a PDF viewer than when printing them. When viewing them the links are to have a blue border around the link, but when printed there shall be no border.

I am using Antenna House Formatter v6.3 and know that you can use axf:layer-settings and axf:layer to create layers and control the print and view-behavior of those layers. But I have not been successful to achieve the above described behavior (I can only make the entire link disappear in print, not just the border).

Is there any way to use the Antenna House extensions or some other way to make links in PDF generated via XSL-FO and a formatting engine to have different appearances in view and print?


Solution

  • Try this. You may need to adjust the baseline-shift value, depending on your font:

    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
      xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions"
      axf:layer-settings="'layer4' view off print on,'layer5' view on print off export off">
    ...
    <fo:block space-before="1em">abcd <fo:inline-container alignment-baseline="baseline" baseline-shift="-3pt">
        <fo:block-container position="absolute" axf:layer="layer5">
            <fo:block>
                <fo:basic-link border="thin solid blue" alignment-baseline="baseline" external-destination="http://www.antennahouse.com/">Antenna House</fo:basic-link>
            </fo:block>
        </fo:block-container>
        <fo:block-container axf:layer="layer4">
            <fo:block>
                <fo:basic-link border="thin solid transparent" external-destination="http://www.antennahouse.com/">Antenna House</fo:basic-link>
            </fo:block>
        </fo:block-container>
    </fo:inline-container> efgh</fo:block>
    

    Requires PDF 1.5 or later. See https://www.antennahouse.com/product/ahf65/ahf-ext.html#pdf-layer