When metadata
is set into a PDF a dummy setFont ...
is required as well.
The reason for this is that the meta strings are fed through the regular internal CleanText
which requires a current font. If no font is set, like in the example of
package require pdf4tcl
pdf4tcl::new exporter -paper {3478 2550} ;# placeholder
#exporter setFont 10 [lindex [::pdf4tcl::getFonts] 0]
exporter metadata -creationdate 0
exporter write -file x.pdf
exporter destroy
the write
command will fail with Can't read "FontsAttrs(,specialencoding)": no such element in array
. Uncommenting the setFont
command makes the error disappear.
This kind of thing is likely not seen so far because most will use the package to generate PDFs with lots of text, so setting a font is natural for that.
However when assembling a PDF whose pages contain only images, and no text at all then it is not natural to set a font, while still normal to set some meta data.
My recommendation would be to run the meta data strings through a variant of CleanText
not depending on a font at all.