Convert Base64 to PDF: Step-by-Step Guide | MuleSoft Guide

This tutorial will show you how to convert a Base64 String to a PDF. Base64 content is needed to create a PDF. To show you how to do it, I converted a PDF file to Base64. I used the URL below for the conversion. I then used the same base64 content to write the PDF to a local directory using the file write operation.

PDF to Base64 Encode – Online Tool

In Anypoint Studio, create a project and set up the listener to start the flow.

To convert the base64 material to PDF, write the dataweave expression.

%dw 2.0import * from dw::core::Binariesoutput multipart/form-data---{ parts: {  base64Content: {   headers: {    "Content-Type": "application/pdf"   },   content: fromBase64(payload)  }, }} 
Flow diagram showing Anypoint Studio configuration for converting Base64 to PDF

Change the mime type to application/pdf

Flow diagram illustrating the process of transforming base64 into a PDF file within Anypoint Studio.

Use the file write procedure to write the file to one of the local directories.

A screenshot of a flow in Anypoint Studio that shows the process of writing a PDF file from a Base64 string, including steps such as transforming messages and setting variables.

Install and launch the file; a PDF is generated in the local directory.

A screenshot of a PDF document titled 'base64-to-pdf.pdf' displayed in a PDF viewer, showing content related to Base64 encoding and decoding, along with a selection box for encoding PDF files.

Git Repositories : sandy551/base64-string-to-pdf (github.com)

We appreciate you taking the time to read the aforementioned post. I hope it was helpful to you. Please leave a remark below if you have any questions. I’d be pleased to look into your suggestions if you’re really interested in learning more about a particular subject.

You can follow us on LinkedIn to receive information on any new postings or updates on our website. I’m excited to interact with you there.

Post a Comment (0)
Previous Post Next Post