Support
unread,Apr 23, 2008, 9:15:41 PM4/23/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to PDFTron PDFNet SDK
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
annotation.
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();
writer.Begin(pdfdoc);
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,
offset_y);
writer.WritePlacedElement(element);
writer.WriteElement(element);
Obj appearance_stream = writer.End();
// Set the annotation appearance...
myannot.SetAppearance(appearance_stream)