MCPcopy Create free account
hub / github.com/PCGen/pcgen / exportCharacter

Method exportCharacter

code/src/java/pcgen/system/BatchExporter.java:104–145  ·  view source on GitHub ↗

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. This method will

(String characterFilename, String outputFile)

Source from the content-addressed store, hash-verified

102 * @return true if the export was successful, false if it failed in some way.
103 */
104 boolean exportCharacter(String characterFilename, String outputFile)
105 {
106 File file = new File(characterFilename);
107 if (!PCGFile.isPCGenCharacterFile(file))
108 {
109 Logging.errorPrint("Invalid character file specified: " + file.getAbsolutePath());
110 return false;
111 }
112 String outFilename = outputFile;
113 if (outFilename == null)
114 {
115 outFilename = generateOutputFilename(characterFilename);
116 }
117 Logging.log(Logging.INFO,
118 "Started export of " + file.getAbsolutePath() + " using " + exportTemplateFilename + " to " + outFilename);
119
120 // Load data
121 SourceSelectionFacade sourcesForCharacter = CharacterManager.getRequiredSourcesForCharacter(file, uiDelegate);
122 Logging.log(Logging.INFO, "Loading sources " + sourcesForCharacter.getCampaigns() + " using game mode "
123 + sourcesForCharacter.getGameMode());
124 SourceFileLoader loader = new SourceFileLoader(uiDelegate, sourcesForCharacter.getCampaigns(), sourcesForCharacter.getGameMode().get().getName());
125 loader.run();
126
127 // Load character
128 CharacterFacade character = CharacterManager.openCharacter(file, uiDelegate, loader.getDataSetFacade());
129 if (character == null)
130 {
131 return false;
132 }
133
134 // Export character
135 File templateFile = new File(exportTemplateFilename);
136 File outFile = new File(outFilename);
137 if (isPdf)
138 {
139 return exportCharacterToPDF(character, outFile, templateFile);
140 }
141 else
142 {
143 return exportCharacterToNonPDF(character, outFile, templateFile);
144 }
145 }
146
147 /**
148 * Export a party sheet for the party to the output file using the

Callers 3

doInBackgroundMethod · 0.95
exportCharacterToPDFMethod · 0.95
startupWithoutGUIMethod · 0.95

Calls 15

isPCGenCharacterFileMethod · 0.95
errorPrintMethod · 0.95
logMethod · 0.95
getCampaignsMethod · 0.95
getGameModeMethod · 0.95
runMethod · 0.95
openCharacterMethod · 0.95
getDataSetFacadeMethod · 0.95
exportCharacterToPDFMethod · 0.95

Tested by

no test coverage detected