Embedded links with page number
This section explains how to create a page that includes embedded links with page numbers for PDF export.
For more information, see the following:
​Custom stylesheet​
​User macro​
​Anchors​

Creating a page including embedded links with page number

Before you begin: Use the following page hierarchy.

Creating a Custom Stylesheet

Important: You need administrator rights in order to carry out the following steps.
1. Create or modify a custom stylesheet using the following CSS code:
a.embedded-page-link::after{
content: "("target-counter(attr(href), page, decimal)")";
}
2. Create a user macro with the following example settings.
## @noparams
#if ( $renderContext.getOutputType().toLowerCase() =="pdf" )
#set($outputHtml= $body.replaceAll(">.*</a>","></a>").replaceAll("<a href=", "<a class='embedded-page-link' href="))
#else
#set($outputHtml = $body)
#end
$outputHtml
Follow these to create a link on the Embedded link Home page that links a table at the Another page in the export page.
1. Edit Another page in the export and add an Anchor tag to the table:
​
2. Edit Embedded link Home and insert the user macro here:
3. Add a link to the Link field with the page name and the anchor's name:
  • Link: <Page name>#<AnchorName>
  • Link text: Any text what you want to see on the page.
Result: You setting should look like this:

Printing settings with Content Exporter

  1. 1.
    Go to your first exportable page (which in this case it is "Embedded link Home").
  2. 2.
    In the page menu click on Export to PDF.
  3. 3.
    Customize for this export.
  4. 4.
    Click on Stylesheet (CSS) β†’ Edit.
  5. 5.
    Select the custom style sheet you created (See Creating a Custom Style Sheet).
  6. 6.
    Click on Apply to save your settings.
  7. 7.
    Select content as desired.
  8. 8.
    Click on Export.

Changing results

You can change the text on your Confluence page by changing the Linked text in the user macro's editable field.
You can change the exported text in the PDF by changing your Custom CSS Style (the export result is (<page number>)).
Here are some examples on how you can do that:
a.embedded-page-link-see::after{
content: "See on page: " target-counter(attr(href), page, decimal);
}
a.embedded-page-link-check::after{
content: "Check " target-counter(attr(href), page, decimal) " page.";
}
Copy link
On this page
Creating a page including embedded links with page number
Creating a Custom Stylesheet
Creating a link
Printing settings with Content Exporter
Changing results