PDF-XChange - Tracker PDF Viewer - TIFF-XChange - Image-XChange - XMF-XChange - Raster-XChange - Support

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Paul - Tracker Supp, Chris - Tracker Supp, 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.
 
dconner
User
Topic Author
Posts: 28
Joined: Fri Feb 07, 2014 10:27 pm

How To Change Redaction Fill Color

Mon Mar 12, 2018 5:43 pm

Hi All,

I’d like to create a “White Out” redaction tool that automatically selects a white fill color in the tool’s color picker, but “tool.annot.redaction” is not accepted in GetCurrentStyle().

This seems to work fine with any other tool but how can I make it work with redaction?

private void btnWhiteOut_ItemClick(object sender, ItemClickEventArgs e)
{
   var tid = pdfx.Inst.Str2ID("tool.annot.redaction", false);
   var styleParams = pdfx.Inst.CommentStylesManager.GetCurrentStyle(tid);
   styleParams["FC"].v = "rgbd(255,255,255)";
   pdfx.Inst.CommentStylesManager.OnChangedCurrentStyle(tid);


   var cmd = uiInst.CmdManager.Cmds.Find("cmd.tool.annot.redaction");

   if (cmd != null)
        {
             pdfx.Inst.ExecUICmd2(cmd.ID);
        }
}


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

Re: How To Change Redaction Fill Color

Thu Mar 15, 2018 3:57 pm

Hello dconner,

Sorry for the long reply. I don't see the problem in this case - the redaction tool should be have like any other tools. Can you confirm that this code works for any other tools (for example line tool)?

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
 
dconner
User
Topic Author
Posts: 28
Joined: Fri Feb 07, 2014 10:27 pm

Re: How To Change Redaction Fill Color

Thu Mar 15, 2018 4:07 pm

It seems to work fine on the other tools. It seems, however, that the fill property is different on this type of annotation.

This is our final working solution:

        public void ChangeRedactToWhite(IPXC_Annotation annot)
        {
            var PXS = (IPXS_Inst)pdfx.Inst.GetExtension("PXS");
            var redact = PXS.StrToAtom("Redact");
            int setPropsID = pdfx.Inst.Str2ID("op.annots.setProps", false);
            var setPropsOp = pdfx.Inst.CreateOp(setPropsID);
            var setPropsInput = setPropsOp.Params.Root["Input"];

            if (annot is IPXC_Annotation && ((IPXC_Annotation)annot).Type == redact)
                setPropsInput.Add().v = annot;

            if (setPropsInput.Count == 0)
            {
                return;
            }


            var setPropsOptions = setPropsOp.Params.Root["Options"];
            setPropsOptions["OFC"].v = "#FFFFFF";  //WHITE COLOR
            setPropsOptions["MaskEx"].v = 1;

            setPropsOp.Do();
        }
 
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 12596
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: How To Change Redaction Fill Color

Thu Mar 15, 2018 4:12 pm

Hello dconner,

Thanks for sharing your code!
So does this latest version work correctly for you? Can we consider this one resolved?

Cheers,
Stefan
 
dconner
User
Topic Author
Posts: 28
Joined: Fri Feb 07, 2014 10:27 pm

Re: How To Change Redaction Fill Color

Fri Mar 16, 2018 5:29 pm

That posted code was a workaround that sets the most recent annotation received from e.annots.inserted’s AnnotsList.Item[0]. While that does satisfy our current use case, it doesn’t resolve the original issue of setting the redaction tool’s default overlay fill color in the command bar’s color picker.

After discovering “tool.annot.redaction” was not being accepted into GetCurrentStyle(), I used this code to determine the list of tools that are accepted.

public void Export_GetCurrentStyle()
{
       int n = 1;
       string output = "";
       while (true)
       {
              string toolName = pdfx.Inst.ID2Str(n);
              if (String.IsNullOrEmpty(toolName)) // loop until tool was not found
                     break;
              try
              {
                     pdfx.Inst.CommentStylesManager.GetCurrentStyle(n);
                     output += toolName + "\r\n";
              }
              catch { }
              n++;
       }
       File.WriteAllText(Path.Combine(Path.GetTempPath(), "GetCurrentStyle.txt"), output);
}

 


This outputs this list:

tool.annot.square
tool.annot.circle
tool.annot.stickyNote
tool.annot.fileAttachment
tool.annot.sound
tool.annot.line
tool.annot.arrow
tool.annot.distance
tool.annot.polyline
tool.annot.polygon
tool.annot.cloud
tool.annot.perimeter
tool.annot.area
tool.annot.textBox
tool.annot.callout
tool.annot.typeWriter
tool.annot.pencil
tool.annot.highlight
tool.annot.underline
tool.annot.strikeout


The exception message when attempting GetCurrentStyle(pdfx.Inst.Str2ID(“tool.annot.redaction”)) is “Value does not fall within the expected range.”
 
User avatar
Sasha - Tracker Dev Team
User
Posts: 3245
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: How To Change Redaction Fill Color

Sat Mar 17, 2018 8:50 am

Hello dconner,

Just investigated this - the thing is that the tools which handlers do not have the specified path to global params are not added to the tools list in the command manager. Thus this behavior occurs.

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

Who is online

Users browsing this forum: No registered users and 1 guest