arcanistzed / pdf-sheet

A system agnostic tool to export your Foundry character sheet to a PDF!
https://arcanist.me
MIT License
14 stars 58 forks source link

[Bug]: PDF cannot be used #88

Closed bushvin closed 1 year ago

bushvin commented 1 year ago

Expected Behavior

Create mapping file for Remastered Pathfinder 2e Charactersheet PDF and export as normal

Current Behavior

PDF is not properly imported, no field relations are shown

Steps to Reproduce

  1. Click Export to PDF for a Pathfinder 2e Player Character Actor
  2. Load Custom PDF
  3. No field relation is shown for Fields in the PDF

If you're willing to jot down the steps, I am prepared to turn it into a human understandable wiki.

Context

Using pdftk, I can see there are fields:

---
FieldType: Text
FieldName: textarea_517vrw
FieldFlags: 4096
FieldJustification: Left

Javascript console:


Foundry VTT | Rendering CharacterSheetPF2e foundry.js:5726:15
Foundry VTT | Retrieved and compiled template systems/pf2e/templates/actors/character/sheet.hbs foundry.js:7606:17
Foundry VTT | Retrieved and compiled template templates/app-window.html foundry.js:7606:17
Foundry VTT | Retrieved and compiled template systems/pf2e/templates/actors/character/manage-tabs.hbs foundry.js:7606:17
Foundry VTT | Rendering Pdfconfig foundry.js:5726:15
Foundry VTT | Retrieved and compiled template modules/pdf-sheet/templates/module.hbs foundry.js:7606:17
Uncaught Error: Stream Length field missing or invalid: {"num":1152,"gen":0}
[Detected 2 packages: pdf-sheet, system:pf2e]
    parse_stream_content https://xxx.yyy.zzz/modules/pdf-sheet/scripts/libraries/pdfform.js/minipdf.js:401
    parse_dict https://xxx.yyy.zzz/modules/pdf-sheet/scripts/libraries/pdfform.js/minipdf.js:393
    parse https://xxx.yyy.zzz/modules/pdf-sheet/scripts/libraries/pdfform.js/minipdf.js:433
    parse_object https://xxx.yyy.zzz/modules/pdf-sheet/scripts/libraries/pdfform.js/minipdf.js:564
    fetch https://xxx.yyy.zzz/modules/pdf-sheet/scripts/libraries/pdfform.js/minipdf.js:222
    fetch https://xxx.yyy.zzz/modules/pdf-sheet/scripts/libraries/pdfform.js/minipdf.js:205
    PDFDocument https://xxx.yyy.zzz/modules/pdf-sheet/scripts/libraries/pdfform.js/minipdf.js:172
    parse https://xxx.yyy.zzz/modules/pdf-sheet/scripts/libraries/pdfform.js/minipdf.js:147
    list_fields https://xxx.yyy.zzz/modules/pdf-sheet/scripts/libraries/pdfform.js/pdfform.js:504
    createForm https://xxx.yyy.zzz/modules/pdf-sheet/scripts/pdfsheet.js:228
    onFileUpload https://xxx.yyy.zzz/modules/pdf-sheet/scripts/pdfsheet.js:393
    onload https://xxx.yyy.zzz/modules/pdf-sheet/scripts/pdfsheet.js:192
    activateListeners https://xxx.yyy.zzz/modules/pdf-sheet/scripts/pdfsheet.js:192
    activateListeners https://xxx.yyy.zzz/modules/pdf-sheet/scripts/pdfsheet.js:189
    _render https://xxx.yyy.zzz/scripts/foundry.js:5766
    _render https://xxx.yyy.zzz/scripts/foundry.js:6456
    render https://xxx.yyy.zzz/scripts/foundry.js:5693
    onclick https://xxx.yyy.zzz/modules/pdf-sheet/scripts/pdfsheet.js:155
    _renderOuter https://xxx.yyy.zzz/scripts/foundry.js:5865
    jQuery 9
    _renderOuter https://xxx.yyy.zzz/scripts/foundry.js:5862
    setTimeout handler*_renderOuter https://xxx.yyy.zzz/scripts/foundry.js:5861
    _renderOuter https://xxx.yyy.zzz/scripts/foundry.js:7042
    _render https://xxx.yyy.zzz/scripts/foundry.js:5753
    _render https://xxx.yyy.zzz/scripts/foundry.js:6456
    _render https://xxx.yyy.zzz/systems/pf2e/pf2e.mjs:1
    maintainFocusInRender https://xxx.yyy.zzz/systems/pf2e/pf2e.mjs:1
    _render https://xxx.yyy.zzz/systems/pf2e/pf2e.mjs:1
    render https://xxx.yyy.zzz/scripts/foundry.js:5693
    render https://xxx.yyy.zzz/scripts/foundry.js:7035
    _onClickEntryName https://xxx.yyy.zzz/scripts/foundry.js:70040
    jQuery 8
    activateListeners https://xxx.yyy.zzz/scripts/foundry.js:69229
minipdf.js:401:10

​```

### Version

0.23.0

### Foundry VTT Version

11.308

### Operating System

Containerized on Linux

### Browser / App

Firefox

### Game System

pf2e (5.4.4)

### Modules Disabled

- [X] I can confirm that disabling all of my other modules doesn't fix this issue.
bushvin commented 1 year ago

It appears the document has some errors which cause your pdf lib to fail. It appears the following seems to work somewhat:

  1. Edit the document & download it
  2. Fix the document
  3. Check the document fields
gioppoluca commented 1 year ago

Do you know who published the PDF? Is something we did not release so we cannot assure that it does not get chenged in time.

bushvin commented 1 year ago

I have no idea who has created it, and I was not looking at you guys to start supporting it. I was merely looking for guidance on fixing it so it could be used with your module.

That being said...

I've spent some time in the deep end of the pool and managed to get it working with a few workarounds. I've been updating the pdf using scribus. It isn't finished yet, but if I provide the fixed pdf, a mappings file, regular updates, would you consider adding it to your repo, or would you prefer me to have a separate repository?

gioppoluca commented 1 year ago

I will include it here

Inviato da Libero Mail

gioppoluca commented 1 year ago

if you will change the name of the mapping and add the pdf here in the pdf folder

bushvin commented 1 year ago

I created a Merge Request: #93

gioppoluca commented 1 year ago

approved