Exporting to PDF with K15t PDF Exporter
Overview
This example requires the install of the Scroll PDF Exporter app.
Once installed, the Comalatech {pdf-export}
macro can then be used as an action in a trigger macro to export a page or blog post in pdf format. The exported pdf is added to the page as an attachment.
Basic Example
{workflow:name=PDF export} {description} Pdf export macro example workflow {description} {state:Review|approved=Published|rejected=Review} {approval:Approve For Export} {state} {state:Published|final=true|submit=Review} {state} {trigger:pageapproved|approval=Approve For Export} {pdf-export} {trigger} {workflow}
In this example, the approved decision will transition the content to the Published state.
When the Approve for Export content review is approved, the content is also exported as a pdf file and added to the content as an attachment
The transition does not wait for the pdf export of the content as a pdf and its addition as an attachment.
The export may take some time - it is queued in Confluence.
- the successful completion of the pdf export will be seen when the pdf is added as an attachment
Using pdf-export
macro events
The pdf-export
macro action generates the workflow event pdf-export-success
. This event occurs when the pdf export is successful.
This workflow event can be used to help confirm the success of the pdf export.
A simple way is to add an on-screen message when the event is triggered.
{trigger:pdf-export-success} {set-message:style=info|duration=PT1M} ||PDF export completed|@datetime@| ||See| @attachmentURL@| {set-message} {trigger}
This would display a confirmation message together with the attachment URL and the date and time the export was completed.
A second workflow event can also be generated by the pdf-export
macro, the pdf-export-error
event.
This event occurs if the pdf export fails.
Again this can be used, for example, to generate a custom notification.
{trigger:pdf-export-error} {set-message} There was an error in the pdf export @errormessage@ {set-message} {trigger}
The value reference @errormessage@
in the set-message
content displays the value for actual error recorded by Confluence.
Note that this same Confluence error message will also be displayed but can be removed by a user.
In this simple example
- the actions of the
pdf-export
macro are not recorded in the page activity report for the content - the on-screen message notifications may not appear on the transition to the Published state as the pdf export is an asynchronous event and may take some time to be completed
Manage the pdf export and add details to the page activity report
The pdf-export
macro events can be used in one or more triggers to
- display a notification that content is being exported
- add details of the pdf export to the page activity report
- transition on the success of the pdf export
Remove the approval transition for the approved decision from the Review state.
{state:Review|rejected=Review} {approval:Approve For Export} {state}
An approved decision for the Approve for Export approval will now NOT action a content review transition.
The pageapproved
event trigger is still used to activate the pdf-export
macro but before the pdf-export
macro, an on-screen message notification is added.
{trigger:pageapproved|approval=Approve For Export} {set-message} This content is currently being exported to pdf {set-message} {pdf-export} {trigger}
The content now remains in the Review state after an approved decision.
A transition is set to occur as an action in a pdf-export-success
event trigger.
{trigger:pdf-export-success} {set-message:style=success|duration=PT2M} PDF export completed! {set-message} {set-state:Published|comment=Approved page exported as pdf - see @attachmentURL@} {trigger}
Completion of the pdf export causes the pdf-export-success
event trigger to transition the content to the Published state using the {set-state}
macro.
The page activity report includes details of the pdf export that were added as the comment
parameter value for the {set-state}
macro.
Create a 'waiting' state for pdf export
Exporting to PDF can take some time, you may find it useful to have a 'waiting' state - a workflow state to wait for the completion of the pdf export.
{state:Review|approved=Export PDF|rejected=Review} {approval:Approve For Export} {state} {state:Export PDF|submit=Published|description=Content is being exported to pdf, please wait ...|hideselection=true} {state}
The approved decision in the Review state now causes the content to transition to the Export PDF state.