/** * Export a character sheet for the character to the output file using the pre-registered * template. If the output file is null then a default file will be used based on the character * file name and the type of export template in use. If the output file exists it will be * overwritten. * * <p>This method will load the required data for the character, load the character and then * export the character sheet. * * @param characterFilename The path to the character PCG file. * @param outputFile The path to the output file to be created. May be null. * @return true if the export was successful, false if it failed in some way. */ boolean exportCharacter(String characterFilename, String outputFile) { File file = new File(characterFilename); if (!PCGFile.isPCGenCharacterFile(file)) { Logging.errorPrint("Invalid character file specified: " + file.getAbsolutePath()); return false; } String outFilename = outputFile; if (outFilename == null) { outFilename = generateOutputFilename(characterFilename); } Logging.log( Logging.INFO, "Started export of " + file.getAbsolutePath() + " using " + exportTemplateFilename + " to " + outFilename); // Load data SourceSelectionFacade sourcesForCharacter = CharacterManager.getRequiredSourcesForCharacter(file, uiDelegate); Logging.log( Logging.INFO, "Loading sources " + sourcesForCharacter.getCampaigns() + " using game mode " + sourcesForCharacter.getGameMode()); SourceFileLoader loader = new SourceFileLoader(sourcesForCharacter, uiDelegate); loader.execute(); // Load character CharacterFacade character = CharacterManager.openCharacter(file, uiDelegate, loader.getDataSetFacade()); if (character == null) { return false; } // Export character File templateFile = new File(exportTemplateFilename); File outFile = new File(outFilename); if (isPdf) { return exportCharacterToPDF(character, outFile, templateFile); } else { return exportCharacterToNonPDF(character, outFile, templateFile); } }
/** * Export a party sheet for the party to the output file using the pre-registered template. If the * output file is null then a default file will be used based on the party file name and the type * of export template in use. If the output file exists it will be overwritten. * * <p>This method will load the required data for the party, load the characters in the party and * then export the party sheet. * * @param partyFilename The path to the party PCP file. * @param outputFile The path to the output file to be created. May be null. * @return true if the export was successful, false if it failed in some way. */ boolean exportParty(String partyFilename, String outputFile) { File file = new File(partyFilename); if (!PCGFile.isPCGenPartyFile(file)) { Logging.errorPrint("Invalid party file specified: " + file.getAbsolutePath()); return false; } String outFilename = outputFile; if (outFilename == null) { outFilename = generateOutputFilename(partyFilename); } Logging.log( Logging.INFO, "Started export of party " + file.getAbsolutePath() + " using " + exportTemplateFilename + " to " + outFilename); // Load data SourceSelectionFacade sourcesForCharacter = CharacterManager.getRequiredSourcesForParty(file, uiDelegate); SourceFileLoader loader = new SourceFileLoader(sourcesForCharacter, uiDelegate); loader.execute(); // Load party PartyFacade party = CharacterManager.openParty(file, uiDelegate, loader.getDataSetFacade()); // Export party File templateFile = new File(exportTemplateFilename); File outFile = new File(outFilename); if (isPdf) { return exportPartyToPDF(party, outFile, templateFile); } else { return exportPartyToNonPDF(party, outFile, templateFile); } }