Atlassian CLI - Export multiple pages to single pdf
Asked by Julius Knorr:

Hi everyone,

I installed the Confluence CLI to export certain pages automatically with a script to pdf files.

Currently the script works like this:

$pageNames = ... --action getPageList --space $space --labels $relevant_labels

foreach ($page in $pageNames)

{

... --action exportPage --space $space --title $page --file "...\\fileName.pdf"

}

This works fine and I get one pdf file per page. But I would prefer getting just a single pdf with all pages included. Especially when it comes to pages with subpages.

* Is this possible with the ACLI? e.g. ist there an option like "exportToSingleFile" or sth. like that?
* Is there is an option that a parent page is with its subpages exported to a single file? (If I trigger exportPage with --descendents)
* In general: where do I find the options for *--options* anyway? Because in the docu it only says "action specific advanced options" - well, thanks for nothing..

I know, that I could do it manually with the Content Exporter App, but the goal is that the pages are exported automatically.

Hope someone can give me some help here.

Thanks a lot!


Answers:
author: Sreeja Manchala {Appfire}
body: Hi [@Julius Knorr](/t5/user/viewprofilepage/user-id/4615145)

Good day, I am Sreeja Manchala from the Bobswift support team. We have created a support request <https://bobswift.atlassian.net/servicedesk/customer/portal/1/SUPPORT-8542> to better track your request. However, we couldn't add you as a reporter. Please sign up using this link <https://bobswift.atlassian.net/servicedesk/customer/portal/1/user/signup>and share the user name/id. We'll then add you as the reporter and confirm.  

In order to export a space with all the pages(and subpages) included in it to a single PDF file, then please run the action command like below  

```
--action exportSpace --space SRS --file "demo.pdf" --exportType "PDF"
```

<br />

If you would like to export a specific page in a space with all the subpages included in it then pass the command like below, here include the parameter "title" of the parent page  

```
--action exportSpace --space SRS --title "demo" --file "demo.pdf" --exportType "PDF"
```

<br />

Please test the above commands with the latest version of the app <https://bobswift.atlassian.net/wiki/spaces/ACLI/pages/16875586/Downloads> and let us know the results, and we always recommend our customers to be on the latest version of the apps so that it includes the latest features and bug fixes.  

Please let us know if you need any further assistance on this by signing up so, that we could help you better in resolving the issue on the ticket.  

Regards,  
Sreeja

comments: author: Julius Knorr
body: Hi Sreeja,

thanks for your quick response and support! Really appreciate that.

I sign up to your Helpdesk with the same name as in this forum*(Julius Knorr).*

What I forgot to mention is, that I get the list of pages that need to be exported with getPageList --labels "mylabels".

So with exportSpace --title "pagetitle" I can export the page like a space and get a nice single pdf file. That's awesome and kinda solves my problem.

It would be even better, if exportSpace would support the --labels option. Then I could spare my first step. But even like that it works fine.

Thanks again!

Best regards,

Julius


author: Sreeja Manchala {Appfire}
body: Hi [@Julius Knorr](/t5/user/viewprofilepage/user-id/4615145)   

As per our discussion on support ticket <https://bobswift.atlassian.net/servicedesk/customer/portal/1/SUPPORT-8542>, the below commands worked for you.

To export the pages with the given labels,

```
--action runFromPageList --labels "mylabels" --common " --action exportPage --id "@pageId@" --exportType "PDF" --file "@pageId@.pdf""
```

To export the pages having the label along with the sub-pages included in it,

```
--action runFromPageList  --labels "mylabels" --common " --action exportSpace --space "@space@" --title \""@title@\""  --exportType "PDF" --file "@pageId@.pdf""

```

If you have any further questions regarding our Appfire apps, please don't hesitate to contact us again; we're happy to help!

You can raise a request with us using the below link for Bobswift apps:  
<https://bobswift.atlassian.net/servicedesk/customer/portal/1>  

Regards,  
Sreeja


author: Matthias Gaiser _K15t_
body: Hi [@Julius Knorr](/t5/user/viewprofilepage/user-id/4615145)

welcome to the Atlassian Community.

I don't know of a way how to leverage the standard PDF export for combining multiple pages into a PDF.

But I have another solution for you how you could accomplish it. My colleagues build the [Scroll PDF Exporter](https://marketplace.atlassian.com/apps/7019/scroll-pdf-exporter-for-confluence?tab=overview&hosting=datacenter). With this app you can define your own export templates, style them as you want - and also export one page and all its child pages.  
And you can also start the [export via a REST API](https://help.k15t.com/scroll-pdf-exporter/4.9/server/export-content-via-rest-api-125699615.html), therefore you could trigger it from your script.

How does that sound?

Cheers,  
Matthias.

comments: author: Julius Knorr
body: Hi Matthias,

thanks a lot! :)  
This sounds really interesting and I will take a closer look at it.

Cheers,  
Julius


author: Matthias Gaiser _K15t_
body: You're welcome.

And because I've read your reply above, there's an option in the Scroll PDF Exporter when you design a template that you specify labels for pages you want to include or exclude from the export.  
Just to let you know.

Have success in finding a fitting solution for your use case.


Tags: bob-swift

cli

confluence-server

server