Reading a PDF file in a MuleSoft application and to print out its content.
It is worth noting that a PDF file that is directly read in a MuleSoft application will not show, nor render, its content into a flat text format just as the text read from
the PDF file itself. Instead, given that PDF files are either binary files or ASCII text files, its read content is set to a byte array stream.
To directly read a PDF file found in either any of your local folders, or in your MuleSoft application project, all needed is the MuleSoft File Connector.
In it, you should configured at least both the file path, where your file is at, and also the output mimetype, which should be defined as application/java:
<file:read doc:name="Read PDF" doc:id="5763a2ba-1175-4b31-a799-43b1eb87af75" path="/Users/sebastian.gonzalez/AnypointStudio/studio-workspace-780/00300342-read-pdf-file-poc/src/test/resources/dummy.pdf" outputMimeType="application/java"/>
At logging the outbound stream from the said read operation, the PDF content file renders to both byte array and bits of text:
To check on the PDF content displayed in a MuleSoft application, please find below both a log application file where the same is found, as well as a Mule 4 application for a better understanding on how it is done.
PDF file content read in MuleSoft application
Read PDF MuleSoft application POC - Mule 4.3.0 app
This example is provided as a reference for your own usage and is not to be considered a MuleSoft product. This example should be considered as a custom solution. The custom solution is not a Supported MuleSoft product.
001116842

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.