We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Redact XFA Form Field inside PDF using Aspose.PDF for .NET

Hello All,


I tried to black out an XFORM using the following operator:

var current = enumerator.Current as XForm;
current.Contents.Add(new Operator.SetRGBColor(System.Drawing.Color.Black));
current.Contents.Add(new Operator.Do());
current.Contents.Add(new Operator.GRestore());

This just seems to make the xform disappear on the PDF. What am I doing wrong?

Hi Jonathan,


Thank you for contacting support. Kindly send us the complete details of your test case, including input PDF document, code and the version number of Aspose.Pdf for .NET API. It will help us to investigate the root cause, and we will share our findings with you. Your response is awaited.

Hi Jonathan,


Thanks for contacting support.

Adding more to Imran’s comments, do you need to redact certain region inside XForm ?

If so is the case, then please note that Aspose.Pdf for .NET supports the feature to redact certain page region and in case you need to perform some manipulation on XFA form, you need to first Convert Dynamic XFA Form to Standard AcroForm and then .Redact certain page region with RedactionAnnotation

I basically just need to black out the xform so that user cannot see it. Whether it’s changing the color via operator or drawing a black rectangle around it.


Yesterday I tried to get the Operator.ConcatenateMatrix from the Contents, to try to gather some positioning information, this didn’t work.

Operator.ConcatenateMatrix opCtm = form.Contents.Cast().ToList().Where(o => o as Operator.ConcatenateMatrix != null).First() as Operator.ConcatenateMatrix;

We cannot send our pdfs they contain sensitive customer information, thanks!

Hi Jonathan,


Thanks for sharing the details.

As per your requirements, you may consider redacting certain page region by following instructions specified in earlier shared link. Now concerning to sharing the document, I have marked this forum thread as private so that the contents shared in this thread are only accessible to Aspose staff and documents shared by our customers are only used for testing purposes and once a particular issue is resolved, they are removed.

Furthermore, in case you are not comfortable sharing the document, you may consider directly sending us the document by following the instructions specified over How to send a license?

Redact may work, I discovered something today while debugging again. I noticed that the what we need to ‘black out’ is an ximage within the xform. I see the width and height for the ximage but how can i obtain the position? Thanks in advance.





Is there a way to obtain the position of the ximage from the contents collection? Maybe using operators? Please advise.

jcunanan:
Redact may work, I discovered something today while debugging again. I noticed that the what we need to ‘black out’ is an ximage within the xform. I see the width and height for the ximage but how can i obtain the position? Thanks in advance.

Is there a way to obtain the position of the ximage from the contents collection? Maybe using operators? Please advise.

Hi Jonathan,


Thanks for sharing the details.

In order to get information regarding image position, please try using Rectangle.LLX and Rectangle.LLY properties of ImagePlacement object. For further details, please visit


Furthermore, in order to redact certain image, you may search particular image and Replace Image in Existing PDF File.

Nayyer you did it! This was the solution that worked for me on one of our docs. Thanks again! You can make this public for anyone that may need to do a similar thing.



Now testing it on a different document. The redact seems to shift text around. Is there a way to tell it not to?



EDIT: I ended up just making the redactionannotation smaller than the actual image by about 4 pixels like below:



// Create RedactionAnnotation instance for specific page region

RedactionAnnotation annot = new RedactionAnnotation(page, new Aspose.Pdf.Rectangle(imagePlacement.Rectangle.LLX, imagePlacement.Rectangle.LLY + 4, imagePlacement.Rectangle.URX - 4, imagePlacement.Rectangle.URY - 4));



Thanks, Jon

Hi Jon,


Thanks for sharing the details.

We are glad to hear that your requirement has been accomplished. Please continue using our API and in the event of any further query, please feel free to contact.

Please note that the thread is already marked public, so anyone can take benefit of related discussion.