PDF compression with Javascript

Hi all,

I’m looking for help and I found this community with a lot of expertise, so I hope to be in the right place!
I’m new here and I’m try to figure out if I can find what I need.
I’m receiving in Mirth environment HL7 messages with a PDF base64 encoded. This PDFs can be too big and I need to compress them.
I’m able to extract the path of the PDF using JavaScript. What I need is a way to perform a strong compression, using Javascript, on the PDF, starting from the path where the file is located.

Is it something possible with PDFTron or I’m completely out of topic?

Thank you in advance!


This PDFs can be too big

Why exactly is the PDF “too big”?
What exactly is the issue with the PDF file size?

What I need is a way to perform a strong compression

You would want to use our Optimizer class.

using JavaScript

You mean client side in the browser? Or server side using NodeJS?

Hi Ryan,

thank you for your answer.

PDF is too big because it contains images. I send a PDF to a service that can accept PDF with a dimension that cannot be over 300 Kb.
This compression needs to be performed server side and needs to be transparent to the user. So, when I receive the message, I need to apply “something” (JS method?), starting to the exact path of the PDF, to reduce its dimensions.
Let me know if I can explain something better, I only have basics competences in informatics so maybe my messages are not too clear.