Am 21.11.2016 um 19:31 schrieb Mikhail Slyusarev:
I've compared it to the file you mentioned. It seems like that is what's
happening. It's not entirely clear to me where to embed the resource
though. I think the way I'm making the appearance stream is kind of a
mistake.

I can't comment without having seen the PDF.

I forgot to mention, the font must also be in the resources of the appearance stream, of course, as seen in

Root/Pages/Kids/[5]/Annots/[14]/AP/N/Yes/Resources/Font/ZaDb

Is there a way to construct the appearance without having it all
be PDF syntax strings?

There's a PDPageContentStream constructor that takes appearance streams as parameter so that it becomes a bit easier. Not sure if this works for checkboxes.

Tilman


On Mon, Nov 21, 2016 at 9:35 AM Tilman Hausherr <[email protected]>
wrote:

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]




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to