Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ deploy/homebrew/*

# As created by some LSP-protocol tooling, e.g. nvim-lsp
.lsp

resources/IceWind Page 1.pdf

resources/IceWind Page 2.pdf

resources/!FeatureSheet.pdf

resources/!Mythos Page 2.pdf
Binary file modified resources/fillable-char-sheetstyle-3-0-spells.pdf
Binary file not shown.
Binary file modified resources/fillable-char-sheetstyle-3-1-spells.pdf
Binary file not shown.
Binary file modified resources/fillable-char-sheetstyle-3-2-spells.pdf
Binary file not shown.
Binary file modified resources/fillable-char-sheetstyle-3-3-spells.pdf
Binary file not shown.
Binary file modified resources/fillable-char-sheetstyle-3-4-spells.pdf
Binary file not shown.
Binary file modified resources/fillable-char-sheetstyle-3-5-spells.pdf
Binary file not shown.
Binary file modified resources/fillable-char-sheetstyle-3-6-spells.pdf
Binary file not shown.
Binary file modified resources/fillable-char-sheetstyle-4-0-spells.pdf
Binary file not shown.
Binary file modified resources/fillable-char-sheetstyle-4-1-spells.pdf
Binary file not shown.
Binary file modified resources/fillable-char-sheetstyle-4-2-spells.pdf
Binary file not shown.
Binary file modified resources/fillable-char-sheetstyle-4-3-spells.pdf
Binary file not shown.
Binary file modified resources/fillable-char-sheetstyle-4-4-spells.pdf
Binary file not shown.
Binary file modified resources/fillable-char-sheetstyle-4-5-spells.pdf
Binary file not shown.
Binary file modified resources/fillable-char-sheetstyle-4-6-spells.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions src/clj/orcpub/routes.clj
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@
:flaws 8
:features-and-traits 8
:features-and-traits-2 8
:features-and-traits-3 8
:attacks-and-spellcasting 8
:backstory 8
:other-profs 8
Expand Down
27 changes: 27 additions & 0 deletions src/cljc/orcpub/pdf_spec.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,33 @@
(actions-string "-----------Other Traits------------" traits)]))
traits-str))}))

(defn traits-fields [built-char]
(let [traits-by-type (group-by :type (es/entity-val built-char :traits))
bonus-actions (sort-by :name (concat (es/entity-val built-char :bonus-actions)
(traits-by-type :b-action)))
actions (sort-by :name (concat (es/entity-val built-char :actions)
(traits-by-type :action)))
reactions (sort-by :name (concat (es/entity-val built-char :reactions)
(traits-by-type :reaction)))
traits (sort-by :name (traits-by-type nil))
traits-str (traits-string traits)
actions? (or (seq bonus-actions)
(seq actions)
(seq reactions)
(seq traits))
header (features-and-traits-header built-char)
]
{:features-and-traits-3 (str header "\n\n"

Copy link
Copy Markdown

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
Copy Markdown
Member 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
Copy Markdown
Member 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

@datdamnzotz datdamnzotz Apr 3, 2024

Copy link
Copy Markdown

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.

@Jessomadic Jessomadic Apr 3, 2024

Copy link
Copy Markdown
Member Author

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

Copy link
Copy Markdown

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.

(if actions?
(s/join
"\n\n"
(remove nil?
[(actions-string "----------Bonus Actions----------" bonus-actions)
(actions-string "---------------Actions--------------" actions)
(actions-string "-------------Reactions-------------" reactions)
(actions-string "-----------Other Traits------------" traits)]))
traits-str))}))

(defn attack-string [attack]
(str "- " (trait-string (:name attack) (disp5e/attack-description attack))))

Expand Down