Is there a simple way to do that, I can't seem to find any decent
example.
-------------
A: We released a new PDFNet SDK update (v.4.8 - http://www.pdftron.com/pdfnet/downloads.html)
that includes some features that will allow you to customize
PDFViewCtrl based on your requirements.
Currently you can override context menus for built-in tools by
overriding OnMouseUp event. For example (in C#):
protected override void OnMouseUp(MouseEventArgs e) {
// One way to override built-in content menu. Replace it with your
own menu?
if (e.Button == MouseButtons.Right) {
MenuItem menuItem = new MenuItem("Print");
menuItem.Click += new EventHandler(OnPrint);
ContextMenu popup = new ContextMenu();
popup.MenuItems.Add(menuItem);
Rect wnd_pos = GetChildWindowPosition();
popup.Show(this, new System.Drawing.Point(e.X+(int)wnd_pos.x1, e.Y+
(int)wnd_pos.y1));
return;
}
base.OnMouseUp(e);
}
Similarly you can override OnKeyUp, OnKeyDown, OnKeyPress and call
the base-class method if you would like to process specific types of
events by the base class.
The extended C# PDFView sample (http://www.pdftron.com/pdfnet/
samplecode.html#PDFView) illustrates various customizations to the
built-in viewer.
----------------
A: To add a watermark you can use ElementWriter and ElementBuilder as
shown in the following snippet:
using (ElementBuilder eb = new ElementBuilder()) {
using (ElementWriter writer = new ElementWriter() {
writer.Begin(page);
Element element = eb.CreateTextBegin(Font.Create(doc,
Font.StandardType1Font.e_times_roman),64);
writer.WriteElement(element);
element = eb.CreateTextRun("Hello World!");
// Position the text run
element.SetTextMatrix(1, 0, 0, 1, 20, 20);
writer.WriteElement(element);
writer.WriteElement(eb.CreateTextEnd());
writer.End(); // Save the changes
}
}
Please note that the procedure is the same as when creating PDF
content from scratch. For a longer code example, illustrating the use
of ElementBuilder and ElementWriter, please take a look at
ElementBuilder sample project.
If you would like to stamp PDF page(s) which are opened in the viewer,
you need to lock the document before modifying pages and Update() the
re-render the page. For example:
_pdfview.GetDoc().Lock();
AddWatarmarks();
_pdfview.GetDoc().Unlock();
_pdfview.Update();
-------------
A: In PDFNet 4.8 and above you can add the following override in your
PDFViewCtrl derived class:
protected override void OnDoubleClick(EventArgs e) {
// MessageBox.Show("Custom OnDoubleClick handler", "Test",
MessageBoxButtons.OK);
}