Initial commit. Load list of cards via config (packs or single cards).
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using ArkhamPnP.Data;
|
||||
using iText.Kernel.Pdf;
|
||||
using iText.Layout;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.Xml;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ArkhamPnP
|
||||
{
|
||||
internal class PDFComposer
|
||||
{
|
||||
const float PAGE_WIDTH = 210; // mm
|
||||
const float PAGE_HEIGHT = 297; // mm
|
||||
const float CARD_WIDTH = 63; // mm
|
||||
const float CARD_HEIGHT = 89; // mm
|
||||
const float FRONT_PADDING = 3; // mm
|
||||
const float MARGIN_SIDE = 5; // mm
|
||||
const float MARGIN_TOP_BOTTOM = 5; // mm
|
||||
|
||||
public void PrintCards(List<Card> cards, string destinationPath)
|
||||
{
|
||||
var pdfDoc = new PdfDocument(new PdfWriter(destinationPath));
|
||||
var doc = new Document(pdfDoc, new iText.Kernel.Geom.PageSize(PAGE_WIDTH, PAGE_HEIGHT));
|
||||
// compute card amount on page
|
||||
int grid_width = 0;
|
||||
while (CARD_WIDTH * (grid_width + 1) + FRONT_PADDING * (grid_width + 1 - 1) +
|
||||
2 * MARGIN_SIDE <= PAGE_WIDTH) grid_width++;
|
||||
int grid_height = 0;
|
||||
while (CARD_HEIGHT * (grid_height + 1) + FRONT_PADDING * (grid_height + 1 - 1) +
|
||||
2 * MARGIN_TOP_BOTTOM <= PAGE_HEIGHT) grid_height++;
|
||||
Console.WriteLine("Will produce grid of cards " + grid_height + "x" + grid_width);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user