Redact RedactRequestCtx json?

Example requests & Code samples for GdPicture Toolkits.
Post Reply
Player1
Posts: 5
Joined: Fri Oct 01, 2021 5:35 am

Redact RedactRequestCtx json?

Post by Player1 » Tue Oct 05, 2021 9:25 am

Hi GdPicture forum,
I am a GdPicture/DocuVieware newbie wanting to handle redaction using the DocuViewareControllerActionsHandler in GdPicture.WEB, in C#/.NET Core.

Looking at the controller's http post handler for redact, I have: public string Redact([FromBody] object jsonString) {....}

Hitting F12 to the metadata for this method in DocuViewareControllerActionsHandler makes mention of the jsonString being the "json form of RedactRequestCtx structure".

Using the Object Browser I've looked through the whole of GdPicture, GdPicture.WEB and others but can't seem to find anything about this structure.
Neither did a google search find anything, and pasteing 'RedactRequestCtx' into the gdpicture.com search field gives me the site's page with just the same information I see in the metadata.

I've tried parsing the jsonString into a jObject and looking at the children but have not found anything there except some json with ScrollbarVal,hScrollbarVal etc. and a session and context ID and that's all there is, ie, same as passed in.

Could someone steer me in the right direction about where I might find the RedactRequestCtx or equivalent object please, as I'd like to extract the width, height and location of the black redact rectangle, or a list of such rectangles (I presume that is what this structure has in it?).

Thanks for any help!

User avatar
Fabio
Posts: 173
Joined: Thu Aug 27, 2020 9:57 am

Re: Redact RedactRequestCtx json?

Post by Fabio » Tue Oct 05, 2021 2:41 pm

Hello,

Before diving into the technical stuff, I just want to mention that we actually have 2 easy ways to handle the redaction feature through DocuVieware.

Integrated redaction

You can activate the Redaction snap-in by setting this property to true server-side: https://www.docuvieware.com/guides/aspn ... napIn.html

ps: you can check it out on our online demo here: https://www.docuvieware-demo.com/annotations_demo.aspx

Custom redaction

You can also manage the redactions using our SDK.
Here is an example of a server-side redaction usage: https://www.gdpicture.com/blog/how-to-r ... ficiently/
Here are some links to set the redaction, and apply it:
- https://www.docuvieware.com/guides/aspn ... dText.html
- https://www.docuvieware.com/guides/aspn ... ctive.html
- https://www.docuvieware.com/guides/aspn ... tions.html

Does one of these usages suits you or do you want to use the feature through the controller?

With best,
Fabio

Player1
Posts: 5
Joined: Fri Oct 01, 2021 5:35 am

Re: Redact RedactRequestCtx json?

Post by Player1 » Wed Oct 06, 2021 1:39 am

Hi Fabio,
Thank you for your prompt reply, and the links, I appreciate it. I had already turned on the snap-in, and it works nicely. That is fine for integrated redaction.

However I do very much want to use the controller handler and obtain the redact rectangles, as I will be processing these at a different stage of the PDF's lifetime.

I just am puzzled at the absence of info on RedactRequestCtx anywhere. I can't see that the stringJson argument includes the redact details?

If I had a full json example sample for the RedactRequest then (in the absence of a C# RedactRequest class) I could run the json through json2csharp.com converter and generate a C# class.

Thanks again,
Player1

User avatar
Fabio
Posts: 173
Joined: Thu Aug 27, 2020 9:57 am

Re: Redact RedactRequestCtx json?

Post by Fabio » Wed Oct 06, 2021 4:44 pm

Hello,

The redact Snap-in is the way to go since the redact controller was made for internal usage only.
By the way, you can use the PostCustomServerAction on the client-side, in order to get the document's annotations server-side. (Redaction are considered annotations while they're are not applied)

PostCustomServerAction: https://www.docuvieware.com/guides/aspn ... ction.html

You can get the properties of the redaction marks from the server and client-side.
Here are the methods to get it client-side through the javascript:
https://www.docuvieware.com/guides/aspn ... rties.html
https://www.docuvieware.com/guides/aspn ... notId.html

Here are the methods to get it server-side:
https://www.gdpicture.com/guides/gdpict ... nager.html
https://www.gdpicture.com/guides/gdpict ... mbers.html
https://www.gdpicture.com/guides/gdpict ... omIdx.html

Hope it helps!

With best,
Fabio

Player1
Posts: 5
Joined: Fri Oct 01, 2021 5:35 am

Re: Redact RedactRequestCtx json?

Post by Player1 » Mon Oct 11, 2021 9:33 am

Thanks for the help Fabio, redactions seem to be working now, as well as triggering the NewAnnotations handler. Knowing that redactions are just a form of annotation helped too :)
I still have two things to sort out - is there an equivalent of 'ApplyRedactions()' for annotations?
I have a number of annotations I've saved (ie. the json given to NewAnnotations()) and am loading them, but without an ApplyAnnotations they don't seem to appear.

Also am I able to hide the 'Apply All Redactions' button so there's only the 'Add Redaction Marks' button?
Thanks again!

User avatar
Fabio
Posts: 173
Joined: Thu Aug 27, 2020 9:57 am

Re: Redact RedactRequestCtx json?

Post by Fabio » Mon Oct 11, 2021 6:03 pm

Hi there!

My pleasure :)

