use of org.magic.api.sorters.CardsDeckSorter in project MtgDesktopCompanion by nicho92.
the class PDFExport method exportDeck.
@Override
public void exportDeck(MagicDeck deck, File f) throws IOException {
var table = new Table(3).useAllAvailableWidth();
try (var pdfDocDest = new PdfDocument(new PdfWriter(f));
Document doc = new Document(pdfDocDest)) {
pdfDocDest.setDefaultPageSize(PageSize.A4);
PdfDocumentInfo info = pdfDocDest.getDocumentInfo();
info.setTitle(deck.getName());
info.setAuthor(getString("AUTHOR"));
info.setCreator(MTGConstants.MTG_APP_NAME);
info.setKeywords(deck.getTags().stream().collect(Collectors.joining(",")));
info.addCreationDate();
var mainList = deck.getMainAsList();
Collections.sort(mainList, new CardsDeckSorter(deck));
for (MagicCard card : mainList) {
table.addCell(createCell(card));
notify(card);
}
doc.add(table);
} catch (Exception e) {
logger.error("Error in pdf creation " + f, e);
}
}
Aggregations