-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
base: develop
Are you sure you want to change the base?
#610 extend feature boxes for icewind/mythos CS #610
Conversation
[pull] develop from Orcpub:develop
…r-icewindmythos-csoptional-variant
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
src/cljc/orcpub/pdf_spec.cljc
Outdated
(seq traits)) | ||
header (features-and-traits-header built-char) | ||
] | ||
{:features-and-traits-3 (str header "\n\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
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.
orcpub/src/clj/orcpub/routes.clj
Line 478 in 6b709e7
(pdf/write-fields! doc fields (not chrome?) font-sizes) |
Implementation of it lives here:
Lines 31 to 55 in 6b709e7
(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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
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: