Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#610 extend feature boxes for icewind/mythos CS #610

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

Jessomadic
Copy link

@Jessomadic Jessomadic commented Apr 2, 2024

Description:

Added a dedicated Feature Sheet to both the Icewind Dale Sheet and the Mythos Sheet. To not waste the space on the Mythos sheet which is about half a page for features I added a new field "Features-and-traits-3" for the full pages on Mythos and kept the normal "features-and-traits-2" but limited it to 500 chars to avoid it shrinking to unreadable sizes.

Related issue (if applicable): fixes #608

Checklist:

  • The code change is tested and works locally.
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation if necessary
  • There is no commented out code in this PR.
  • My changes generate no new warnings (check the console)

Jessomadic and others added 3 commits March 30, 2024 15:56
[pull] develop from Orcpub:develop
Added dedicated Feature Sheet to both Icewind Dale Sheet and the Mythos Sheet. In order to not waste the space on the Mythos sheet that is about half a page for features I added a new field "Features-and-traits-3" for the full pages on Mythos and kept the normal "features-and-traits-2" but limited it to 500 char to avoid it shrinking to unreadable sizes.
Increased char limit of Feature2 to 1000
(seq traits))
header (features-and-traits-header built-char)
]
{:features-and-traits-3 (str header "\n\n"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't rename :features-and-traits-2 to :features-and-traits-3.
It is the form field name in the PDF that needs to match.

image

Testing the other PDF's they come across blank.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. I found a fallback that I can make whats called a "PDF Portfolio" that will allow multiple of the same form field name while not linking them so I can set Char limits

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is strange that they are coming across blank though

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jessomadic
This work flow takes the form data from the "download-form" in the browser and loops through all the elements in it.

image

If you look in the data, there is no :features-and-traits-3. But there is :features-and-traits-2.

It's looping through all the fields being passed down from the as built character.

Ideally, we need a chunk of code that looks at the size of what features-and-traits are going to be and adds another page if needed.

Example, where 900 is the character length that looks good in the PDF Text field. something like:

do while ( features-and-traits >=900 )
add page
take first 900 characters from features-and-traits and insert it into the page.
remove the first 900 characters from features-and-traits and set features-and-traits to the new value.
)

The routes is responsible for filling the PDF text fields, and it is called here.

(pdf/write-fields! doc fields (not chrome?) font-sizes)

Implementation of it lives here:

(defn write-fields! [doc fields flatten font-sizes]
(let [catalog (.getDocumentCatalog doc)
form (.getAcroForm catalog)
res (or (.getDefaultResources form) (PDResources.))]
(.setNeedAppearances form true)
(.setDefaultResources form res)
(doseq [[k v] fields]
(try
(let [field (.getField form (name k))]
(when field
(if (and flatten (font-sizes k) (instance? PDTextField field))
(.setDefaultAppearance field (str "/Helv " " " (font-sizes k) " Tf 0 0 0 rg"))
;; this prints out weird boxes
#_(.setDefaultAppearance field (str COSName/DA "/" (.getName font-name) " " (font-sizes k 8) " Tf 0 0 0 rg")))
(.setValue
field
(cond
(instance? PDCheckBox field) (if v "Yes" "Off")
(instance? PDTextField field) (str v)
:else nil))))
(catch Exception e (prn "failed writing field: " k v (strace/print-stack-trace e)))))
(when flatten
(.setNeedAppearances form false)
(.flatten form))))

Which is just looping through all the fields/elements that are in the edn.

The (doseq [[k v] fields] is basically the do while above for all the fields/elements being passed in, eg :religion :dex-save :hp-current etc.
https://clojuredocs.org/clojure.core/doseq

I don't know. It's a toss up to break up that function or just live with it.

Copy link
Author

@Jessomadic Jessomadic Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets just live with it. I'll make a workaround. It was more if it was an easy 10 min change it would be nice to have but I can get it all done in Adobe. Thanks for breaking it down though that explains alot

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look into the logic zotz pointed out once I get a free weekend again.

Reverted Routes and PDF Spec changes to remove Feature 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

#608 Extend Feature Boxes for IceWind/Mythos CS/Optional Variant
3 participants