You are viewing limited content. For full access, please sign in.

Question

Question

Redactions without Text

asked on May 12, 2015

Using SDK 9.2 RA.  I would like to redact a document that is an image only without text.  

Currently the users are able to use the Full Client UI to redact certain areas of scanned documents.

I am attempting to do the same action via C# code but the Laserfiche.RepositoryAccess.RedactionAnnotation object does not seem to allow a direct placement of the redaction.

The position / size are static.

Is there any way to add a Redaction using C# RA to an image without any text associated with the image, if so is there an working example that can be reviewed?

0 0

Answer

SELECTED ANSWER
replied on May 12, 2015

See your SDK documentation for LFRectangle and examples on annotating documents through RA.

PageInfo pInfo = Document.GetPageInfo(ENTRYID,PAGENUMBER, RASession);
RedactionAnnotation ann = new RedactionAnnotation();
List< Laserfiche.RepositoryAccess.Common.LfRectangle> listofcoords = new List<Laserfiche.RepositoryAccess.Common.LfRectangle>();
Laserfiche.RepositoryAccess.Common.LfRectangle rectangle = new Laserfiche.RepositoryAccess.Common.LfRectangle();
rectangle.X = 400;
rectangle.Y = 400;
rectangle.Width = 800;
rectangle.Height = 800;
listofcoords.Add(rectangle);
ann.ImageRectangles = listofcoords;
pInfo.AddAnnotation(ann);

 

0 0

Replies

replied on May 12, 2015

I believe from what you are saying is that the part you want redacted may be in different spot of the document? If that is the case, then you would have to have text associated with it in order to find what you want redacted. If the place on the document is static then you can program in the location of the area.

0 0
replied on May 12, 2015

Yes, the locations are static.  The document is imported as an image, so there is no text or electronic document associated with the record.

With the RectangleAnnotation I am able to place an annotation on the document,  So I am capable of placing ojects on the image.  It would be preferred if the RedactionAnnotation class was used.  

The issue I am having is that I cannot place the RedactionAnnotation object on the image where I want (or I am unsure how to).

0 0
replied on May 12, 2015

Ok, this is possible to do, At a Laserfiche VAR that I used to work for we had an activity that allowed you to set a redaction by the coordinates on the document. We even had a small program that would tell us what those cords were. Unfortunately I am not a script writer and do not know how our programmer programmed it. At least you know it is possible. I would talk to your VAR, they may have someone that is able to do that kind of programming for you.  

0 0
replied on May 12, 2015

I think what you're missing is that a RedactionAnnotation doesn't have a single position, it has a collection of rectangles that each has a position.  Assign your list of redaction segments to the the ImageRectangles property.

0 0
replied on May 13, 2015

It appears this worked.  I did try it a variation of it first but it did not work.  I thought there needed to be text based on the example.

// Retrieve the first page of a document.
PageInfo pInfo = Document.GetPageInfo(47, 1, mySess);
// Create a highlight annotation object.
HighlightAnnotation ann = new HighlightAnnotation();
List&lt;LfRectangle&gt; listofcoords = new List&lt;LfRectangle&gt;();
LfRectangle rectangle = new LfRectangle();
rectangle.X = 400;
rectangle.Y = 400;
rectangle.Width = 800;
rectangle.Height = 800;
listofcoords.Add(rectangle);
ann.ImageRectangles = listofcoords;
// The TextLinker class can help you determine the appropriate
// text range for a given image rectangle
TextLinker textLinker = new TextLinker(pInfo.ReadTextPagePartAsWords(), pInfo.ReadLocationsPagePart());
IList&lt;TextRange&gt; texthighlightrange = textLinker.GetTextRanges(rectangle);
TextRange tRange = texthighlightrange[0]; // We only have 1 rectangle
// Set the text range for the highlight.
ann.TextStart = tRange.StartPosition;
ann.TextEnd = tRange.EndPosition;
ann.Color = Laserfiche.RepositoryAccess.Common.LfColor.FromAbgr(65535); // Yellow highlight
pInfo.AddAnnotation(ann);
0 0
replied on May 13, 2015

Yes, that's if you want to link to the text. That's exactly the example i used for my code sample above and took out the lines that were trying to link the image redaction to the page text.

0 0
replied on May 13, 2015 Show version history

I noticed that, I should of tried it but was weary due to the notification that appears in the UI about linking to text.

Anyway, thanks for your help.  

Also, the height and width of the annotation can be discovered by making the annotation and using the following query on the LF database to find the values needed for the annotation/redaction.

SELECT DOC.tocid
        , DOC.page_id
        , DOC.pagenum + 1 AS pagenum --people like 1 to be first page
        , REC.x1
        , REC.y1
        , REC.x2 - REC.x1 AS width
        , ABS(REC.y1 - REC.y2) AS height
  FROM [dbo].[doc] AS DOC
    LEFT JOIN [dbo].[ann] AS ANN
        ON DOC.page_id = ANN.page_id
    LEFT JOIN [dbo].[annrect] AS REC
        ON ANN.ann_id = REC.ann_id
  
  WHERE tocid = <enter tocid/entryID here>

 

Thanks again!

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.