Change colour of annot text colour

PDF-XChange Editor SDK for Developers

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

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: 406
Joined: Sat May 16, 2009 1:55 pm

Change colour of annot text colour

Post by lidds » Fri Jan 04, 2019 4:31 pm

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

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

Re: Change colour of annot text colour

Post by Sasha - Tracker Dev Team » Sat Jan 05, 2019 2:02 pm

Hello Simon,

Let's try this. After you have executed the import annotations operation, the https://sdkhelp.tracker-software.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.tracker-software.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
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

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

Re: Change colour of annot text colour

Post by lidds » Mon Jan 07, 2019 10:27 am

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: 406
Joined: Sat May 16, 2009 1:55 pm

Re: Change colour of annot text colour

Post by lidds » Tue Jan 08, 2019 11:14 am

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

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

Re: Change colour of annot text colour

Post by Sasha - Tracker Dev Team » Tue Jan 08, 2019 4:03 pm

Hello Simon,

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

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

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

Re: Change colour of annot text colour

Post by Sasha - Tracker Dev Team » Wed Jan 09, 2019 2:00 pm

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
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

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

Re: Change colour of annot text colour

Post by lidds » Thu Jan 10, 2019 3:38 pm

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: 406
Joined: Sat May 16, 2009 1:55 pm

Re: Change colour of annot text colour

Post by lidds » Fri May 10, 2019 12:41 pm

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

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

Re: Change colour of annot text colour

Post by Sasha - Tracker Dev Team » Fri May 10, 2019 1:03 pm

Hello Simon,

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

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

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

Re: Change colour of annot text colour

Post by lidds » Fri May 10, 2019 3:26 pm

Thanks Alex,

I'll give this a try over the weekend.

Thanks for your help

Simon

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

Re: Change colour of annot text colour

Post by Sasha - Tracker Dev Team » Mon May 13, 2019 6:24 am

:)
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Post Reply