Argument out of range exception pasting annotations.

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

Argument out of range exception pasting annotations.

Post by IntegraHarlan »

Hi,
I implemented annotation copy paste and I am seeing a Argument out of range exception on the paste operation.
I have tried the implementation two ways.
First I implemented the copy paste functionality similar to your PdfEditorDemo application.
I then implemented the functionality from the annotaion tool CopyAction and PasteAction properties.

Where the _pdfAnnotationTool is PdfAnnotationTool.
The GetUIAction as well as the TryGetCurrentToolActions methods in the GetUIAction method are copied out of the demo app

Code: Select all

         // In context menu for copy.
	 CopyItemUIAction copyUIAction = GetUIAction<CopyItemUIAction>(GetAnnotationTool(_pdfAnnotationTool).ImageViewer.VisualTool);
         if (copyUIAction != null)
         {
             copyUIAction.Execute();
         }

         // In context menu for paste.
	 PasteItemUIAction pasteUIAction = GetUIAction<PasteItemUIAction>(GetAnnotationTool(_pdfAnnotationTool).ImageViewer.VisualTool);
         if (pasteUIAction != null)
         {
         	pasteUIAction.Execute();
         }

I also implmented the annotation tool UIActions

Code: Select all

        // In context menu for copy.
        CopyItemUIAction copyUIAction = pdfAnnotationTool.CopyAction;
        if (copyUIAction != null)
        {
              copyUIAction.Execute();
        }
                
         // In context menu for paste.
        PasteItemUIAction pasteUIAction = pdfAnnotationTool.PasteAction;
        if (pasteUIAction != null)
        {
             pasteUIAction.Execute();
        }
Here is a stack trace of the error. This happens on the pasteUIAction.Execute:
03/12/2020 9:26:46.496 AM :: ER :: 1 :: VintaSoftViewerControl.ProcessTool :: An unexpected error occurred processing tool 'Paste'. Details: System.ArgumentOutOfRangeException: Index must be within the bounds of the List.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.Collections.ObjectModel.Collection`1.Insert(Int32 index, T item)
at Vintasoft.Imaging.Pdf.UI.Annotations.PdfAnnotationViewCollection.?(Object A_0, CollectionChangeEventArgs`1 A_1)
at Vintasoft.Imaging.CollectionChangeEventHandler`1.Invoke(Object sender, CollectionChangeEventArgs`1 e)
at Vintasoft.Imaging.Pdf.Tree.PdfTreeNodeList`1.OnChanged(CollectionChangeEventArgs`1 e)
at Vintasoft.Imaging.Pdf.Tree.PdfTreeNodeList`1.Insert(Int32 index, T item)
at Vintasoft.Imaging.Pdf.Tree.Annotations.PdfAnnotationList.Insert(Int32 index, PdfAnnotation item)
at Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormEditorManager.?(PdfAnnotationList A_0, IEnumerable`1 A_1, Single A_2, Single A_3)
at Vintasoft.Imaging.Pdf.Tree.InteractiveForms.PdfInteractiveFormEditorManager.AddCopy(PdfInteractiveFormFieldList targetFieldList, PdfAnnotationList targetAnnotationList, IEnumerable`1 annotations, Single offsetX, Single offsetY)
at ?.Execute()
at IS.WM.Viewers.VintaSoftViewerControl.ProcessTool(String toolKey, Boolean controlPressed, Object parameter1, Object parameter2, Object parameter3) in D:\GIT\docutrack\Projects\Viewers\VintaSoftViewer\VintaSoftViewerControlToolbarSupport.cs:line 914

I am not sure what is going on here. It looks like the There in some problem inserting the pasted item into the annotation list.
Is there some other functionality that I am missing for implementing the copy paste operations?
Do I need to be doing something with the clipboard?

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

Re: Argument out of range exception pasting annotations.

Post by Alex »

Hi Harlan,

Please send us (to support@vintasoft.com) a small project, which allows to reproduce the problem. We need to reproduce the problem on our side.

Best regards, Alexander
Alex
Site Admin
Posts: 2308
Joined: Thu Jul 10, 2008 2:21 pm

Re: Argument out of range exception pasting annotations.

Post by Alex »

Hi Harlan,

Have you solved the problem? We still not received the project, which allows to reproduce the problem on our side.

Best regards, Alexander
Post Reply