Export to pdf for Confluence cloud

Hi,

Is any one guide me to implement export to pdf functionality for downloading pdf files with macro body at client side.

we did at app descriptor json file added below snipet

“renderModes”:
{
“pdf”: {
“url”: "/src/html/1.1/config/pdfpageexport.html
}
}
And corresponding pdfpageexport.html with respective JS included in out project. But we are able to see that JS file is not triggered or not executed . How can we achive this and documentation said that we can add in js file with below code. But the pdf is downloaded without macro body data.

AP.require(“request”, function(request) {
var pageId = getUrlParameter(“pageId”);
var pageVersion = getUrlParameter(“pageVersion”);
var macroId = getUrlParameter(“macroId”);
request({
url: “/rest/api/content/” + pageId +
“/history/” + pageVersion +
“/macro/id/” + macroId,
success: function(response) {
var macro = JSON.parse(response);
console.log(macro);
//process(macro.body);
//My html div tag where i need to paste content in html
$("#graphviz-global-render").on(“click”, function (e) {
window.top.location.href = macro.body;
});

If any one knows solutions, please help us with your guidance.

3 Likes

Hi @DharmaTeja ,

Thank you for raising this.

As of today, it is not possible to implement the export to PDF functionality from the client/frontend side.

The only option today is the one described on the Dynamic Content Macro page. In particular, this paragraph:

Since Dynamic Content Macros are rendered in an iframe, you are able to include your own style sheets and javascript. You can use these to create a rich, interactive experience for your users. When your macro is exported to a static format such as PDF or Word, you can use the renderModes property to define a mapping between a certain type of output device and a static macro implementation. This will allow you to create a static view of your macro’s data where an interactive model is not appropriate.

There might be some options to achieve this but, based on the current technical implementation, they would require further investigation and development.

For the team to consider such effort, it would help if you could provide an answer to the following:

  • What is not possible to achieve today with the current implementation?
  • How would this feature help you/your team/the app development as well as the customers using them?

Thank you,
Caterina

1 Like

I’ve now created the following feature request for this feature:
https://jira.atlassian.com/browse/CONFCLOUD-72677

Please watch it to be notified of any update and feel free to add a comment if you want to share your use case.

Thank you,
Caterina