Could you upload your result file somewhere? I could compare it with a
file that has a checkbox.
What may be missing is the font definition in Root/AcroForm/DR/Font/ZaDb
To see what I mean, open this file in PDFDebugger
http://www.ghostscript.com/doc/examples/annots.pdf
Tilman
Am 21.11.2016 um 15:32 schrieb Mikhail Slyusarev:
How is this done? I'm able to create the field... that part's pretty
straight forward. However, the field doesn't have an appearance, and
constructAppearance isn't implemented for it.
I'm doing this in jRuby, so excuse the syntax, but here's what I have so
far for creating an appearance.
field = PDCheckBox.new(form)
field.partial_name = rf.id
form.fields.add(field)
rect = PDRectangle.new(
rf.x * box.width,
box.height - (rf.y * box.height) - (rf.height * box.height),
rf.width * box.width,
rf.height * box.height
)
appearance_stream = PDAppearanceStream.new(COSStream.new)
cs = appearance_stream.content_stream
out = cs.create_output_stream
out.write("q\n1 1 9.3879 9.4828 re\nW\nn\nBT\n/ZaDb 7.7614 Tf\n2.4109
3.1142 Td\n7.4742 TL\n(x) Tj\nET\nQ\n".to_java_bytes)
out.close
ad = COSDictionary.new
ad.set_item(COSName::YES, appearance_stream)
appearance = PDAppearanceDictionary.new(COSDictionary.new)
appearance.normal_appearance = PDAppearanceEntry.new(ad)
widget = field.widgets.get(0)
widget.rectangle = rect
widget.page = page
widget.printed = true
widget.appearance = appearance
page.annotations.add(widget)
The magic string above is pulled from analyzing an existing checkbox
field on a pdf. How do I get the appearance correct (with a check
symbol)?
Thanks,
Mikhail
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]