I think something like this should work…
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
inputDoc.save(outStream);
ByteArrayInputStream inStream = new ByteArrayInputStream( outStream.toByteArray());
Core.storeFileDocumentContent(getContext(), this.inputFile.getMendixObject(), inStream);
You can use the ByteArrayOutputStream to save your modified inputDoc. You then need to convert this into a ByteArrayInputStream that you can pass to Core.storeFileDocumentContent.
You’ll want to add this after your call to inputDoc.removePage and before you return true;
Double check I have used the correct variable names as I can’t see them very clearly in the screenshot, but I think they are right.
Hope this helps and good luck!