How to export Confluence "space" to PDF using remote API

I am looking for examples of exporting a merge space in pdf format. The documents for this are terrible. It looks like it can still be supported in the latest merge (5.0) using the XML-RPC api. I can not find an example of what can be called.

https://developer.atlassian.com/display/CONFDEV/Remote+API+Specification+for+PDF+Export#RemoteAPISpecificationforPDFExport-XML-RPCInformation

These links say that calls should be prefixed with pdfexport , but then should not indicate any of the calls or give an example.

+6
source share
3 answers

I know this is a PHP example, not Ruby, but you can check the XML-RPC example in the VoycerAG PHP project on Github at https://github.com/VoycerAG/confluence-xmlrpc-pdf-export/blob/master/src /Voycer/Confluence/Command/PdfExportCommand.php ... hope this helps.

Basically, you just need to make a call to the login method, and the user needs the authentication token returned to call the exportSpace method. This in turn gives you a URL that an authenticated user can download PDF.

0
source

It turns out that the soap API is the only api currently available for exporting 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: 'https://example.atlassian.net/wiki/rpc/soap-axis/pdfexport?wsdl', read_timeout: 200) # call the 'findUser' operation response = client.call(:login, message: {username: "user", password: "pass"}) token = response.body[:login_response][:login_return] response = client.call(:export_space, message:{token: token, space_key: "SPACE KEY"}) 
0
source

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

 void exportSpaceAsPdf(spaceKey, File outputFile) { // Setup Pdf Export Service PdfExportRpcServiceLocator serviceLocator = new PdfExportRpcServiceLocator() serviceLocator.setpdfexportEndpointAddress("${url}/rpc/soap-axis/pdfexport") serviceLocator.setMaintainSession(true) 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) httpget.addHeader( BasicScheme.authenticate( 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 = inputStream.read()) != -1) fos.write(inByte) inputStream.close() fos.close() } else { throw new GradleException("""Cannot Export Space to PDF: Space: ${spaceKey} Dest: ${outputFile.absolutePath} URL: ${pdfUrl} Status: ${response.getStatusLine()} """) } } 
0
source

All Articles