From d85dcd1081c5d40b946d193f849a52f140e334aa Mon Sep 17 00:00:00 2001 From: Pavel Braginskiy Date: Mon, 4 Nov 2024 16:30:55 -0800 Subject: [PATCH] Add pdf extension to files selected without one --- megameklab/src/megameklab/util/UnitPrintManager.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/megameklab/src/megameklab/util/UnitPrintManager.java b/megameklab/src/megameklab/util/UnitPrintManager.java index 0cfc729dd..2f99755ee 100644 --- a/megameklab/src/megameklab/util/UnitPrintManager.java +++ b/megameklab/src/megameklab/util/UnitPrintManager.java @@ -40,6 +40,7 @@ import megameklab.printing.*; import megameklab.ui.dialog.MegaMekLabUnitSelectorDialog; import megameklab.ui.dialog.PrintQueueDialog; +import org.apache.commons.io.FilenameUtils; import static megamek.common.options.OptionsConstants.RPG_MANEI_DOMINI; import static megamek.common.options.OptionsConstants.RPG_PILOT_ADVANTAGES; @@ -119,7 +120,14 @@ public static File getExportFile(Frame parent, String suggestedFileName) { // I want a file, y'know! return null; } - return f.getSelectedFile(); + + var file = f.getSelectedFile(); + + if (FilenameUtils.getExtension(file.getName()).isEmpty()) { + file = new File(file.getAbsolutePath() + ".pdf"); + } + + return file; } public static List createSheets(List entities, boolean singlePrint,