I have a macro with body that renders the result of a calculation. The Word Export of the page will always render the original macro body, while the PDF Export will always render the content generated by the macro. So the Word Export is broken, the PDF Export is as intended.
It makes no difference if I add the code as shown in the example for emitReadyEvent, add a attribute, or do not emit the event at all.
Are there any Forge examples that show, how the use of this feature is intended? Would this feature fix the issue with the Word Export?
Non Atlassian here, and I agree the documentation is very light. We tested view.emitReadyEvent() internally, and found that it helps the PDF export finish much faster. I think it is a flag for the background PDF renderer to know the macro is finished loading, rather than waiting for a some timeout.
Exporting a PDF page in confluence with 3 custom UI forge macros ( no export or adfExport functions defined ).
I do not see any performance improvements when I run my code exporting PDF. It is about 17 seconds with our without the emitReadyEvent callled. And the Word Export is never correct.
Now I wonder, if may code is correctly using the emitReadyEvent feature. I am very new to Forge and React. So I may be missing some basic concepts.
Hi, we are not using React for this custom UI, so this may be of limited use. The code snippet is very simple and called as the last item after the page rendering is complete:
import * as Bridge from '@forge/bridge';
async function render() {
try {
...
}
catch {
}
finally {
// notify renderer for PDF export
await Bridge.view.emitReadyEvent();
}
}
It seems to me that you create the response and just before it is returned emit the event in the finally block. This helps a lot since I can discard the “attribute stuff”. I’ll try this and check, it it makes any difference for my “Word Export” problem …
Thank you for sharing!
If there is information from the Atlassian Team, I’d be happy to have further information on this topic.
Just a short follow up in case someone is as new to Forge as I am:
It took me quite some time to learn that the emitReadEvent fails when in the tunnel. Otherwise the solution presented by Chris works like a charm!
The “Word Export” still does not work. The issue here is probably somewhere else, since it works for “PDF Export”.
The emitReadyEvent also does not prevent the body from being rendered (that is why I looked into this). It is a feature to improve performance (again see Chris’ post for figures) for the export (as advertised in the docs).