0

I'm using PdfNet (C#) for Winforms.

I want to be able to underline text, so i created an underline annotation like this:

Annot underlineAnnot = Annot.Create(m_document, Annot.Type.e_Underline, rect)
underlineAnnot.SetFlag(Annot.Flag.e_read_only);

according to this page, it's not possible to move a readonly annotation: https://www.pdftron.com/pdfnet/docs/PDFNet/html/T_pdftron_PDF_Annot_Flag.htm

But when i move it with the toolmode e_annot_edit, it actually does move...

how can I 'lock' an annotation so that it doesn't react to mouse events?

DennisVA
  • 2,068
  • 1
  • 25
  • 35
  • Have you downloaded this package from Nuget? If so, can you post the URL of the project so I can try as well and try to get an answer for you? – Selim Balci Aug 05 '16 at 15:00
  • Thx for trying to help me but it's kinda impossible to share the project since it's not mine. – DennisVA Aug 08 '16 at 12:06

1 Answers1

1

Currently the viewer does not enforce read only.

You can do this easily yourself.

Create a delegate method with the following signature.

return false to allow editing, otherwise return true
public bool edit_annot_proc(Annot annot, object obj)
{
    return annot.GetFlag(Annot.Flag.e_read_only);
}

Then register the callback when you create the PDFViewCtrl object

mypdfviewctrl.SetAnnotationEditPermissionHandler(edit_annot_proc, null);
Ryan
  • 2,473
  • 1
  • 11
  • 14
  • Thanks alot but I'm currently using the 5.1 version which doesn't contain this method. Is there any other way to do this without upgrading? – DennisVA Aug 09 '16 at 08:32
  • In that case, you would subclass the PDFViewCtrl class, and override the OnMouse[Up|Down] events and skip the call to base.OnMouseUp(e) if you don't want to allow the default behaviour. See MyPDFView.cs OnMouseUp in the PDFViewTest sample. – Ryan Aug 09 '16 at 16:51
  • I don't really want to skip it, some annotations should be ignored in my project. If an annotation overlaps another annotation that should be ignored, only the overlapping annotation should be selected with the toolmode e_annot_edit. It's kinda hard to achieve this without updating i guess but updating is not an option for my project – DennisVA Aug 10 '16 at 07:33
  • I fixed it by changing the order of the annotations on the page. – DennisVA Aug 10 '16 at 08:22