Change colour of annot text colour

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

Change colour of annot text colour

Post by lidds »

I am trying to change the colour of imported annotation to grey, which I am able to do using the following code:

Code: Select all

 options("SColor").v = "rgbd(128,128,128)"
                                options("Flags").v = PXC_AnnotFlag.AF_Print + PXC_AnnotFlag.AF_ContentLocked + PXC_AnnotFlag.AF_Locked + PXV_OpModifyAnnotMaskFlags.OpModifyAnnot_SColor
                                options("Mask").v = PXV_OpModifyAnnotMaskFlags.OpModifyAnnot_Flags + PXV_OpModifyAnnotMaskFlags.OpModifyAnnot_SColor
However what I want to do is also change the colour of the text on the annotation to grey, I therefore tried using the DefTextColor option, but this had no effect:

Code: Select all

 options("SColor").v = "rgbd(128,128,128)"
                                options("DefTextColor").v = "rgbd(128,128,128)"
                                options("Flags").v = PXC_AnnotFlag.AF_Print + PXC_AnnotFlag.AF_ContentLocked + PXC_AnnotFlag.AF_Locked + PXV_OpModifyAnnotMaskFlags.OpModifyAnnot_SColor + PXV_OpModifyAnnotMaskFlags.OpModifyAnnot_Text
                                options("Mask").v = PXV_OpModifyAnnotMaskFlags.OpModifyAnnot_Flags + PXV_OpModifyAnnotMaskFlags.OpModifyAnnot_SColor + PXV_OpModifyAnnotMaskFlags.OpModifyAnnot_Text
How do I go about changing the annotation text colour?

Thanks

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

Re: Change colour of annot text colour

Post by Sasha - Tracker Dev Team »

Hello Simon,

Let's try this. After you have executed the import annotations operation, the https://sdkhelp.pdf-xchange.com/vi ... ePagesList operation should be fired. You should catch it, and go though all of the FreeText annotations in the IPXC_Document and change their https://sdkhelp.pdf-xchange.com/vi ... tTextColor parameter. Then, the event should be caught by all of the other Views and they should load the style of the annotation with the changed text color.

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

Re: Change colour of annot text colour

Post by lidds »

Alex,

I must be doing something wrong as the below code does not seem to change the text colour, could you please let me know what I am doing wrong?

Code: Select all

      ElseIf e.nEventID = nIDS(CInt(IDS.e_document_afterChangePagesList)) Then
        Debug.WriteLine("e_document_afterChangePagesList")

        Dim nID As Integer = Me.docPreview.Inst.Str2ID("op.annots.setProps", False)
        Dim Op As PDFXEdit.IOperation = Me.docPreview.Inst.CreateOp(nID)
        Dim inputProps As PDFXEdit.ICabNode = Op.Params.Root("Input")

        For i As UInteger = 0 To Me.docPreview.Doc.CoreDoc.Pages.Count - 1
          Dim page As PDFXEdit.IPXC_Page = Me.docPreview.Doc.CoreDoc.Pages(i)
          Dim nCnt As UInteger = page.GetAnnotsCount()

          If nCnt <> 0 Then
            For j As UInteger = 0 To nCnt - 1
              Dim annot As PDFXEdit.IPXC_Annotation = page.GetAnnot(j)
              If annot.IsMarkup Then
                Dim annotType As String = pxsInst.AtomToStr(annot.Type)
                If annotType = "FreeText" Then
                  Dim mData As PDFXEdit.IPXC_AnnotData_FreeText = CType(annot.Data, PDFXEdit.IPXC_AnnotData_FreeText)
                  Dim color As PDFXEdit.IColor = auxInst.CreateColor(PDFXEdit.ColorType.ColorType_RGB)
                  color.Value = "rgbd(128,128,128)"
                  mData.DefaultTextColor = color
                  annot.Data = mData

                  inputProps.Add().v = annot
                End If
              End If
            Next
          End If
        Next

        Dim options As PDFXEdit.ICabNode = Op.Params.Root("Options")
        options("Flags").v = PXV_OpModifyAnnotMaskFlags.OpModifyAnnot_Text
        options("Mask").v = PXV_OpModifyAnnotMaskFlags.OpModifyAnnot_Flags
        Op.Do()
Thanks

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

Re: Change colour of annot text colour

Post by lidds »

Alex,

Sorry to bother you as I know I only posted this yesterday, but this is the last thing I need to resolve prior to releasing my new version of software, if you have time could you have a look at the for me.

Thanks

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

Re: Change colour of annot text colour

Post by Sasha - Tracker Dev Team »

Hello Simon,

We had a holiday yesterday, thus I could not attend to your question. I will look into this one tomorrow.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Change colour of annot text colour

Post by Sasha - Tracker Dev Team »

Hello Simon,

From what I see, if you modify the color of the annotation's text, the RichText value is being set to the proper formatting. You can get the plain text out of the annotation and turn it into your own formatting via the RichText value, though if there were any other setting like font size or different styles - all of them will be rewritten by your new style.
Basically, the string itself would look something like this:

Code: Select all

<?xml version="1.0"?><body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:APIVersion="Acrobat:10.1.5" xfa:spec="2.0.2" style="text-align:left;line-height:normal;font-family:Arial;font-size:12pt;font-weight:normal;font-style:normal;text-decoration:none;color:#000000;text-valign:top;"><p style="color:#C0FFFF;"><span>MyText</span></p></body>
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
lidds
User
Posts: 510
Joined: Sat May 16, 2009 1:55 pm

Re: Change colour of annot text colour

Post by lidds »

Alex,

Thank you for the info, however I do not want to change the formatting etc if the text. I have just had a play around with your text commandbar and this allows you to change the font colour and does not override the formatting. Would it be possible for the developers to make available the method that the change font colourpicker is using as this seems to do the job?

Thanks

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

Re: Change colour of annot text colour

Post by lidds »

Alex,

A couple of questions as always.

1. How do I set the new richtext back to the annotation element?
2. I am working with annotation export files and I have noticed that in the fdf file the tichtext is within this file. I was wondering if I can use javascript to return the current richtext of an annotation element and modify the colour and push it back?

Thanks

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

Re: Change colour of annot text colour

Post by Sasha - Tracker Dev Team »

Hello Simon,

Check out this topic:
viewtopic.php?f=66&t=26483&p=105624&hil ... xt#p105624

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

Re: Change colour of annot text colour

Post by lidds »

Thanks Alex,

I'll give this a try over the weekend.

Thanks for your help

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

Re: Change colour of annot text colour

Post by Sasha - Tracker Dev Team »

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