programmatically set text annotation to edit mode.

Questions, comments and suggestions concerning VintaSoft PDF .NET Plug-in.

Moderator: Alex

Post Reply
IntegraHarlan
Posts: 84
Joined: Fri Jan 24, 2020 3:37 am

programmatically set text annotation to edit mode.

Post by IntegraHarlan »

Hi,
Is there a way to set a text annotation to edit mode programmatically?
I want the text annotation to be in edit mode when it is added to a pdf so it can be edited immediately with out having to double click it.
I am using the Winforms .net plug in.
Thanks
Harlan
Alex
Site Admin
Posts: 2307
Joined: Thu Jul 10, 2008 2:21 pm

Re: programmatically set text annotation to edit mode.

Post by Alex »

Hi Harlan,
Is there a way to set a text annotation to edit mode programmatically?
Yes, this is possible.

Here is code snippet that shows how to enable text editing for newly created text annotation:

Code: Select all

// ...
// subscribe to the AnnotationTool.BuildingFinished event
_annotationTool.BuildingFinished += AnnotationTool_BuildingFinished;
// ...


/// <summary>
/// The annotation building is finished.
/// </summary>
private void AnnotationTool_BuildingFinished(object sender, PdfAnnotationViewEventArgs e)
{
    // get annotation view for newly created annotation
    PdfFreeTextAnnotationView textView = e.AnnotationView as PdfFreeTextAnnotationView;
    // if newly created annotation is PDF free text annotation
    if (textView != null)
    {
        // find text box transformer
        TextObjectTextBoxTransformer textBoxTransformer = CompositeInteractionController.FindInteractionController<TextObjectTextBoxTransformer>(textView.Transformer);
        // if text box transformer is found
        if (textBoxTransformer != null)
        {
            // get annotation tool
            PdfAnnotationTool annotationTool = (PdfAnnotationTool)sender;

            // show text box
            textBoxTransformer.ShowTextBox(annotationTool.ImageViewer, textView.GetBoundingBox().Location);
        }
    }
}
Best regards, Alexander
IntegraHarlan
Posts: 84
Joined: Fri Jan 24, 2020 3:37 am

Re: programmatically set text annotation to edit mode.

Post by IntegraHarlan »

Hi Alexander,
Thank you for the example. this is what I need.
However, I would like for the annotation to have the appearance of being in edit mode when I create it.
Currently I can create an annotation and when I double click to put it in text edit mode and if the
PdfAnnotationTool.InteractionMode set to PdfAnnotationInteractionMode.Edit, it gets the blue highlight around the border to show that it is in edit mode.
However, If the PdfAnnotationTool.InteractionMode set to PdfAnnotationInteractionMode.Edit when the annotation is created, it does not have the blue highlight. If I set the PdfAnnotationTool.InteractionMode set to PdfAnnotationInteractionMode.Edit while the text annotation is in text edit mode, it is taken out of text edit mode.
Is there a way to show the text annotation with blue highlight around the border when it is created and in text edit mode?

Thanks
Harlan
Alex
Site Admin
Posts: 2307
Joined: Thu Jul 10, 2008 2:21 pm

Re: programmatically set text annotation to edit mode.

Post by Alex »

Hi Harlan,

You need to use the PdfAnnotationTool.PerformSelection(PdfAnnotationView) method if you want to perform the selection of annotation:
https://www.vintasoft.com/docs/vsimagin ... View).html

Best regards, Alexander
Post Reply