Q: We use forms buttons as place holders for showing graphical PDFs.
This allows our form designers to sort of have a WSIWIG of where the
graphics will appear on a form. The buttons are set to ICON ONLY and
READ ONLY. We currently do this using the FDF Toolkit. How do I set a
button to display a PDF via PDFNet? I am assuming it’s something like
a watermark using streams and writers. I can’t seem to find any sample
code on how this can be achieved.
A: What you want to do is to define a custom appearance for a widget
annotation (i.e. a button).
To create your own icon for stamp annotation you would need to create
a custom appearance using ElementBuilder & ElementWriter. Then you can
use annot.SetAppearance() to associate the new appearance with an
For examples of how to create custom appearances, you may want to
search this KB using the following keyword: "SetAppearance".
The code may look along the following lines:
// Create appearance stream for the annotation --------
ElementWriter writer = new ElementWriter();
ElementBuilder eb = new ElementBuilder();
Element element = builder.CreateForm(input_pdf_page, pdfdoc);
double scale_x = input_pdf_page.GetPageWidth();
double scale_y = input_pdf_page.GetPageHeight();
element.GetGState().SetTransform(scale_x, 0, 0, scale_y, offset_x,
Obj appearance_stream = writer.End();
// Set the annotation appearance...