You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Article!
The code provided is a script written in Groovy programming language (Scriptrunner plugin) that converts image attachments of a JIRA issue into PDF format. It makes use of several libraries and APIs, including the Atlassian JIRA API, Apache Commons IO, iText PDF library, and JSoup HTML parser.
The convertImageToPdf()
function is responsible for converting a given image file into a PDF file. It reads the image file using ImageIO
library, creates a new PDF document using iText library, and adds the image to the document using Image
class. The resulting PDF file is then saved to the specified path.
The processAttachments()
function is the main function that processes all the attachments of a given JIRA issue. It retrieves the list of attachments using the JIRA API, iterates over them, and checks if the attachment is an image (JPEG, JPG, or PNG). If it is, it calls the convertImageToPdf()
function to convert the image to PDF format, creates a new PDF attachment using the converted PDF file, and deletes the original image attachment.
Finally, the main()
function is the entry point of the script. It calls the processAttachments()
function for the current issue.
In summary, this script can be useful for teams who want to convert image attachments to PDF format for easier sharing and collaboration. It can be customized and extended to support other file formats and JIRA operations.
Also in code i use this lib https://mvnrepository.com/artifact/com.itextpdf/itextpdf/5.5.13.2
download it to (after downloading you should restart jira)
JIRA_INSTALL/atlassian-jira/WEB-INF/lib
JIRA_INSTALL/WEB-INF/lib