Fill the text in search panel and start search programmatically  SOLVED

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.
Fanski
User
Posts: 33
Joined: Tue Apr 17, 2012 10:33 am

Fill the text in search panel and start search programmatically

Post by Fanski »

I can’t figure out how to set the search text in the search panel and than start the search programmatically.
Could you give me an example? (c# maybe :) )
User avatar
TrackerSupp-Daniel
Site Admin
Posts: 8613
Joined: Wed Jan 03, 2018 6:52 pm

Re: Fill the text in search panel and start search programmatically

Post by TrackerSupp-Daniel »

Hello Fanski,

We do offer some samples on our GitHub, including a FullDemo for the Editor SDK in C#, Have you already looked through these to see if what you needed is available there?
https://github.com/tracker-software/PDF ... ter/CSharp

I hope this helps!
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Fanski
User
Posts: 33
Joined: Tue Apr 17, 2012 10:33 am

Re: Fill the text in search panel and start search programmatically

Post by Fanski »

Hello Daniel,

thenks for your answer.
In the demo i only can find, how to toggle the panel on and off (Show Search pane)
I cant find, how to fill the “Search text” field, and how to perform the search after this.
if i missed it, could you send me a screenshot where i can find it in the demo?

In the PdfXChange Viewer it worked like this:

Code: Select all

 axCoPdfxCview.SetProperty("View.Bars[\"Find\"].Visible", "True", 0);
 axCoPdfxCview.SetProperty("View.Panes[\"Search\"].Visible", "True", 0);
 axCoPdfxCview.SetProperty("Search.What.Text", searchString, 0);
 object vDataOut;
 axCoPdfxCview.DoVerb(null, "ExecuteCommand", 32977, out vDataOut, 0);
Kind Regards
Peter Stefanski
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Fill the text in search panel and start search programmatically  SOLVED

Post by Sasha - Tracker Dev Team »

Hello Peter Stefanski,

Try using forum search first - many questions are already answered. Here are two topics that can prove useful:
viewtopic.php?f=66&t=26242&p=103184&hil ... og#p103184
viewtopic.php?f=66&t=27795&hilit=find+dialog

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Fanski
User
Posts: 33
Joined: Tue Apr 17, 2012 10:33 am

Re: Fill the text in search panel and start search programmatically

Post by Fanski »

Hi Alex,

thank you for your help.
I missed the example "FullDemo.Fixed.zip"

If someone else needs this, here is the code you need:

Code: Select all

        public void Search(string text)
        {
            string js = GetJavascript(text);

            axPxvControl.Inst.ExecuteJS(axPxvControl.Doc,
                js,
                PXV_ActionTriggerClass.PAEC_Console,
                PXV_ActionTriggerSubclass.PAESC_Exec,
                null);
        }

        private static string GetJavascript(string searchText)
        {
            StringBuilder script = new StringBuilder();
            script.AppendLine("search.refine = false;");
            script.AppendLine("search.matchCase = false;");
            script.AppendLine(string.Format("search.query(\"{0}\", \"ActiveDoc\");", searchText));
            return script.ToString();
        }
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17948
Joined: Mon Jan 12, 2009 8:07 am
Location: London

Re: Fill the text in search panel and start search programmatically

Post by Tracker Supp-Stefan »

Thanks for sharing this code Fanski!

Regards,
Stefan
Fanski
User
Posts: 33
Joined: Tue Apr 17, 2012 10:33 am

Re: Fill the text in search panel and start search programmatically

Post by Fanski »

I have a problem with my solution.
I open the PDF Editor is a second Form. After using, i dospose the PdfEditor Control and dispose the Form.
When i open the Form a second time (and initialize the PDF Editor again) there is always an exception, when i use JS.
Without JS there are no Problems but JS throws this Exception that i even can’t catch:

Attempted to read or write protected memory. This is often an indication that other memory is corrupt

This is the line of code throwing this exception:

Code: Select all

axPxvControl.Inst.ExecuteJS(axPxvControl.Doc,
    js,
    PXV_ActionTriggerClass.PAEC_Console,
    PXV_ActionTriggerSubclass.PAESC_Exec,
    null);
I'm using Version SDK 8.0.333.0
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Fill the text in search panel and start search programmatically

Post by Sasha - Tracker Dev Team »

Hello Fanski,

This topic should prove useful:
viewtopic.php?f=66&t=26714&p=103655&hil ... ce#p103655

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Fanski
User
Posts: 33
Joined: Tue Apr 17, 2012 10:33 am

Re: Fill the text in search panel and start search programmatically

Post by Fanski »

Hello Alex,

Thank you that fixed my problems.

Kind Regards
Peter
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Fill the text in search panel and start search programmatically

Post by Sasha - Tracker Dev Team »

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