PDA

View Full Version : 5e Character to PDF Converter



Nightstride
April 24th, 2019, 01:16
I created a relatively simple tool to convert FG 5e character sheets to Pdfs. My apologies if this is not the right place to post this.

It can be found here: bitbucket (https://bitbucket.org/tomanzm/fg5exmltopdfconverter/src/master/)

The downloadable packages can be found here: Downloads (https://bitbucket.org/tomanzm/fg5exmltopdfconverter/downloads/)

The source is freely available, so feel free to modify it how you will, just keep it free for everyone.

I've put several details on how to use it in the readme (I can include them here if there's a preference for that).

I would include the zipped up file(s), but it turns out java files have a nasty habit of becoming large.

This is written in Java, so it should be compatible with most computers

As of 7/24, the converter has been updated to version 1.03. Change log:

Added checkbox to swap ability scores and mods
Hired some adventurers to squash some rogue bugs
Fighters now don't make the application cry as much
All supplied character pdfs are now handled
Fired adventurers due to likely chance of more bugs being introduced
Snuck into the dragon's horde and squashed some bugs in the pdfs (You will need to use the pdfs supplied in the repo)
Added some error logging to keep out some of those tricksey goblins


As of 8/10, the converter has been updated to version 1.04. Change log:

Hired adventurers to squash more bugs
Made a deal with Cthulhu to associate the correct power groups with the correct class (It assumes that the spell group includes the name of the class, or that the class that can cast spells, but doesn't have its name as a part of a group, is the default spell group)
update the error logging to catch the kobolds sneaking around the back


As of 8/20, the converter has been updated to version 1.05. Adventurers were hired, more bugs squashed

As of 4/5/20, the converter has been updated to version 1.06. A spell a calm emotions has been cast to keep it from crying over reading your epic adventures...It still doesn't know what to do with them, but in time it may.

damned
April 24th, 2019, 01:57
Well done zmtoman

Nightstride
July 25th, 2019, 02:09
This has been updated:


Added checkbox to swap ability scores and mods
Hired some adventurers to squash some rogue bugs
Fighters now don't make the application cry as much
All supplied character pdfs are now handled
Fired adventurers due to likely chance of more bugs being introduced
Snuck into the dragon's horde and squashed some bugs in the pdfs (You will need to use the pdfs supplied in the repo)
Added some error logging to keep out some of those tricksey goblins

Booker Grimm
July 25th, 2019, 19:11
How do I download this?

Trenloe
July 25th, 2019, 20:08
How do I download this?
The downloads link is in post #1. What part of the process is failing for you?

Booker Grimm
July 25th, 2019, 20:36
Hmm. The part where my brain is needed. It is constantly letting me down and I'm considering getting it replaced with a very small pea. Trust me, it'll be an improvement.

nebbiolo
July 26th, 2019, 14:19
Looked interesting. Too bad it requires Java since I refuse to install Java runtimes on my computers.

Mortani
August 10th, 2019, 21:16
Hey, thanks for sharing! Just had a chance to test it out (Been playing with Open Java versions due to the new licensing and just got Oracle back on one of my machines). I'm running Windows 10, with Oracle Java 1.8.0_221. The pdfs are in a sub folder from the jar file titled srcPdfs.

I got the following error when clicking convert on a few mid level spell casters.



Thread 15: starting conversion
Thread 15: Error: java.lang.NullPointerException
java.lang.NullPointerException
at converter.FgXML.buildStructure(FgXML.java:210)
at converter.FgXML.<init>(FgXML.java:95)
at converter.Converter.run(Converter.java:66)
at java.lang.Thread.run(Unknown Source)


The following for a 10th level Barbarian

Thread 16: Error: java.lang.NullPointerException
java.lang.NullPointerException
at converter.FgXML.buildStructure(FgXML.java:420)
at converter.FgXML.<init>(FgXML.java:95)
at converter.Converter.run(Converter.java:66)
at java.lang.Thread.run(Unknown Source)


And this for a 5th level Monk



Thread 17: starting conversion
Thread 17: Error: java.lang.NullPointerException
java.lang.NullPointerException
at converter.FgXML.structuredText(FgXML.java:557)
at converter.FgXML.buildStructure(FgXML.java:415)
at converter.FgXML.<init>(FgXML.java:95)
at converter.Converter.run(Converter.java:66)
at java.lang.Thread.run(Unknown Source)

Nightstride
August 10th, 2019, 21:34
Hi Mortani,

Thanks for the logs, I'll look into it right now. I'll try something that I think will fix it, but would it be possible for you to temporarily remove any identifying information, zip up your xmls and include them? That would help expedite the efficiency of the fix. I think this site allows you to attach some files if you go advanced in your reply. If you would prefer to message me directly with a copy-paste or something that would work as well.

Mortani
August 10th, 2019, 22:35
I meant to offer including them. Fairly certain the only thing to be concerned with are some of the silly names my Players like to use :) Attached list I tried zipped below.

Nightstride
August 10th, 2019, 22:42
Thanks. This is... insightful. Turns out fantasy grounds does interesting things with the xml structure that I didn't realize. I'll try and get this updated and pushed by this time tomorrow.

Nightstride
August 11th, 2019, 01:18
This has been updated!

Hired adventurers to squash more bugs
Made a deal with Cthulhu to associate the correct power groups with the correct class (It assumes that the spell group includes the name of the class, or that the class that can cast spells, but doesn't have its name as a part of a group, is the default spell group)
update the error logging to catch the kobolds sneaking around the back


Moratini, I tested with your xmls, and they all appear to be working...All but one of them showed me a bug somewhere in my code, so thanks :) . It should be safe to remove your attached file now if you want.

RoleforFun
August 18th, 2019, 18:17
This is great! Thanks! Here's another error:28520

It does the same with each of the character sheet versions. I have 4 players, 3 worked just fine. Hope this helps.

Laerun
August 19th, 2019, 01:37
Is there any objection or reason not to use the AL tools online?
https://www.alonlinetools.net/FGCharacterSheet.aspx
Other than not printing offline? Nice to have options, good work!

Laerun

ps. One caveat, do not use weird characters like hyphens or apostrophes in your 'Name' field or it will break the conversion.

Laerun
August 19th, 2019, 01:40
Good work!

Nightstride
August 21st, 2019, 02:06
Catalyst20XX, it appears that you have a weapon that doesn't have a damage type specified.

Thanks for screenshot. I updated the application so an empty type will no longer break it...as well as a few other empty fields that had potential to cause issue.

Laerun

I've definitely tried that one, but I'm not really big on register walls...if that makes sense. Just personal preference. I also have a preference for standalone applications since they have better support for things like multi-threading.

Hmm...that issue with the special characters tells me that, depending on what is being used to do the conversion, the characters may need to be encoded before they're read, then decoded when placed into the pdf. Or if a regular expressions are being used, look for the matching opening and closing xml tags, and blindly grab the content between them. Or do what I did and use a library that parses html or xml.

Skate927
May 17th, 2020, 20:32
Hi, I tried the adventurers league converter, to convert FGU characters to PDF and it had the ability scores where the modifiers where supposed to be. Does anyone know where I went wrong?

LordEntrails
May 17th, 2020, 20:43
Hi, I tried the adventurers league converter, to convert FGU characters to PDF and it had the ability scores where the modifiers where supposed to be. Does anyone know where I went wrong?
You probably did nothing wrong. Have to see what someone else says, but do be aware that some character sheets intentionally switch the score and the modifier (Since some people prefer the modifier score to be larger than the attribute value.)

Skate927
May 17th, 2020, 20:45
do you know if there is a way to correct it?

LordEntrails
May 17th, 2020, 20:52
I haven't used this one, but its not wrong, just not what you want/expect :) You can change the code of the program (use the Bit Bucket link) to swap the fields. Have you tried the online printer listed in post #14? I think it does it the way you want.

pollux
May 17th, 2020, 22:09
@zmtoman are you aware of the character sheet printer: https://www.fantasygrounds.com/forums/showthread.php?27390-Universal-Character-Sheet-Printer-for-FG

It uses XSL stylesheets to enable export from any ruleset. The available stylesheets aren't great, and the tool itself is a little rough around the edges... but the XSL approach is quite powerful, flexible, and extensible and is implementable in pretty much any language (including java). You might want to have a look and consider XSL for your conversion engine.

Nightstride
May 18th, 2020, 01:44
@Skate927 If you're using the tool I created, there's a checkbox just below where you reference your character xml. It'll swap them. If you want the adventurers league pdf, you have to use the 'Tyranny of Dragons' option in the dropdown. If you're using the online tool that was referenced elsewhere, I don't actually know what to do to change that...it kinda' bothered me as well.

@pollux Thanks for the info, I'll look into it when I get a chance. I wonder how well it would pair with referencing pdfs since the only pdf I actually programmatically generate is the info dump at the end, the others are just copy/fill.

pollux
May 18th, 2020, 01:59
@pollux Thanks for the info, I'll look into it when I get a chance. I wonder how well it would pair with referencing pdfs since the only pdf I actually programmatically generate is the info dump at the end, the others are just copy/fill.

It's a wildly different approach, I'm not really suggesting it's compatible with the codebase you have... just that you might be interested in prior art. Here's a snippet that is oriented toward html output and creates a list of languages conditional on there being languages to list. You can see HTML tags intermingled with XSL tags that perform some tag-selection and logic:



<xsl:if test="count(languagelist/*) &gt; 0">
<ul name="languages">
<label for="languages">Languages</label>
<xsl:for-each select="languagelist/*">
<li><xsl:value-of select="name" /></li>
</xsl:for-each>
</ul>
</xsl:if>


I'm not familiar as familiar with PDF output, but I get the vague sense that XSL provides a markup language for PDF structure that's not so different from HTML. Or one could use one of many strategies to get from html to PDF. Anyplace you have java code that selects XML elements, you'd instead have element selectors in the XSL stylesheet. This strategy allows the code to handle any ruleset by having a stylesheet per ruleset and feeding the character sheet plus the stylesheet to the XSL library to do the heavy-lifting on formatting... whereas you'd potentially need a whole new class heirarchy to handle a different ruleset.

Nightstride
May 18th, 2020, 02:53
Oh, I see, XSL with the intention of generating new files from scratch. That's vastly different than what I'm doing.

From what research I've done since my last reply, it appears it would simply rely on linking up an xsl file to an xml file, then outputting the implementation as an html (from there to pdf...possibly) file. I'm pretty sure there's simple web uis that can do that. For example this might be of use to you if you already have an xsl generated: https://www.freeformatter.com/xsl-transformer.html although their support for styles may vary

A standalone application could do this, however, I think accessible alternatives may already exist. In concert with the link above, I'd find a converter to convert the html output to a pdf.

ianw
September 19th, 2021, 14:55
Is there any objection or reason not to use the AL tools online?
https://www.alonlinetools.net/FGCharacterSheet.aspx
Other than not printing offline? Nice to have options, good work!

Laerun

ps. One caveat, do not use weird characters like hyphens or apostrophes in your 'Name' field or it will break the conversion.

All I get from this is file uploaded, I don't seem to get a PDF?

kevdog45
September 21st, 2021, 00:14
This prints out a nice character sheet. I can't complain about that but I will mention this...it looks like the program is producing a sheet with double the proficiency bonus. Easy to overcome but I wanted to add my two cents. And yes I know I am replying to a thread that is over two years old.

ianw
September 21st, 2021, 10:09
This prints out a nice character sheet. I can't complain about that but I will mention this...it looks like the program is producing a sheet with double the proficiency bonus. Easy to overcome but I wanted to add my two cents. And yes I know I am replying to a thread that is over two years old.

Hi Kev, thanks for replying. So after uploading the XML and leaving it for an hour nothing is happening? I'm sure I'm being daft, but after it's uploaded, then what happens for you to get your print out?

MacDork
September 30th, 2021, 13:04
Hi Kev, thanks for replying. So after uploading the XML and leaving it for an hour nothing is happening? I'm sure I'm being daft, but after it's uploaded, then what happens for you to get your print out?

I think it's broken; it used to then create a PDF you could save.

attriel
September 14th, 2022, 18:16
Mine won't even launch the window anymore. Is this project abandoned, then?

Nightstride
September 14th, 2022, 22:40
Specifically this project as in the java one? I wouldn't say abandoned, but I'm just super busy with another project. All I can suggest is verifying your java version, and launching it via the included bat file. Since it appears executable jars can't be executed directly.

The online project at https://www.alonlinetools.net/FGCharacterSheet.aspx is a completely different thing (not my work).

I'm aware of the proficiency issue, however I have no idea why it's doubling. I'll fix it at some point.

foggyone
September 19th, 2022, 06:48
Like Attriel, the program did literally nothing for me. It opened, a second later it closed. That's looking at a process log. Nothing at all showed up on screen. Could something have broken it? Running Windows 10.

Nightstride
September 19th, 2022, 06:53
Hmm...I tested my local version before my precious reply and it was opening as expected. I haven't updated my Java for a while though, so that might be why.

Has your Java updated since last you used the application?