Loading

How to read a PDF file

Data pubblicazione: Mar 2, 2024
Operazione

GOAL

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. 

Fasi

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:

  • Author
  • Creator
  • Producer
  • CreationDate
  • EOF
  • Beginning and end of the PDF file stream

 

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.

 

 

Files:

PDF file content read in MuleSoft application

Read PDF MuleSoft application POC - Mule 4.3.0 app


Disclaimer:

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.

Numero articolo Knowledge

001116842

 
Caricamento
Salesforce Help | Article