[Confluence 3.5.13] Content Page in html

How can I get html content of page when I heve page ID? I am writing plugin for confluence (java api) and I need content of page in html (source of page).

3 answers

1 accepted

2 votes
Accepted answer
Joe Clark Atlassian Team May 20, 2012

You need to use the PageManager API to retrieve the content of the page, and then use the WikiStyleRenderer API to convert the wiki markup into the HTML markup for the page.

Here's a code snippet:

public class MyExampleClass
    private final PageManager pageManager;
    private final WikiStyleRenderer wikiStyleRenderer;

	public MyExampleClass(PageManager pageManager, WikiStyleRenderer wikiStyleRenderer)
	    this.pageManager = pageManager;
		this.wikiStyleRenderer = wikiStyleRenderer;
    public String getHtmlForPage(long pageId)
	    Page page = pageManager.getPage(pageId);
	    PageContext pageContext = page.toPageContext();
        String contentToRender = page.getContent();

        return wikiStyleRenderer.convertWikiToXHtml(pageContext, contentToRender);


I hope I have understood your question correctly. Confluence has the ability to allow you to export a space or a page in HTML (usually so it can be used for a website), this will allow you to view a page in HTML.

Directions are as follows:

  1. Go to a page in the space, open the 'Browse' menu and select 'Advanced'.

  2. Click 'HTML Export' in the left-hand panel.
    This option will only be visible if you have 'Export Space' permission.
  3. Select the check box 'Include Comments' if you want to include comments for the pages you are exporting.
  4. Select the pages you want to export by selecting the check boxes in the tree view of pages displayed. By default, all pages are selected. You have the option to 'Select All' or 'Deselect All' pages.
    If you select the check box of a page that contains one or more child or descendant pages, all of these child and descendant pages will also be selected. Similarly, if you clear the check box of such a page, all of its child and descendant pages will also be cleared. This provides a convenient method of exporting subtrees, for example, chapters or sections within a document.
  5. Click 'Export'. This will create a zipped archive of HTML files.
  6. When the export process has finished, download the zipped archive as prompted and extract the files into a folder.

More detailed information can be viewed at: Confluence 3.5 Documentation - Export to HTML

Hope that answers your issue!

Thanks for your answer!

I am writing confluence plugin and I want to take page as html code and process this string. I can use getContent() method (from Page class) but I get wiki markup. What class or method can I use in order to get html code page?

Hey Marcin,

I've been doing a lot of research on your question, and I've been struggling to find an inbuilt method to display HTML code for the page.

What I have found is the following: Wiki Markup Converters

The best one on there appears to be Wiky. It is written in Javascript and is bi-directional. It can convert your wiki markup to HTML, then convert the generated HTML back to wiki markup (should you need the function)

Hope this helps you.

Thank you very much!

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Feb 06, 2019 in Confluence

Try out the new editing experience

Hi team, I’m Avinoam, a product manager on Confluence Cloud, and today I’m really excited to let the Community know that all customers can now try out the new editing experience and see some of the ...

783 views 33 5
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you