Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How to create PDFs using Java?

Hi there,

I am trying to create PDF exports of pages using the Java API of Confluence. I am using @ComponentImport PdfExporterService

This groovy code example works:

import com.atlassian.confluence.pages.Page
import com.atlassian.confluence.pages.PageManager
import com.atlassian.confluence.user.AuthenticatedUserThreadLocal
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.extra.flyingpdf.analytic.PageExportMetrics;
import com.atlassian.confluence.extra.flyingpdf.PdfExporterService
import com.atlassian.user.User

Page page = ComponentLocator.getComponent(PageManager.class).getAbstractPage(114915234)
User user = AuthenticatedUserThreadLocal.getUser()
return pdfExporterService.createPdfForPage(user, page, "", new PageExportMetrics())

(I am using an own groovy console which allows me to inject a binding to the PdfExporterService)

Doing similar in Java fails with

java.lang.ClassNotFoundException: com.atlassian.confluence.extra.flyingpdf.analytic.PageExportMetrics

I played around with the class loaders a little, but nothing seems to help. How can I make the class loader find that class?


1 answer

Hey @swisscompedia how are you? Did you finally were able to solve this?


We are in the same situation. We tried to use the PdfExporterService and we got the same error because of the PageExportMetrics class not found. 


Seems like they only exported first level classes of the package com.atlassian.confluence.extra.flyingpdf

But this is really weird as you cannot use this service without analytics classes.


The only service we could use is the XmlToPdfConverter. But we still got no successful results because some resources cannot be resolved (the contextPath parameter is best candidate to be wrong).


Did you opened a ticket to Atlassian for this? Maybe we should do it.

Updates: They have created a bug ticket, so there is hope of incoming versions with a fix. Feel free to vote!! :pray:

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events