While there is no proper Rest API support for this, you can still get this to work. I have created a GitHub gist which details the necessary steps using NodeJS.
If you hover over the "Export to PDF" and the "Export to Word" buttons in Confluence you can see the links that are called when you press those buttons. You can do a GET on these URLs to get the objects.
So the URL would be something like (for PDF):
"confluenceurl" + "/spaces/flyingpdf/pdfpageexport.action?pageId=PAGE_ID"
The auto-generated filename is then in the "content-disposition" of the return object. But you can always set your own filename.
The content of the file is in the return object's content.
We use the above method and python to dynamically export pages to PDF when we need to.
Hope that helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Seems to work as well!
The URL is simpler and something like this:
"CONFLUENCE_URL" + "exportword?pageId=PAGE_ID"
Like above, the filename is in the content-disposition header but you can always set your own if you don't want the auto-generated file name.
The content of the file is in the "content" of the return object. You can simply write that to a file.
I tested this morning with a bit of python code and it worked fine.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It doesn't work for me.My confluence server is local.
How can I export word using template?
I have tried rest api GET 'http://CONFLUENCE_URL/plugins/servlet/scroll-office/api/public/1/export-sync?templateId=com.k15t.scroll.office.default-template-1&pageId=67415595'
But the response downloaded word is error coding.
And I also tried the rest api POST 'http://CONFLUENCE_URL/plugins/servlet/scroll-office/api/public/1/exports'
But the response is {
"status": 403,
"message": "User not allowed to export because of export restrictions on either space or groups."
}
According to the document https://help.k15t.com/scroll-pdf-exporter/latest/server/export-content-via-rest-api-125699615.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Elliot Sloman
Using Confluence cloud, when I try doing a GET request to that URL via Postman to export the PDF, then HTML content is returned, not JSON, and there is no 'content-disposition' object.
Can you provide more details and an example for doing that GET request.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm working on the same type of issue but only for pdf's. If you're using Python, you can use the confluence package (https://atlassian-python-api.readthedocs.io/confluence.html) and the export_page function for pdf.
confluence.export_page(page_id)
As the doc indicates, if you're using Confluence Cloud, make sure when you instantiate confluence that you set the api_version to cloud.
confluence = Confluence( url='https://yourcompany.atlassian.net/', api_version='cloud', username=username, password=password)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Larry.D.East Were you able to get the PDF exported? What is the scope that was used?
token={
"access_token": "token_xxx",
"token_type": "Bearer"
}
oauth2_dict = {
"client_id": "client_id_xxx",
"token": token}
confluence= Confluence( url='https://api.atlassian.com/ex/confluence/{cloud_id_xxx}',
oauth2=oauth2_dict)
With the above code, I am able to use the OAuth2.0 authentication and make other functions like 'get_spaces' working. However, the export_page, doesn't return the PDF. Receiving an error "Unauthorized; scope does not match"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's been a while since I worked on this so I'll make the disclaimer upfront that it's all a little fuzzy now :) From what I can find of the source code I still have access to, I didn't specify a scope. However, a quick search turned up these two links, https://community.developer.atlassian.com/t/unauthorized-scope-does-not-match-forge-app/49459 and https://community.developer.atlassian.com/t/scope-does-not-match/49346, both of which point to recreating the app as a confluence app instead of a jira app. Don't know if that's your situation, but hope it helps. Good luck!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @PASUPULA REDDY ,
you might want to have a look at our Scroll PDF Exporter, which lets you easily create templates using a graphical template designer, without the need to know any CSS.
Additionally you can use our REST API (or even Java API) to perform exports automatically.
Scroll PDF Exporter is available via the Atlassian Marketplace and can be tested using a free evaluation license.
Cheers,
Nils
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
thanks for the reply, It would be great for us if you share the code along with the http head managers.
Regards,
Kulasekhar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@PASUPULA REDDY There are no rest api's to export PDF/Word out of Confluence.
But there exists SOAP API's for this - https://developer.atlassian.com/server/confluence/remote-api-specification-for-pdf-export/
Please do verify if SOAP is working with your version of Confluence as Atlassian team is looking to deprecate it as soon as all its features are replicated in REST.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.