<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Austin Aylworth on Medium]]></title>
        <description><![CDATA[Stories by Austin Aylworth on Medium]]></description>
        <link>https://medium.com/@austinaylworth?source=rss-55a2306c8d65------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*WmN_USNElqBp8CnI</url>
            <title>Stories by Austin Aylworth on Medium</title>
            <link>https://medium.com/@austinaylworth?source=rss-55a2306c8d65------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 22:56:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@austinaylworth/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[PDF Separator — Building on Mendix’s Base]]></title>
            <link>https://medium.com/@austinaylworth/pdf-separator-building-on-mendixs-base-602e52bbce5d?source=rss-55a2306c8d65------2</link>
            <guid isPermaLink="false">https://medium.com/p/602e52bbce5d</guid>
            <category><![CDATA[mendix]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[pdf]]></category>
            <category><![CDATA[split-pdf]]></category>
            <category><![CDATA[modules]]></category>
            <dc:creator><![CDATA[Austin Aylworth]]></dc:creator>
            <pubDate>Mon, 16 Oct 2023 18:40:52 GMT</pubDate>
            <atom:updated>2023-10-16T18:40:52.023Z</atom:updated>
            <content:encoded><![CDATA[<h3>PDF Separator — Building on Mendix’s Base</h3><p>If you have a special requirement for your project that isn’t already provided in the base set of offerings by Mendix’s Studio Pro, don’t worry! You can add on to Mendix’s base to create awesome solutions for your unique needs. A company I was working with found themselves in a similar situation — they needed functionality that wasn’t already included in the large offering of Mendix’s base. With this need I developed that requirement, and this is my journey!</p><h3>Requirement</h3><p>It was a simple need, the company wanted to be able to upload a PDF and then have Mendix separate the PDF’s pages into their own individual PDF documents for further manipulation. With that need I started searching for solutions.</p><h3>Potential Solutions</h3><p>Mendix is flexible. I’m going to keep saying this because it is one of my favorite parts about Mendix. You have a large selection of frameworks for developing your add-ons including:</p><p>- Java</p><p>- JavaScript</p><p>- HTML</p><p>- React</p><p>- Typescript</p><p>- Dojo</p><p>- Whatever magic you can make happen in an API!</p><p>I’d be working with files and manipulating them, so I opted to first look into Java as a potential solution. Java provides a robust and easily accessible library of… libraries… that provide pre-developed functionality. Also, Java is efficient when working with potentially large file documents, so it was a solid candidate for providing this functionality.</p><h3>Solution Search</h3><p>Now that we have an initial framework it was time to look for a library that could get us close to the desired functionality.</p><p>&lt; <em>Commence the epic Google search montage</em> &gt;</p><p>But in all seriousness, many people out there have probably developed what you’re wanting to achieve. Maybe not in its entirety, but most of the time there is an existing solution that will get you close to what you want. In this case I came across an open source library provided by Apache called <a href="https://pdfbox.apache.org/">PDFBox</a>. It was free, had a lot of support from the community and documentation around it, and, most of all, it did what I needed it to do.</p><h3>Implementation</h3><p>Personally, I had never created a solution prepared for public marketplace use. Or in other words, up to this point in my Mendix journey I’ve never written Java code that was meant to be shared outside of a specific organization. Since I planned on writing a solution to be able to assist not just this company, but others who may need it in the future, I wanted to create my Java action in such a way that allowed for distribution and reuse. In my search for direction on how to do this, I found <a href="https://gajduk.notion.site/Best-practice-for-adding-a-java-dependency-to-Mendix-e2ee2b5776c145f99f8e9fc77f2b62b6">this article</a> explaining best practices for developing a Java action in Mendix that has external dependencies. My solution would be reliant on Apache’s PDFBox library, but I didn’t want those using my solution to have to worry about that dependency — I wanted to create a black box that simply separated a PDF file, so they wouldn’t have to worry about the nitty-gritty.</p><p>Andrej(The author of the article above) does an awesome job at explaining each step of the process of creating a module and Java action that require their own JAR files to operate. I simply did the following:</p><p>- Created a new Gradle project</p><p>- Implemented my code that was dependent on the PDFBox library</p><p>- Tested my code accordingly with JUnit</p><p>- Built the fat jar using shadowing and a gradle plugin</p><p>- Implemented my new Java library in a Java action</p><p>If you’d like some additional direction on each of these steps please see Andrej’s <a href="https://gajduk.notion.site/Best-practice-for-adding-a-java-dependency-to-Mendix-e2ee2b5776c145f99f8e9fc77f2b62b6">complete post</a>!</p><h3>Black Box Inception</h3><p>For my implementation all I needed to do was access a function provided by the library. The details of the function were hidden from, and I didn’t particularly care how they did what they did, I just cared about what it returned, and that was a list of files for each page of a single PDF. It was a black box that I was using to create another black box. This is what that looked like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*N7ctGyjUAyJIm43YQUFy6w.png" /><figcaption>This code snippet along with the rest of the source code for my PDF Separator Java Action can be found <a href="https://github.com/aleworth/pdfseparate">here</a></figcaption></figure><p>I wanted to make it as easy as possible to implement in a Mendix environment, so I made sure to limit my parameters and simplify what I returned. Ultimately, I only needed the name of the document, the document itself, and to return the resulting list of new files output from the first black box. And that was the second black box created, a black box that would provide easy inclusion into Mendix while abstracting management of the necessary dependencies.</p><h3>Initial Issues</h3><p>Nothing is perfect, especially the first time around. Though things were working well locally, when deployed I was experiencing an issue that didn’t make much sense — not at first. The implementation of my Java action did a few things. It took an uploaded Mendix FileDocument entity and wrote its contents into a temporary File object that can then be sent to the function shown above using the my custom class. That function would return a list of File objects, but I couldn’t use those raw file documents in Mendix, so I then had to translate those File objects back into FileDocument objects so they could be managed in Mendix. Pretty, straight forward, input, translate, output, translate, but there was an issue! In a deployed environment I was running into the below problem:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*l6ivcpPPsGDpdgUheMDpLg.png" /><figcaption>Java FileNotFound/Permission Denied error. You hate to see it…</figcaption></figure><p>Some of you may look at this and think, “Ah, yes, I know what this is…” I did not. I had an idea, but I needed to do some digging. I took to the Mendix forums, and it seems others experienced similar problems to this, I was in luck! And then I found the answer. I have read/write access to make local storage, so when running this code where I need to create temporary File documents, it works fine locally. However, in the cloud I don’t have access to the user’s local file systems, at least not through my Java action. After some trial and error I found the solution in the form of a Mendix Java method that allowed for access to temp storage in the deployed app’s file system. You can read more on this <a href="https://apidocs.rnd.mendix.com/8/runtime/com/mendix/core/conf/Configuration.html#getTempPath()">here in the official documentation</a>.</p><h3>Conclusion</h3><p>It was a long road coming, but I was able to learn a lot of new things, like how to efficiently include external Java dependencies in a reusable module for Mendix. After building out a demo application and fine-tuning the initial implementation of the module, I submitted it for review by Mendix and was pleasantly surprised to see my module’s approval in the public marketplace. You can check out PDF Separate’s public listing <a href="https://marketplace.mendix.com/link/component/217435">here</a>, as well as the demo application <a href="https://pdfseparate-sandbox.mxapps.io/">here</a>.</p><figure><img alt="Two pages being torn apart, representing the splitting of a single PDF into multiple individual files" src="https://cdn-images-1.medium.com/max/600/1*jmeyYPENIpTvCYCguvE-Tg.png" /><figcaption>PDF Separator!</figcaption></figure><p>Happy coding out there and thanks for the read!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=602e52bbce5d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>