How to export a Confluence "Space" to PDF using remote API

How can I export a Confluence 'space' as a pdf? It looks like it might still be supported in Confluence 5.0 using the XML-RPC API. I cannot find an example of what to call, though.

That link says calls should be prefixed with pdfexport, but then doesn't list any of the calls or give an example.


This works using Bob Swift's SOAP library ('org.swift.common:confluence-soap:5.4.1'). I'm using this in a gradle plugin, so you'll need to change a few things

void exportSpaceAsPdf(spaceKey, File outputFile) {
    // Setup Pdf Export Service
    PdfExportRpcServiceLocator serviceLocator = new PdfExportRpcServiceLocator()
    def pdfService = serviceLocator.getpdfexport()

    // Login
    def token = pdfService.login(user, password)

    // Perform Export
    def pdfUrl = pdfService.exportSpace(token, spaceKey)

    // Download Pdf
    HttpClient client  = new DefaultHttpClient();
    HttpGet httpget = new HttpGet(pdfUrl)
                    new UsernamePasswordCredentials(user,password),"UTF-8", false))
    HttpResponse response = client.execute(httpget)
    HttpEntity entity = response.getEntity()

    if (entity != null) {
        InputStream inputStream = entity.getContent()
        FileOutputStream fos = new FileOutputStream(outputFile)
        int inByte
        while ((inByte = != -1)
    } else {
        throw new GradleException("""Cannot Export Space to PDF:
        Space:  ${spaceKey}
        Dest:   ${outputFile.absolutePath}
        URL:    ${pdfUrl}
        Status: ${response.getStatusLine()}


I know this is a PHP example, not Ruby, but you can check out the XML-RPC example in VoycerAG's PHP project on Github at ... hope it helps.

Basically you just need to make a call to the login method and user the authentication token returned to make a call to the exportSpace method. That in turn gives you back a URL which an authenticated user can then download the PDF from.

Turns out the soap API is the only currently available api for exporting a space

Using the Savon library in Ruby here:

require 'savon'
# create a client for the service
# http://<confluence-install>/rpc/soap-axis/pdfexport?wsdll
client = Savon.client(wsdl: '', read_timeout: 200)

# call the 'findUser' operation
response =, message: {username: "user", password: "pass"})

token = response.body[:login_response][:login_return]

response =, message:{token: token, space_key: "SPACE KEY"})

Need Your Help

Do I have to make constructors for all inherited classes in java?

java inheritance constructor

My base class has a constructor with parameters (String, String, int)

draggable box width glitch

javascript css

Usually I prefer to write my own solutions for trivial problems because generally plugins add a lot of unneeded functionality and increase your project in size. Size makes a page slower and a 30k