clear highlighted text programmatically

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

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

fabrizio
User
Posts: 33
Joined: Fri Jul 02, 2010 1:58 pm

clear highlighted text programmatically

Post by fabrizio »

Hi, I'm trying to clear some higlighted text in a little VB.NET application which embeds PDFXChange ActiveX component (demo). In order to higlight text I use the following which works fine:

Dim vDataIn As Object
Dim vDataOut As Object = Nothing

Dim vArr(5) As Object
vArr(0) = 0
vArr(1) = 10
vArr(2) = RGB(255, 0, 0)
vArr(3) = 0.75
vArr(4) = "12345"

vDataIn = vArr
spText.DoVerb("", "Highlight", vDataIn, vDataOut, 0)

Then I try to clear the highlighted text calling destroy on an Annotation object via javascript:

Dim idDoc As Integer = 0
AxCoPDFXCview1.GetActiveDocument(idDoc)
Dim sScript As String = "var a = this.getAnnot(0, " + Chr(34) + "12345" + Chr(34) + "); if(a!= null) { a.destroy(); }; "
AxCoPDFXCview1.RunJavaScript(sScript, Nothing, idDoc, 0)

which returns with no errors but doens't clear the higlighted area.
I think a is null and when I try to call destroy on it (without checking if it's null) the application crashes with this error: 0x82132712

Can you please tell me where I'm wrong? Is there a way to clear highlighted text programmatically?
Thank you.
Regards,
Fabrizio
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: clear highlighted text programmatically

Post by Corwin - Tracker Sup »

Hi Fabrizio,

I'm afraid that we cannot reproduce this problem.
Can you please send us sample project and PDF file, so we can test it here.

Thanks.
fabrizio
User
Posts: 33
Joined: Fri Jul 02, 2010 1:58 pm

Re: clear highlighted text programmatically

Post by fabrizio »

Thank you for your answer, I attach the little VisualStudio project I was working on and a sample PDF file.
HighLight.zip
You do not have the required permissions to view the files attached to this post.
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: clear highlighted text programmatically

Post by Corwin - Tracker Sup »

Hi Fabrizio,

Your sample works fine for me. Please, install latest build of PDF-XChange Viewer SDK.
Also please note, that it will be better to set spText variable right before its usage:

Code: Select all

AxCoPDFXCview1.DoVerb("Documents[0].Pages[0].Text", ".SP", Nothing, vDataOut, 0)
spText = vDataOut
vDataOut = Nothing

spText.DoVerb("", "Highlight", vDataIn, vDataOut, 0)
System.Runtime.InteropServices.Marshal.ReleaseComObject(spText)
HTH.
fabrizio
User
Posts: 33
Joined: Fri Jul 02, 2010 1:58 pm

Re: clear highlighted text programmatically

Post by fabrizio »

Thank you, now it works fine with ver 0.53 :D
(I was running ver 0.52)
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: clear highlighted text programmatically

Post by Stefan - PDF-XChange »

:)