ExecuteJS seems to stop my application closing...

PDF-XChange Editor SDK for Developers

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

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.
Post Reply
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

ExecuteJS seems to stop my application closing...

Post by lidds »

I have noticed that if I execute any javascript and then close my application it seems to leave my application hanging (resulting in the application .exe process still running).

Below is my code, which works fine with no errors. Do I need to dispose of anything prior to closing my application?

Code: Select all

Private Sub getAnnotStatus(ByVal annotOID As String)
Dim tOutputJS As String = Nothing

            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("nSortBy: ANSB_Author,")
            JS.AppendLine("bReverse: true")
            JS.AppendLine("});")
            JS.AppendLine("")
            JS.AppendLine("var stateResults;")
            JS.AppendLine("var returnResults;")
            JS.AppendLine("returnResults = """";")

            JS.AppendLine("var selAnnots = [")

            If getSelected = True Then
                Dim sel As PDFXEdit.IPXV_DocSelection = Me.docPreview.Doc.ActiveSel
                Dim annotSel As PDFXEdit.IPXV_AnnotSelection = CType(sel, PDFXEdit.IPXV_AnnotSelection)
                If annotSel IsNot Nothing Then
                    For i As UInteger = 0 To annotSel.Items.Count - 1
                        JS.AppendLine("""" & annotSel.Items(i).Name & """" & ",")
                    Next
                End If
            Else
                JS.AppendLine("""" & annotOID & """")
            End If

            JS.AppendLine("];")

            JS.AppendLine("for (var i = 0; i < annots.length; i++) {")
            JS.AppendLine("for (var j = 0; j < selAnnots.length; j++) {")
            JS.AppendLine("if (selAnnots[j] == annots[i].name) {")
            JS.AppendLine("var states = annots[i].getStateInModel(""Review"");")
            JS.AppendLine("var state;")
            JS.AppendLine("stateResults = """";")
            JS.AppendLine("if (states.length > 0) {")
            JS.AppendLine("for (k = 0; k < states.length; k++) {")
            JS.AppendLine("var s = states[k].state;")
            JS.AppendLine("state = s;")
            JS.AppendLine("stateResults = ""State="" + s;")
            JS.AppendLine("}")
            JS.AppendLine("} else {")
            JS.AppendLine("stateResults = ""State=None"";")
            JS.AppendLine("}")
            JS.AppendLine("if (states.length === 0);")
            JS.AppendLine("returnResults = returnResults + stateResults + ""~"";")
            JS.AppendLine("res = returnResults;")
            JS.AppendLine("}")
            JS.AppendLine("}")
            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 getting annotation state: " & convertErr(ex))
            End Try
 End Sub
Thanks in advance
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: ExecuteJS seems to stop my application closing...

Post by Tracker Supp-Stefan »

Hello lidds,

This has been passed to the correct developer (Roman), and he will look at it as soon as he comes to work, and will post with further advise shortly after!

Regards,
Stefan
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: ExecuteJS seems to stop my application closing...

Post by lidds »

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

Re: ExecuteJS seems to stop my application closing...

Post by Tracker Supp-Stefan »

:D
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: ExecuteJS seems to stop my application closing...

Post by lidds »

Stefan,

Is there any update on this?

Thanks

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

Re: ExecuteJS seems to stop my application closing...

Post by Tracker Supp-Stefan »

Sorry Simon,

I was expecting Roman would post directly here.
He is in the Canadian office - so I didn't speak with him directly yesterday, but will chase this one up again today and try to get you some feedback asap!

Regards,
Stefan
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: ExecuteJS seems to stop my application closing...

Post by lidds »

Thanks Stefan,

Do not mean to hassle you, but I want to release a new version of my software, but obviously can't if the software does not close properly.

Thanks for your time.

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

Re: ExecuteJS seems to stop my application closing...

Post by Tracker Supp-Stefan »

Hi Simon,

I understand that fully, and have already taken the necessary steps to get a reply back to you asap!

Regards,
Stefan
User avatar
Roman - Tracker Supp
Site Admin
Posts: 303
Joined: Sun Nov 21, 2004 3:19 pm

Re: ExecuteJS seems to stop my application closing...

Post by Roman - Tracker Supp »

Hi Simon,
This issue is in our top list. We will come with a solution next week.
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: ExecuteJS seems to stop my application closing...

Post by lidds »

Thanks Roman,

I was just wondering if there is any update on this issue?

Thanks

Simon
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: ExecuteJS seems to stop my application closing...

Post by Sasha - Tracker Dev Team »

Hello Simon,

Just spoke with Roman, if you can, please provide a small sample project (preferably on .Net for easier debugging) and he will take a look at it.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: ExecuteJS seems to stop my application closing...

Post by lidds »

Alex,

