# Embedded links with page number

This section explains how to create a page that includes embedded links with page numbers for PDF export.&#x20;

For more information, see the following:

[Custom stylesheet](https://docs.meta-inf.hu/content-exporter-confluence/user-guides/before-exporting/custom-stylesheets/stylesheet-administration)

[User macro](https://confluence.atlassian.com/doc/writing-user-macros-4485.html)

[Anchors](https://confluence.atlassian.com/doc/anchors-139442.html)

## Creating a page including embedded links with page number <a href="#embeddedlinkwithpagenumber-step-by-stepguide" id="embeddedlinkwithpagenumber-step-by-stepguide"></a>

**Before you begin**: Use the following page hierarchy.

![](https://1860999847-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzRdmWgyGMtYCkkt1hFgr%2Fuploads%2FrfJSmCMj0b7GUkPMS0wd%2Fimage.png?alt=media\&token=cb97b672-0341-4f2b-8c40-fd2db587305e)

### Creating a Custom Stylesheet <a href="#embeddedlinkwithpagenumber-creatingacustomstylesheet" id="embeddedlinkwithpagenumber-creatingacustomstylesheet"></a>

{% hint style="warning" %}
**Important:** You need administrator rights in order to carry out the following steps.
{% endhint %}

1\. Create or modify a custom stylesheet using the following CSS code:

```css
a.embedded-page-link::after{
    content: "("target-counter(attr(href), page, decimal)")";
}
```

2\. Create a user macro with the following example settings.

![](https://1860999847-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzRdmWgyGMtYCkkt1hFgr%2Fuploads%2FrZzriCZhIinMAk490fq3%2Fimage.png?alt=media\&token=6ee0d6bb-3129-4505-9e3b-03582441b03e)

```velocity
## @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
```

### Creating a link <a href="#embeddedlinkwithpagenumber-creatingalink" id="embeddedlinkwithpagenumber-creatingalink"></a>

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:

![](https://1860999847-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzRdmWgyGMtYCkkt1hFgr%2Fuploads%2FV8hzOwSAvT3zYPMwuT1W%2Fimage.png?alt=media\&token=83f01731-345d-4e68-a3fe-3bbf6ef54f98)

![](https://1860999847-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzRdmWgyGMtYCkkt1hFgr%2Fuploads%2Fc1z7av64svpQJJq37ieY%2Fimage.png?alt=media\&token=e9b39217-968a-4402-a028-f7c323006b53)\
\
\ <br>

2\. Edit **Embedded link Home** and insert the user macro here:<br>

![](https://1860999847-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzRdmWgyGMtYCkkt1hFgr%2Fuploads%2FD1kWgpV2XFMLCSjRXwOx%2Fimage.png?alt=media\&token=b70872b2-36cc-4185-b137-a63c5a836f9b)

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.

![](https://1860999847-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzRdmWgyGMtYCkkt1hFgr%2Fuploads%2Fdf7UiXxtwPd4EGRkZ22Q%2Fimage.png?alt=media\&token=edf43c8f-5e21-4a60-824c-7e95ff8ce618)

**Result**: You setting should look like this:

![](https://1860999847-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzRdmWgyGMtYCkkt1hFgr%2Fuploads%2Fwl6z3QqO2v16L0SnkIUF%2Fimage.png?alt=media\&token=84ceea1a-0e5b-4d11-ba4c-0dcdef2dbd21)

### Printing settings with Content Exporter <a href="#embeddedlinkwithpagenumber-printsettingswithcontentexporter" id="embeddedlinkwithpagenumber-printsettingswithcontentexporter"></a>

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

### Changing results <a href="#embeddedlinkwithpagenumber-changeresults" id="embeddedlinkwithpagenumber-changeresults"></a>

You can change the text on your Confluence page by changing the Linked text in the user macro's editable field.&#x20;

You can change the exported text in the PDF by changing your **Custom CSS Style** (the export result is (\<page number>)).&#x20;

Here are some examples on how you can do that:

```css
a.embedded-page-link-see::after{
    content: "See on page: " target-counter(attr(href), page, decimal);
}
```

```css
a.embedded-page-link-check::after{
    content: "Check " target-counter(attr(href), page, decimal) " page.";
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.meta-inf.hu/content-exporter-confluence/user-guides/before-exporting/embedded-links-with-page-number.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
