Comments (3)
Thanks. Unfortunately, I don't have the bandwidth to work on this right now but hopefully that SO post will be useful when I (or someone else) do.
from dungeon-sheets.
I've just made a PR to use @matsavage latex package, take a look when you can.
from dungeon-sheets.
LOL I had the same issue, this is what I came up with:
#!/usr/bin/env python3
from PyPDF4.generic import NameObject
from PyPDF4.generic import TextStringObject
from PyPDF4.pdf import PdfFileReader
from PyPDF4.pdf import PdfFileWriter
import random
import sys
reader = PdfFileReader(sys.argv[1])
writer = PdfFileWriter()
# Try to "clone" the original one (note the library has cloneDocumentFromReader)
# but the render pdf is blank
writer.appendPagesFromReader(reader)
writer._info = reader.trailer["/Info"]
reader_trailer = reader.trailer["/Root"]
writer._root_object.update(
{
key: reader_trailer[key]
for key in reader_trailer
if key in ("/AcroForm", "/Lang", "/MarkInfo")
}
)
page = writer.getPage(0)
params = {"Foo": "Bar"}
# Inspired by updatePageFormFieldValues but also handle checkboxes
for annot in page["/Annots"]:
writer_annot = annot.getObject()
field = writer_annot["/T"]
if writer_annot["/FT"] == "/Btn":
value = params.get(field, random.getrandbits(1))
if value:
writer_annot.update(
{
NameObject("/AS"): NameObject("/On"),
NameObject("/V"): NameObject("/On"),
}
)
elif writer_annot["/FT"] == "/Tx":
value = params.get(field, field)
writer_annot.update(
{
NameObject("/V"): TextStringObject(value),
}
)
with open(sys.argv[2], "wb") as f:
writer.write(f)
https://stackoverflow.com/a/66388344/646005
from dungeon-sheets.
Related Issues (20)
- Magic Itens don't add Saving Throws bonuses HOT 3
- Clean up portrait handling
- Clean up the licensing
- More flexible interface for magic item bonuses
- Restore automated tests HOT 1
- Putting a homebrew weapon in magic_items is not resolvable by the content resolver HOT 2
- Weapons used by monsters are not listed in their weapons list HOT 2
- NameError in `content_registry.ContentRegistry` HOT 3
- GM Notes failing with `fancy_decorations=True` HOT 3
- can't add class HOT 6
- Enhancement proposal: companions and summonable creatures HOT 5
- allow multiclassing of magic weapons HOT 1
- Specifying Bloodhunter's Patron HOT 4
- Lucky HOT 2
- Rogue: Arcane Trickster Spell Slot count is always 0
- Portrait slightly off-center in MSavage latex template HOT 15
- Revivify doesn't show special_material
- latex output HOT 31
- Compatibility with foundry VTT export HOT 1
- Homebrew: Cannot specify a weapon subclass HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dungeon-sheets.