How to programatically export Jira issue to PDF?

Hello,

For one of our customer, we need to implement a custom feature that will generate a PDF file from an issue, containing all fields set for this issue. The client would like to avoid custom plugin development and would rather work with groovy scripts.

The aim is to upload the generated PDF to a folder on a distant server, along with the issue’s attachments, if available.

Our client is using Jira Server 7.13.1 and Scriptrunner.

Is there a REST endpoint in the API or a java API designed to perform this operation? If not, is there a way to programatically export the issue in another format that can be converted to PDF later using the PDF velocity template of Jira?

Kind regards,

Hi @alexis.ramacciotti !
I suggest use lib itext.

It needed save as text PDF or enough as picture PDF?
In first case I think You could to parse XML. In second just try get picture from web page.

Thanks a lot, this is helpfull!

Alexis, it may be too late, but the cloud version of our popular PDF Exporter app will be available soon. (It took us major efforts to get to this stage, and I can tell you can save a lot of work if you don’t reinvent the wheel.)

See: Better PDF Exporter for Jira (Jira PDF plugin) | Midori

You can use it completely free under the terms of our beta program. Please send me a message if you wanted to get access.

Hi @alexis.ramacciotti i am facing problem to generate pdf file using itext lib. but while adding itext lib in pom.xml plugin works fine after import required package in my class after re running the plugin will get disabled.
dependency are:

	<dependency>
	    <groupId>com.itextpdf</groupId>
	    <artifactId>itextpdf</artifactId>
	    <version>5.0.6</version>
		<scope>provided</scope>
	</dependency> 

.
.
.
and Import-Package
org.bouncycastle.cms.*;resolution:=“optional”

i don’t what mistake did, and in class i importer all itext package to generate padf file.
am ising jira 8.1.0 in development machine.
.
.
example.class

import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Document;
import com.itextpdf.text.Font;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
.
.
.
if possible can you please share sample code.
Thanks in advance.