XFDF data to token

If you have searched the other User Creations subforums and an answer to your question has not been found, please post here!

Moderators: dorpond, trevor, Azhrei, Gamerdude

Post Reply
User avatar
patnodewf
Cave Troll
Posts: 97
Joined: Sun Jan 15, 2012 3:44 am

XFDF data to token

Post by patnodewf »

I'm curious at the moment...

...my form-fillable PDF character sheet allows the user to save their form data as an XFDF file. It's basically descriptions of page form elements and their values, such as the names and values for text fields, stored in an XML format. I currently use it as an option for transferring character data from one sheet to another after I squash a bug or two and need to release an update for the form. I'll attach an example, saved from my current character sheet.
Ninja_data.zip
XFDF data file pulled from my PFRPG form-fillable PDF character sheet.
(8.58 KiB) Downloaded 76 times
Is it possible to examine the XML data, and extract relevant information for use in maptool?
(I'm looking at lmarkus' framework potentially, as it's a Pathfinder sheet)

Some of the fields utilize arrays to keep track of various bonuses, which honestly are a bit open to user error for the translation into token properties.
Example

Code: Select all

<field name="weap_dmgbonus_1_breakdown"
><value
>Strength Modifier-:-0-:-Enhancement-:-1-:--:-0-:--:-0-:--:-0-:--:-0</value
></field
>
"Enhancement" is just a plain text field where the user could enter anything, even something as ambiguous as "boots" for example. The array element separator is the "-:-" also...
Those fields that utilize arrays though, are just here as place-holders for users to keep track of sources of bonuses. There are other fields in the form which add them all up and display the total from the arrays.
Example

Code: Select all

<field name="weap_dmgbonus_1"
><value
>1</value
></field
>
The field "weap_dmgbonus_1" is displaying the sum of all the array elements in the prior example.
Last edited by patnodewf on Thu Aug 09, 2012 10:31 am, edited 1 time in total.
My form-fillable PDF Character Sheet for Pathfinder can be found here.

User avatar
patnodewf
Cave Troll
Posts: 97
Joined: Sun Jan 15, 2012 3:44 am

Re: XFDF data to token

Post by patnodewf »

Another approach to the "sheet to token" translation that I had, was to see if I can get Acrobat to export a formatted statblock as just plain text. That way a user could just use the statblock2token macro. If I go with this route, I'd be inclined to build an exported HTML file to retain text formatting though.
My form-fillable PDF Character Sheet for Pathfinder can be found here.

badsequel
Giant
Posts: 115
Joined: Thu May 31, 2012 3:13 am

Re: XFDF data to token

Post by badsequel »

If I understand you correctly you are looking for a xml data -> token import routine.

I think the closest thing is Sozin's TokenLab application. It uses xml files exported from Herolab to create tokens so won't work out of the box, but you might be able to tweak it for your purposes.

If you control the xml schema used inside that pdf file you could perhaps replace it with some bastard version of Herolab's schema and force it through Sozin's app.

Dunno - just thinking out loud.

http://forums.rptools.net/viewtopic.php?f=53&t=20409
My shared rpg stuff:
(exe)TokenNameChanger3: https://www.dropbox.com/s/cqsof54v3dl2k ... 3.zip?dl=0
Tiddly Spell Wiki: https://www.dropbox.com/s/53pya4k68mnvc ... ddly01.htm

Stuff to check out:
Mote Kickstarter(back it): https://www.kickstarter.com/projects/74 ... abletop-ev

User avatar
patnodewf
Cave Troll
Posts: 97
Joined: Sun Jan 15, 2012 3:44 am

Re: XFDF data to token

Post by patnodewf »

badsequel wrote:If I understand you correctly you are looking for a xml data -> token import routine.

I think the closest thing is Sozin's TokenLab application. It uses xml files exported from Herolab to create tokens so won't work out of the box, but you might be able to tweak it for your purposes.

If you control the xml schema used inside that pdf file you could perhaps replace it with some bastard version of Herolab's schema and force it through Sozin's app.

Dunno - just thinking out loud.

http://forums.rptools.net/viewtopic.php?f=53&t=20409
I'm pretty much thinking out loud here too, but yea: xml -> token properties, ideally. The statblock2token macro is an alternative, I am thinking.

I don't suppose there's a way to execute a macro from a token and have it reference a XFDF file stored in drop box via public link, then update properties on the token with XML data pulled from the XFDF file, is there? Or is that wishful thinking?

What would be keen is, for players who use my PDF for their character sheet, just export the XFDF data to dropbox. Once it's synced with dropbox's site, they can just click the macro to update the token data.
My form-fillable PDF Character Sheet for Pathfinder can be found here.

User avatar
CoveredInFish
Demigod
Posts: 3104
Joined: Mon Jun 29, 2009 10:37 am
Location: Germany
Contact:

Re: XFDF data to token

Post by CoveredInFish »

patnodewf wrote:[I don't suppose there's a way to execute a macro from a token and have it reference a XFDF file stored in drop box via public link, then update properties on the token with XML data pulled from the XFDF file, is there? Or is that wishful thinking?
No there is no way to do that. Either you actually build token files or have to import data by drag and drop. The devs have decided against file access for security reasons (a widely discussed topic, you should find stuff about it in the forums)

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: XFDF data to token

Post by JamzTheMan »

I've actually did some work with XFDF for another project. If you have access to a web server and PHP this COULD be a lot easier for you.

Adobe can actually POST it's data to a URL. So for my personal forums, I serve up various custom PDF Character sheets that have a button that posts the data back to the server.

The data simply goes to a PHP file that "creates" an XFDF format using the HTML POST name:value pairs. It then sends this XFDF data to a database for storage. So all my players can create/access their PDF characters from the web and only they or the GM can edit/update them. I have a separate form for adding XP.

Anyway, I digress. It would be simple enough to change the PHP to create a Stat Block or JSON or anything else really instead of the XFDF (or in addition to) and simply display it on the screen to copy/paste into Map Tools macro. There's no way to automate it further (ie still will require a manual copy/paste).

Although, the most difficult piece will be looking up ALL the PDF variable names and build a map in the PHP. Or you would just dump the POST data to a JSON and then map it in Map Tools. If it's a simple WoD sheet, it wouldn't be bad, but something like my Pathfinder sheet has a couple hundred variables.

As a side note, I also have a semi working Android App that reads that same XFDF data from the web and recreates the sheet on my Tablet (for WoD Hunter) and which case I translate the XFDF variables inside the app where 95% of the variables are "dots" so dot 1-5 == skill 1, dots 6-10 == skill 2, etc so mapping was easy.

If you want to look at the code, it's all available on a public SMF forum I created for testing at http://public.nerps.net

EDIT: Reread that you are using Pathfinder. Personally I use Hero Lab which has a "output to statblock" option which I then just cut/paste into my Statblock macro. Was much easier than probably doing any other route. I've modified the current Statblock macro 1.9 for PF to also work with Hero Lab as it outputs weapons slightly different.
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: XFDF data to token

Post by Azhrei »

Very interesting, Jamz.

Back in the day (like early last year) we talked about having a "character storage" service here at RPTools. It never went anywhere because of the technical considerations, but something as simple as name/value pairs stored in a database would be an extremely simple storage technique that would allow for almost anything to be stored. We would likely have to ensure that the column widths were super wide when the table is created and perhaps have the PHP validate that before sending it to the dbms (some databases can be difficult in regards to error handling for such things).

I'm going to try to look at your code over the next few weeks and I may hit you up with a question or two. Don't know when I'll have time for this, but it's the kind of thing I can look at via my tablet while I'm waiting on an appointment... Thanks for the note!

User avatar
patnodewf
Cave Troll
Posts: 97
Joined: Sun Jan 15, 2012 3:44 am

Re: XFDF data to token

Post by patnodewf »

Wow, I wasn't intending on fueling the ol' "maptool thinktank" with this query, but I'm excited to see the wheels start moving!

As for my personal endeavor here, I think I'm going to just build a dialog window in my PDF that allows the user to copy statblock data for pasting elsewhere. And, as you said, just pilfer the field values to build the output. Sadly I don't have access to any sort of database storage on a webserver like you're suggesting though.
My form-fillable PDF Character Sheet for Pathfinder can be found here.

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: XFDF data to token

Post by Azhrei »

patnodewf wrote:Sadly I don't have access to any sort of database storage on a webserver like you're suggesting though.
Hm, kinda strange. Nowadays even the throw-away web server accounts include at least one database that is accessible from PHP, Perl, or whatever.

Of course, you could use a directory where the field that would have been the key becomes the filename, and the data for the record is simply stored into the file. You can't do SQL queries against the entire database very easily but in terms of just storing and retrieving data it would work (for queries you'd need to open/read/close each file yourself or use something like grep and parse the output; neither are attractive solutions). You would need to be sure to use the appropriate function calls to store the data so that it couldn't be used as an attack vector and include the proper .htaccess file to prevent access to the files directly via the web server...

Edit: So I checked the site and it appears that there are threads discussing the original code dated May 2012 and then some "security patches" dated July 2012. Is there a single ZIP somewhere that has the current code (with all patches) packaged up already? It may even have been in those original threads and I just missed it. :? Thanks!

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: XFDF data to token

Post by JamzTheMan »

Azhrei, just go with the first post in the v2 code for now (http://public.nerps.net/index.php?topic=14.0). The security updates was by another user who wanted to obscure the URL a bit.

Personally, I relied more on SMF security and it was mainly for personal use but I'm sure some things could be improved for a public space. That and it would need changed anyway for phpBB.

Also, note, I'm not storing the actual name:value pairs, I'm reading them and using that to construct an xml file that is in XFDF format to be read by adobe. I then store that xml into a blob. I do scrape a view values to store in table columns for other purposes like Name, and also "insert" valuse into the XFDF when serving it up like "Server URL" which tells adobe where to post the info back to so it's not hard coded into the PDF.

All the DB create/alters are in that post as well with the PHP code. You'll want to look at any of the PDF's as well for what you need add to them. I kept it simple and only takes me about 5 mins to convert a given PDF for use. Most of it can be thrown away if you don't want/need the XP system. At it's core, you only need a couple PHP files.

Feel free to poach what ever you can use and ask away. I'd be more than happy to help if you want to add it to RPTools.net, maybe it'll inspire getting Map Tools "cloud aware" and we'll see token -> pdf -> token or something cool :)
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: XFDF data to token

Post by JamzTheMan »

patnodewf wrote:Wow, I wasn't intending on fueling the ol' "maptool thinktank" with this query, but I'm excited to see the wheels start moving!

As for my personal endeavor here, I think I'm going to just build a dialog window in my PDF that allows the user to copy statblock data for pasting elsewhere. And, as you said, just pilfer the field values to build the output. Sadly I don't have access to any sort of database storage on a webserver like you're suggesting though.
Technically you don't NEED a DB, the PHP code can do the work and just display the results back on screen. And if open the PDF locally adobe creates a pop up screen to show the HTML response. But you would still need a way to run the PHP code.

But it depends on your comfort level, if it's easier to code in adobe then go for it. I find it painful myself :)

Oh and it doesn't even have to be PHP, and you could post to localhost and use javascript, JSP or anything really.

Or save hours and hours of work with 30$ and hero lab :) Some guy did a kick donkey HTML sheet for pathfinder which is way better than the hero lab pdf output and our group uses it exclusively now.
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

User avatar
patnodewf
Cave Troll
Posts: 97
Joined: Sun Jan 15, 2012 3:44 am

Re: XFDF data to token

Post by patnodewf »

JamzTheMan wrote:But it depends on your comfort level, if it's easier to code in adobe then go for it. I find it painful myself
The most painful part would be whipping up a data-flow diagram in Visio before starting. I've got some pseudo-code jotted down so far, so that's a start.
JamzTheMan wrote:Oh and it doesn't even have to be PHP, and you could post to localhost and use javascript, JSP or anything really.
Yea, the only languages I'm comfortable with at the moment are javascript, C# & HTML/CSS... still a bit sketchy on even the macro language (MTscript?), but it's coming along as needs arise.
JamzTheMan wrote:Or save hours and hours of work with 30$ and hero lab :) Some guy did a kick donkey HTML sheet for pathfinder which is way better than the hero lab pdf output and our group uses it exclusively now.
My PDF (link is in signature if you haven't checked it out yet) is sort of intended to be a free product for Pathfinder players that takes care of a lot of the calculations for the player. Hero Lab trumps my sheet due to actually providing game content, though. I'm only providing calculations, and enforcing rules with those calculations, among fields. Not sure if I care to don the lawyer-hat and figure out what bits of actual game content I'm allowed to use from the community use and pathfinder compatible product licenses yet though.

I've got an option in my sheet to save all of the form field data as an *.xfdf file though, for when I need to update javascript to squash any potential bugs or add features to it. Was wondering how easy it would be to pilfer that data for maptool.
My form-fillable PDF Character Sheet for Pathfinder can be found here.

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: XFDF data to token

Post by JamzTheMan »

patnodewf wrote:My PDF (link is in signature if you haven't checked it out yet) is sort of intended to be a free product for Pathfinder players that takes care of a lot of the calculations for the player. Hero Lab trumps my sheet due to actually providing game content, though. I'm only providing calculations, and enforcing rules with those calculations, among fields. Not sure if I care to don the lawyer-hat and figure out what bits of actual game content I'm allowed to use from the community use and pathfinder compatible product licenses yet though.

I've got an option in my sheet to save all of the form field data as an *.xfdf file though, for when I need to update javascript to squash any potential bugs or add features to it. Was wondering how easy it would be to pilfer that data for maptool.
That's a mighty fancy sheet there! :)

I suppose it also depends on how you want to use that data in Map Tools? Are you using an existing framework or your own? You "could" just copy the xfdf data into a macro to parse but that's a lot of mt script to write. You could use java app with gson to convert the xml to json to make it a little easier but still, a lot of script to write.

I'd create a sheet at the back of the pdf that displays a typical statblock that conforms with a Pathfinder and use the existing PFStatBlockToToken macro. Plus users could also use it to paste in an email, forum, or other uses. Would be pretty handy. Bonus points if there's an option to add BBCode.

If you have questions on the statblock macro or need changes to it, let me know and I can help.
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

User avatar
patnodewf
Cave Troll
Posts: 97
Joined: Sun Jan 15, 2012 3:44 am

Re: XFDF data to token

Post by patnodewf »

Well, the option to save character data locally as a *.xfdf file is unfortunately limited to Acrobat users. I did add the function for users to mail themselves a copy of it, if they're using Reader & have a MAPI configured local email client. I sent an inquiry to Adobe about pricing for LiveCycle Reader Extensions so I can add the capability for ALL users to save data locally. The idea for providing it was to allow an easier transition from one version of the sheet to another, should bugs be found/squashed.

So for now, it's not available for everyone - sadly :cry:

I think the statblock option would be probably better all around, though. Not every user of the sheet is going to be a user of maptool, so the "general purpose" nature of the statblock is highly appealing. You think I should dedicate an entire page of the PDF to it though? I was thinking a dialog window would be sufficient...
My form-fillable PDF Character Sheet for Pathfinder can be found here.

User avatar
JamzTheMan
Great Wyrm
Posts: 1872
Joined: Mon May 10, 2010 12:59 pm
Location: Chicagoland
Contact:

Re: XFDF data to token

Post by JamzTheMan »

patnodewf wrote:Well, the option to save character data locally as a *.xfdf file is unfortunately limited to Acrobat users. I did add the function for users to mail themselves a copy of it, if they're using Reader & have a MAPI configured local email client. I sent an inquiry to Adobe about pricing for LiveCycle Reader Extensions so I can add the capability for ALL users to save data locally. The idea for providing it was to allow an easier transition from one version of the sheet to another, should bugs be found/squashed.

So for now, it's not available for everyone - sadly :cry:

I think the statblock option would be probably better all around, though. Not every user of the sheet is going to be a user of maptool, so the "general purpose" nature of the statblock is highly appealing. You think I should dedicate an entire page of the PDF to it though? I was thinking a dialog window would be sufficient...
A dialog window would be good enough but if the there is enough info to display a page may not be bad either. Try both and see what the users like? :)

And ya, regarding the saving and acrobat only, was one of the reasons I did my whole project allowing my players to save there XFDF data to the server as it works with Reader ;-) Also for the same reason, so I can change the sheet and they wouldn't have to refill the sheet again.
-Jamz
____________________
Custom MapTool 1.4.x.x Fork: maptool.nerps.net
Custom TokenTool 2.0 Fork: tokentool.nerps.net
More information here: MapTool Nerps! Fork

Post Reply

Return to “Requests for HELLLLP!”