I’m sure this has come up before, but I can’t find anything about it, not even among the extensions.
I’ve edited a page where in a section I mention an attachment, which is linked from the page content. I now need to send a PDF export of this page and would like to hide the section that talks about the attachment (that plus mentions some reserved URL’s and hosts).
I don’t have a ready-made solution but I think you could use regular CSS print styles to control the display of the content. Basically, you could add, e.g., a certain class attribute to all content that shouldn’t be printed and then centrally create a CSS style to hide it. If you want to make this easier to use for users, you could create a wiki macro that wraps its content in a group with the respective class like the following example macro code:
you could then prevent printing the macro content.
[Edit] Actually, you don’t even need to add any CSS, just use the class hidden-print that is already present in XWiki as it is defined in Bootstrap 3. So the following macro code in a wiki macro should do the trick:
Thanks for the idea. Looks like it would do the job.
However, I think it’s a bit less clean than what we used to be able to write as the print or non-print content is produced even when not in that context. I hope we can still have some server-side IF.
@vmassol not all users are able to use the server-side IF (some don’t have script right and some don’t have coding skills). Moreover, using a script macro makes editing a pain: you need to edit the source. Besides that, the script is easily broken if someone without script right saves a change to the content.
The wiki rendering macro suggested by @MichaelHamann is much more user-friendly. Using the script directly makes sense only if the section you want to hide from PDF is very costly to generate. But for standard content the performance penalty is insignificant.