Forum rules DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Dim JS As New StringBuilder
JS.AppendLine("//JS Code to search for an annotation and get status of it where StateInModel is Review")
JS.AppendLine("//the JS output is passed to the SDK IString Res")
JS.AppendLine("this.syncAnnotScan();")
JS.AppendLine("var annots = this.getAnnots({")
JS.AppendLine("nPage: 0,")
JS.AppendLine("nSortBy: ANSB_Author,")
JS.AppendLine("bReverse: true")
JS.AppendLine("});")
JS.AppendLine("")
JS.AppendLine("var stateResults;")
JS.AppendLine("var returnResults;")
JS.AppendLine("returnResults = """";")
JS.AppendLine("identity.name = """ & MISData.Instance.FirstName & """;")
JS.AppendLine("for (var i = 0; i < annots.length; i++) {")
If statusName = "None" Then
JS.AppendLine("annots[i].transitionToState(""Review"",""None"");")
ElseIf statusName = "Accepted" Then
JS.AppendLine("annots[i].transitionToState(""Review"",""Accepted"");")
ElseIf statusName = "Cancelled" Then
JS.AppendLine("annots[i].transitionToState(""Review"",""Cancelled"");")
ElseIf statusName = "Completed" Then
JS.AppendLine("annots[i].transitionToState(""Review"",""Completed"");")
ElseIf statusName = "Rejected" Then
JS.AppendLine("annots[i].transitionToState(""Review"",""Rejected"");")
End If
JS.AppendLine("}")
Dim res As PDFXEdit.IString = Me.docPreview.Inst.CreateString()
Try
Me.docPreview.Inst.ExecuteJS(Me.docPreview.Doc, JS.ToString, PDFXEdit.PXV_ActionTriggerClass.PAEC_External, PDFXEdit.PXV_ActionTriggerSubclass.PAESC_Exec, Nothing, res)
Catch ex As Exception
Console.WriteLine("Error changing annotation state: " & convertErr(ex))
End Try
Is there anyway that I can get the annotation elements that I am changing the state of? e.g. if I have a rectangle and I run the above code, is there anyway I can get the rectangle annotation element as a IPXC_Annotation?
Just out of interest the JS code that I posted obviously gets all annotation elements and set all annotation element status. How would I just set the selected annotations state?
Get annotations from the current document's selection. Next when running through the JS cycle, check whether the annotation is in the selected array by comparing the JS Annotation "name" property and the IPXC_Annotation https://sdkhelp.pdf-xchange.com/vi ... ation_Name property.
I have almost got it working, however I have noticed in the below section of the JS that it is only get the annotation on page "0" (zero), or does this mean the active page?
nPage
(optional) A 0-based page number. If specified, gets only annotations on the given page. If not specified, gets annotations that meet the search criteria from all pages.