Hexal PDF Generator

Generates PDFs of pages of Hexal cards for print.

Created from templates made available by Stagehand under a BSD-style license.


A simple usage example:

import 'package:hexal_generator/generator.dart';
import 'package:image/image.dart';
import 'dart:typed_data';

main() async {
  // Load fonts used in cards. Optionally add bold and semibold variants.
  final ByteData fontData = await readBytes("assets/courier_regular.ttf");

  // Load icons used for element symbols.
  final Map<String, Image> elements = {
    'fire': await readBytes("assets/icon_fire.png").then((data) => decodeImage(data)),
    // Images for other elements

  // Load images used as backing frames for cards based on element.
  final Map<String, Image> frames = {
    'fire': await readBytes("assets/frame_fire.png").then((data) => decodeImage(data)),
    // Images for other frames

  // Create generator instance and add cards.
  final Generator generator = Generator(assets);

  Image cardImage = await readBytes("assets/frame_fire.png").then((data) => decodeImage(data))

    name: "Test Card",
    id: "[0.000]",
    type: "Token Creature",
    stats: "0 / 0",
    text: "<Keyword>s and [Fire]s",
    element: 'neutral',
    cost: {
      'neutral': 1,
    image: cardImage,

  List<int> output = generator.saveDocument();

  // Convert output from generator into PDF blob.
  final Int8List int8array = Int8List.fromList(intList);
  final Blob blob = Blob([int8array], 'application/pdf');

  // Create URL referencing blob that could be displayed to a user.
  String url = Url.createObjectUrlFromBlob(blob);


Generate PDFs of pages of Hexal cards for print.