The ApplyRedaction equivalent for the annotations is the "burn". When you burn the annotations on a page, it means they're not editable anymore, they are now part of the document itself.
Here are the different methods regarding the class you're using to manage the annotations:
- Burn method from DocuVieware: https://www.docuvieware.com/guides/aspn ... tions.html
- Burn method at the save step: https://www.docuvieware.com/guides/aspn ... sTIFF.html
- Burn from the AnnotationManager class: https://www.gdpicture.com/guides/gdpict ... oPage.html

If you saved the annotations (in an XMP/XML file I guess), you can load them thanks to the LoadAnnotations method: https://www.docuvieware.com/guides/aspn ... tions.html
You can also reload the annotation with this method: https://www.docuvieware.com/guides/aspn ... tions.html

If you want to hide a button from the snap-in, it's technically possible using JQuery, but it is not really a best practice using our SDK. The best thing to do is to create a new dedicated snap-in and inject HTML/JS within.
It's pretty simple, here is a code snippet I made (you need to add this code in DocuVieware's instance client-side):

Code: Select all

var icon1 = document.createElement("svg");
icon1.setAttribute("viewbox", "0 0 20 20");
icon1.setAttribute("height", "100%");
icon1.setAttribute("width", "100%");
icon1.innerHTML = "<path d='YOUR_SVG_ICON_CODE_HERE'></path>";

var panel1 = document.createElement("div");
panel1.style.padding = "10px";
panel1.innerHTML = "YOUR_HTML_CODE_TO_INJECT"; 

DocuViewareAPI.AddCustomSnapIn("DocuVieware1", "Custom redact panel", "Redact Panel", icon1, panel1, true, function () { });
Hope it helps!

With best,
Fabio

Player1
Posts: 5
Joined: Fri Oct 01, 2021 5:35 am

Re: Redact RedactRequestCtx json?

Post by Player1 » Thu Oct 14, 2021 2:40 am

Thanks again Fabio,
I've noticed that the online demo gives a context menu when I select some text. When I select text, I get the purple selected text but I don't get that menu so I'd like to enable it.
I've tried all the obvious-sounding 'Enable...' and '...Context...' and '...Menu' switches on the DocuViewareControl but none of them seem to enable.

I looked through the documentation but not sure of what else it may be called if 'context', 'menu' or 'button' aren't in the name?

It would be great for the online help to have a screenshot (or more than one) with all controls turned on, and the controls labelled as to what they are called, as a visual reference cue. If there is such a thing in the doc I have overlooked please let me know.

The context menu I'm looking for is simply this one (in larger red ellipse) that should appear when releasing mouse on select+drag text. I presume that will give me all the menu's buttons by default but if not, also the name of the redact button (small ellipse):

Image

Thanks again. I'm getting somewhere with this :)

Player1

User avatar
Fabio
Posts: 173
Joined: Thu Aug 27, 2020 9:57 am

Re: Redact RedactRequestCtx json?

Post by Fabio » Thu Oct 14, 2021 9:48 am

Hello Player1,

This menu is called the "context menu" and it is enabled by default in DocuVieware (it has been implemented in version 3.0.42).
Are you using the last version of our SDK?

Here is the code to enable the redaction (which is embedded within the EnableTextSelectionAnnotation property), and disable the copy and remove text items:

Code: Select all

docuVieware.EnableTextSelection = true;
docuVieware.EnableTextSelectionAnnotation = true;
docuVieware.EnableTextCopyMenuItem = false;
docuVieware.EnableRemoveTextItem = false;
By the way, if you want to have only the redaction feature, you need to set EnableTextSelectionAnnotation to false, and to add a new button with a custom redaction code-behind, using this method: https://www.docuvieware.com/guides/aspn ... uItem.html

Hope it helps!

With best,
Fabio

Player1
Posts: 5
Joined: Fri Oct 01, 2021 5:35 am

Re: Redact RedactRequestCtx json?

Post by Player1 » Fri Oct 22, 2021 8:34 am

Thank you Fabio,
I tried those lines with our version 3.1.0.68 version of GdPicture.NET.14.WEB.DocuVieware.Core.dll DocuViewareControl and only the EnableTextSelection and EnableSelectionAnnotation were valid properties, the last two not present in Intellisense or found in the metadata for 3.1.0.68.
But, still no context menu when selecting text? The Alt+ does function as a rubber-banding text selection, but same, no context menu.
I'm not sure what other modes I can turn on when instantiated in index.cshtml, I think I have tried them all :)

So, I downloaded the latest 3.1.135 SDK and ran the Core demos (as I had tried for our existing 3.1.0.68 version) so it would be faster to experiment rather than building and starting our app each time.
The Licence Manager says we have already got a commercial licence, so I left it at that, however I can't get our licence keys to work with the latest.

The RegisterKEY("...") returns a bool, just wondering if there is some means to get enum status explaining why the fail (eg. # of seats, expired licence, wrong checksum whatever)?

Thanks again, I appreciate your help,
Player1

User avatar
Fabio
Posts: 173
Joined: Thu Aug 27, 2020 9:57 am

Re: Redact RedactRequestCtx json?

Post by Fabio » Mon Oct 25, 2021 2:37 pm

Hi Player1!

For the license part, could you create a ticket on our helpdesk to talk privately about it, please?
Our Customer Success will handle this as soon as possible :)

Also, does your updated version fits your need regarding the context menu?

Have a nice day,
Fabio

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest