access new added annotation when pasted ín a document

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Post Reply
User avatar
MartinCS
User
Posts: 153
Joined: Thu Apr 07, 2011 10:01 am
Contact:

access new added annotation when pasted ín a document

Post by MartinCS »

Hi,

I have the following scenario:

The user selects and copies an annotation which is on a document page to the clipboard. After pasting it I need to modify certain annotation properties like (author, name, readOnly etc.) of the new annotation.

I'm aware of the OnEvent of the activeX control and currently I do have the following code:

Code: Select all

If (e.type = PDFXCviewAxLib.PXCVA_EventTypes.PXCVA_OnNamedNotify) And (e.name = "Notifications.NewAnnotAdded") Then

	Dim newAnnotName As Object = ""
	Dim pageIndex As Object = -1

	AxCoPDFXCview1.GetProperty("Notifications.NewAnnotAdded.PageIndex", pageIndex, 0)
	AxCoPDFXCview1.GetProperty("Notifications.NewAnnotAdded.Name", newAnnotName, 0)

		If (pageIndex >= 0) Then
			Dim js As String = "var ann = this.getAnnot(" + CStr(pageIndex) + ", '" + newAnnotName + "'); if (ann.readOnly == 1) { ann.readOnly = false; ann.name = 'TestID'; ann.author = '" + Environment.UserName + "'; app.alert(ann.author) }"

			AxCoPDFXCview1.RunJavaScript(js)
		End If

End If
Unfortunelly, the GetProperty Method does not return the new added annotation. It's always the original/selected annotation. So, with this code I always change the properties of the original annoation.

Is there a way to get access to the new added annotation? (Maybe direcly out of the clipboard?)

I would higly appreciate it if you guys could help me or give me an advise how to do this.


Thank you!


Martin
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17906
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: access new added annotation when pasted ín a document

Post by Tracker Supp-Stefan »

Hi Martin,

Can you please check and make sure that you are using the latest build of the Viewer AX SDK?

Best,
Stefan
User avatar
MartinCS
User
Posts: 153
Joined: Thu Apr 07, 2011 10:01 am
Contact:

Re: access new added annotation when pasted ín a document

Post by MartinCS »

Hi,

meanwhile I'm able to get access to the newly created annotation and edit the properties of the annotation using the following code:

Code: Select all

If (e.type = PDFXCviewAxLib.PXCVA_EventTypes.PXCVA_OnNamedNotify) And (e.name = "Notifications.Selection") Then

	Dim nDocID As Integer = -1
	AxCoPDFXCview1.GetActiveDocument(nDocID)

	AxCoPDFXCview1.DoDocumentVerb(nDocID, Nothing, "GetSelectedAnnot", Nothing, vDataOut)

	Dim pageIndex As Integer = DirectCast(vDataOut, Integer())(0)
	Dim annotIndexOnPage As Integer = DirectCast(vDataOut, Integer())(1)
	Dim res As String

	If pageIndex <> -1 AndAlso annotIndexOnPage > 0 Then

		Dim script As String = "var annots = this.getAnnots(" + CStr(pageIndex) + "); " +
			"var res = annots.length; " +
			"if ( (annots != null) && (" + CStr(annotIndexOnPage) + " < annots.length)) " +
			"{ " +
				"var sel= annots[" + CStr(annotIndexOnPage) + "]; " +
				"res = sel.contents; " +
				"sel.strokeColor = color.green;" +
				"sel.name = 'TestID';" +
				"if ( sel.readOnly == true) sel.readOnly = false;" +
				"sel.author = '" + Environment.UserName + "'" +
			"}" +
			" this.Results=res "

		Try
			AxCoPDFXCview1.RunJavaScript(script, res, 0, CInt(PDFXCviewAxLib.PXCVA_Flags.PXCVA_NoUI))
		Catch ex As Exception
			ShowErrorMessage(System.Runtime.InteropServices.Marshal.GetHRForException(ex))
		End Try

	End If

End If
But the problem now is that the code is executed every time when I select an annotation.

Is it possible to capture/listen to the paste event when the user clicks the toolbar button for paste, right hand mouse button with the context menu option paste and CTRL + V?


Thank you!


Martin
User avatar
MartinCS
User
Posts: 153
Joined: Thu Apr 07, 2011 10:01 am
Contact:

Re: access new added annotation when pasted ín a document

Post by MartinCS »

Hi Stefan,

I'm using the latest build of the Viewer Ax SDK.

While you were replying to my first post I posted a second code snippet showing you that I'm able to get access to the added annotation. I'm using the behavior of the Viewer that it selects the newly pasted annotation. But I need to execute this code only when the user pasts an annotation from clipboard.

I hope you have an advise for me!


Best,
Martin
Last edited by MartinCS on Wed Nov 27, 2013 4:15 pm, edited 1 time in total.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17906
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: access new added annotation when pasted ín a document

Post by Tracker Supp-Stefan »

Hi Martin,

Yes I noticed your second post.

When an annotation is pasted it is always selected - so maybe you can use your first notification Notifications.NewAnnotAdded with the GetSelectedAnnot method?

Regards,
Stefan
User avatar
MartinCS
User
Posts: 153
Joined: Thu Apr 07, 2011 10:01 am
Contact:

Re: access new added annotation when pasted ín a document

Post by MartinCS »

Hi Stefan,

but the problem is that the notification 'NewAnnotAdded' gets also fired when the document is loaded and the current annotations are added to the document.

Is there a way to capture the paste event of an annotion?


Thank you!


Best,
Martin
User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 2353
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: access new added annotation when pasted ín a document

Post by Vasyl-Tracker Dev Team »

We found one issue: when you paste the copied annot then it will be pasted with the same name as in original. We will fix it inn the next build. Please wait.
but the problem is that the notification 'NewAnnotAdded' gets also fired when the document is loaded and the current annotations are added to the document.
Is there a way to capture the paste event of an annotion?
In the next build we can add simple property:
"Notifications.NewAnnotAdded.Source" = "User" | "JS" | "Paste" ...
You will be able to handle case "Notifications.NewAnnotAdded.Source" == "Paste"..

Best
Regards.
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
User avatar
MartinCS
User
Posts: 153
Joined: Thu Apr 07, 2011 10:01 am
Contact:

Re: access new added annotation when pasted ín a document

Post by MartinCS »

Hi Vasyl,

first of all a big thank you for your quick reply and the efforts of Stefan and yourself! I highly appreciate that!

I'm glad you found the issue with the copied name property.

I noticed this problem before and I was trying to set a new name for the pasted annot:

Code: Select all

<...>
"sel.name = 'TestID';"
<...>
When do you think the next build for the Viewer will be out? The programming I'm working on is very critical for us. The reason that the Viewer doesn't support the selection of multiple annots and to copy and paste them like it was introduced in the Editor is a big issue for our clients.

We desperately need the programming I'm working on in order to support our clients with a workaround.

Please give me a release date for the next build. That would be great!


Thank you!


Best,
Martin
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17906
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: access new added annotation when pasted ín a document

Post by Tracker Supp-Stefan »

Hi Martin,

Still no specific date yet I am afraid. Trying to get anything further for you from the dev team.

Regards,
Stefan
User avatar
MartinCS
User
Posts: 153
Joined: Thu Apr 07, 2011 10:01 am
Contact:

Re: access new added annotation when pasted ín a document

Post by MartinCS »

Hi Stefan,

do you have received any feedback from the dev team meanwhile?

We are desperately waiting for the next release.

Thank you for your efforts!

Regards,
Martin
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17906
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: access new added annotation when pasted ín a document

Post by Tracker Supp-Stefan »

Sorry Martin,

I still do not have any specific date for you :(

Regards,
Stefan
User avatar
MartinCS
User
Posts: 153
Joined: Thu Apr 07, 2011 10:01 am
Contact:

Re: access new added annotation when pasted ín a document

Post by MartinCS »

Hi Stefan,

just to make sure that I stick in your mind ...

We're still waiting for a statement when the next update for the Viewer SDK will be released.

Do you have an update?

I also would like to ask you if there might be a release candidate version for the Editor SDK available?


Thank you!

Martin
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17906
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: access new added annotation when pasted ín a document

Post by Tracker Supp-Stefan »

Hi Martin,

Apologies for the delay in answering that latest question of yours. Nothing has changed since my last post and when a date is set it will be announced.

Regards,
Stefan
User avatar
Paul - Tracker Supp
Site Admin
Posts: 6897
Joined: Wed Mar 25, 2009 10:37 pm
Location: Chemainus, Canada
Contact:

Re: access new added annotation when pasted ín a document

Post by Paul - Tracker Supp »

Hi Martin,

we will be doing what could be called a 'Service Release' soon. We have been recently very heavily focused on getting the Editor as up to speed with the Viewer features and some bugs and other fixes have suffered as a result.

We will be trying to resolve a lot of these outstanding issues in a build expected in about a month's time. As usual this is not a promised delivery date but an intention at present.

We will be looking to this as well as other issues for that build. I don't think it will however include the ability to modify multiple annotations concurrently in the Viewer as that was, as you point out, done in the Editor.

Moving forward it would be a good thing to consider moving to the Editor when it is available.
Best regards

Paul O'Rorke
Tracker Support North America
http://www.tracker-software.com
Post Reply