I have an issue now, I have created a .Net sample project with my code and this all works fine and closes the application cleanly. However on my main project if the JS code is run it does not close kill the .exe process. It is as if something is not getting disposed correctly, however I have debugged the application and the PDFXChange Dispose method is getting fired and runs without any errors. I know you are probably unable to help with this as it could be a many things, but is there anything methods, debugging I can try? I would send you my main project, but I use various DevExpress third party controls.

Any help would be appreciated as I am stuck.

Thanks in advance for your help

Simon
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: ExecuteJS seems to stop my application closing...

Post by Sasha - Tracker Dev Team »

Hello Simon,

I will tell Roman this, and we'll see whether he can take something out of it.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: ExecuteJS seems to stop my application closing...

Post by lidds »

Thanks Alex,

I have the following onEvent methods:

Code: Select all

Private Sub docPreview_OnEvent(sender As Object, e As AxPDFXEdit._IPXV_ControlEvents_OnEventEvent) Handles docPreview.OnEvent

Code: Select all

Public Sub OnEvent(pSender As PDFXEdit.IUIX_Obj, pEvent As PDFXEdit.IUIX_Event) Implements PDFXEdit.IUIX_ObjImpl.OnEvent
And these do not get fired if I run the JS, therefore the JS command must be doing something behind the scenes that is leaving something open / exposed stopping the exe process from closing.

Just thought I'd mention it

Thanks

Simon
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: ExecuteJS seems to stop my application closing...

Post by Sasha - Tracker Dev Team »

Hello Simon,

Well, we still will have to wait for Roman's response whether you will have to send him your project or will the information that you have provided give him another idea on the cause of this.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: ExecuteJS seems to stop my application closing...

Post by lidds »

Understood Alex, just thought I'd try and post as much info for Roman as possible.

Alternatively, and not sure if this is beyond your service agreement, whether Roman would be available to do a WebEx?

Anyway as you said we will wait for Roman.

Thanks for your time, good support as usual.

Simon
User avatar
Roman - Tracker Supp
Site Admin
Posts: 303
Joined: Sun Nov 21, 2004 3:19 pm

Re: ExecuteJS seems to stop my application closing...

Post by Roman - Tracker Supp »

Hi Simon,
Can you then provide a memory dump of your hung application?
To do this (assuming you run Windows 7 or later) Open Windows Task Manager (Ctrl+Shift+Esc), locate your application process (either on Processes or Details tab), right-click it and select "Create dump file". You will get a window with the path to the created dump file. Please send me this file (zipped). I think it would be better to upload the file to some file sharing online service (like Google Drive or DropBox) and send me the link. If your application memory may contain private data, please send me the link in private message.
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: ExecuteJS seems to stop my application closing...

Post by lidds »

Roman,

For some reason I am unable to find how to PM you. Therefore I have send an email to support@pdf-xchange.com with the download link

Thanks

Simon
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: ExecuteJS seems to stop my application closing...

Post by Sasha - Tracker Dev Team »

Hello Simon,

As soon as Roman can investigate the issue, we will reply back here.
PS: He's in our Canadian office so expect a reply in that time zone.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
dconner
User
Posts: 28
Joined: Fri Feb 07, 2014 10:27 pm

Re: ExecuteJS seems to stop my application closing...

Post by dconner »

Hi all. I'm running into the exact same issue. This is what I discovered:

1> this only happens when control isn't shown
2> seems to happen on certain text annotations (especially on the rect property) when control isn't visible

This seems to be the culprit:

Code: Select all

                            fieldinfo.value = ExecuteJS($"this.getField('{fieldinfo.name}').rect;");
Invoked via:

Code: Select all

        public string ExecuteJS(string script)
        {
            var iresult = pdfx.Inst.CreateString("");
            if (pdfx.Doc != null)
            {
                pdfx.Inst.ExecuteJS(pdfx.Doc,
                    script, 
                    PXV_ActionTriggerClass.PAEC_External, 
                    PXV_ActionTriggerSubclass.PAESC_Exec, 
                    null, 
                    iresult);
                return iresult.Value;
            }
            return null;
        }
Is there any timeline on resolving this issue?

Most Sincerely
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: ExecuteJS seems to stop my application closing...

Post by Sasha - Tracker Dev Team »

Hello dconner,

We are holding a release in a couple of days - we will tend to this problem afterwards.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
User avatar
Roman - Tracker Supp
Site Admin
Posts: 303
Joined: Sun Nov 21, 2004 3:19 pm

Re: ExecuteJS seems to stop my application closing...

Post by Roman - Tracker Supp »

Hello dconner,
Please make sure all calls of IPXV_Inst.Init in your code pair with with IPXV_Inst.Shutdown.
dconner
User
Posts: 28
Joined: Fri Feb 07, 2014 10:27 pm

Re: ExecuteJS seems to stop my application closing...

Post by dconner »

Awesome! That did it! This is a really nice control.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: ExecuteJS seems to stop my application closing...

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply