1

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?

Tony Graham
  • 7,306
  • 13
  • 20
h.sundblad
  • 13
  • 4
  • Let me get back to you. It should be possible by overlaying two versions of the text, e.g., as two relatively positioned blocks inside an `fo:inline-container` (provided that you don't have line breaks inside the links, that is). – Tony Graham Oct 23 '17 at 19:53
  • That would be very much appreciated, The links will not contain any line breaks :) – h.sundblad Oct 24 '17 at 06:52

1 Answers1

0

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

Tony Graham
  • 7,306
  • 13
  • 20
  • Works like a charm. – h.sundblad Oct 27 '17 at 14:31
  • When setting `text-align` on the outermost `fo:block` to either `"center"` or `"right"` the result become a bit peculiar. The two layers seem to get offset from each other. Do you have any idea why and if there is a way to generate the two layers on top of each other even when using `text-align="right"`? – h.sundblad Oct 31 '17 at 07:29