Giter VIP home page Giter VIP logo

pdf-sheet's Introduction

PDF Sheet

Version Latest Release Download Count Supported Foundry Versions Discord Server Patreon

A system agnostic tool to export your Foundry character sheet to a PDF!

Installation

In the setup screen, use the URL https://github.com/arcanistzed/pdf-sheet/releases/latest/download/module.json to install the module.

Usage

Just click on the button in the header of a character sheet and then it will open the configuration window. Once you upload a PDF, you'll see a list of each of the PDF's fields alongside an input. You can either fill in the fields manually with what is on your character sheet or you can use a "mapping" (described later) to fill them in automatically with the values from your character sheet.

Get a PDF

If you need a copy of the PDF for D&D 5th edition, there is a button to take you to the official one.

You can theoretically use this module with the PDF for any system, but some fields used on other PDFs may not be supported. File a bug if you encounter a PDF that doesn't work.

Mapping

In order to automatically fill out the sheet with values, you will need a JS Object mapping of the PDF fields to the values on your character sheet. This is known as a "mapping" and can be edited in the module settings.

If a mapping has been created for your system, you can select it with the dropdown to load it in.

TIP: Install Ace Library if you want to use a proper editor to work on creating your mapping.

The mapping is formatted like this:

[
    {
        "pdf": "CharacterName",
        "foundry": @name
    },
    {
        "pdf": "Check Box 11",
        "foundry": @data.abilities.str.proficient
    },
    {
        "pdf": "Race",
        "foundry": @data.details.race
    },
    {
        pdf: "Speed",
        foundry: Object.entries(actor.data.data.attributes.movement).filter(val => val[1]).map(val => val[0] === "hover" ? Object.entries(actor.data.data.attributes.movement)[6][0] : "" + val[0] !== "units" && val[0] !== "hover" ? val.join(": ") + Object.entries(actor.data.data.attributes.movement)[5][1] : "").filter(String).join(", ")
    },
    {
        pdf: "Backstory",
        foundry: @data.details.biography.value?.replaceAll(/<[^>]*>/g, "").trim()
    },
    { "pdf": "PlayerName", foundry: Object.entries(@permission).filter(entry => entry[1] === 3).map(entry => entry[0]).map(id => !game.users.get(id)?.isGM ? game.users.get(id)?.name : null).filter(x => x).join(", ") }
]

This will take care of filling out the character name, strength save proficiency, race, speed, and backstory on a D&D 5e character sheet.

As you can see, the @ is used to access properties of the Actor data, rather than a fixed value. You may use any valid JavaScript functions or formulas in the mapping, but it should return a String or coerce into one.

While creating a mapping, it's very helpful to work in the browser console (F12):

using-the-console-pdf-sheet.mp4

Please share any mappings you create with me and I will include them in the module for the benefit of the community. See the mappings here.

License

Copyright © 2021 arcanist

This package is under an MIT license and the Foundry Virtual Tabletop Limited License Agreement for module development.

This uses some code from pdfform.js which is under the Apache 2.0 License and heavily modified by me. You may obtain a copy of the license on the Apache website.

Bugs

You can submit bugs via Github Issues or on my Discord server.

Contact me

Come hang out on my my Discord server or click here to send me an email.

TODO

  • Use PDFlib library instead of pdfform.js (since it's not maintained and can't support images)
  • Change the mapping to JSON, evaluating each value instead of the whole file
  • Store the JSON as an Object rather than serialized text
  • Add a field to the JSON mapping for a link to the PDF which can be put in the App instead of only the D&D link

pdf-sheet's People

Contributors

arcanistzed avatar chasarooniz avatar dick-k avatar fashtas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.