DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • How to Convert Between PDF and TIFF in Java
  • Java UDFs and Stored Procedures for Data Engineers: A Hands-On Guide
  • How to Split PDF Files into Separate Documents Using Java
  • Using Java Class Extension Library for Data-Oriented Programming - Part 2

Trending

  • Revolutionizing Financial Monitoring: Building a Team Dashboard With OpenObserve
  • Building Enterprise-Ready Landing Zones: Beyond the Initial Setup
  • How Large Tech Companies Architect Resilient Systems for Millions of Users
  • AI’s Role in Everyday Development
  1. DZone
  2. Data Engineering
  3. Data
  4. Creating PDF's With Custom Data Using Mule 4+ Java

Creating PDF's With Custom Data Using Mule 4+ Java

While there's no way to generate a PDF in Mule Application, Mule allow you to write a Java code and make use of it in your API.

By 
Sravan Lingam user avatar
Sravan Lingam
DZone Core CORE ·
Jul. 23, 20 · Tutorial
Likes (6)
Comment
Save
Tweet
Share
13.6K Views

Join the DZone community and get the full member experience.

Join For Free

Hello, readers!

We know that we can create PDFs and Images using Base64 Data, we can generate PDFs only if we have a valid Base64 content which includes, PDF format like Borders, Fonts, Style along with Data. Even if a small character is missed in Base64 content, you won't be able to generate a PDF.

In short, you should have a valid base64 to generate PDFs using Mule 4.

There's no option to generate a PDF by providing Custom Data as input in Mule Application.

But still, Mule helps you to allow you to write a Java code and make use of it in your API.

Requirements

  • We need an external Jar: iTextPdf
  • Custom Java Code
  • Java connector to invoke Java class

Step One

Add below dependency into your pom before writing your Java code. So that you can import the classes while writing Java code

Java
 




x


 
1
<dependency>
2
    <groupId>com.itextpdf</groupId>
3
    <artifactId>itextpdf</artifactId>
4
    <version>5.5.13.1</version>
5
</dependency>



Step Two

Create a Package under src/main/java and create a Class. Please note that you have to be familiar with Java code. Make sure your code is good enough to have the necessary Structure of PDF like borders, paragraphs, Font Style, etc.

If you are not familiar, no worries, am providing you the Git repo link where I have written a sample code that helps you to dig further and modify your code accordingly.

Step Three

Now use Java connector (Invoke Static ) and provide your class name and method name with appropriate arguments to be passed fo the method you have written.

Note: Methods and arguments are displayed automatically if your Java class is under src/main/java

invoke status

Step Four

You can pass inputs from POST body like name, role and transform your message accordingly and pass them as arguments to your Java method so that you can create a Custome PDF file.

CreatePDF

If you can see the PDF which is generated, I have used Name and role in it.

creating PDF

That's pretty simple, isn’t it?

Why don’t you try out!

Find the code here: https://github.com/sravanl/generatePdfs

Note: Please change your FILE path that is mentioned in Java code to your local path

As said, you can modify according to your need!

Java (programming language) PDF Data (computing)

Opinions expressed by DZone contributors are their own.

Related

  • How to Convert Between PDF and TIFF in Java
  • Java UDFs and Stored Procedures for Data Engineers: A Hands-On Guide
  • How to Split PDF Files into Separate Documents Using Java
  • Using Java Class Extension Library for Data-Oriented Programming - Part 2

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!