PDF VIewer with PDF Redaction

Hi,

Is there is a way in which I could use PDFViewer to mark certain areas in the PDF and call the backend server to redact those areas and save PDF? 

Regards,

Sri


9 Replies 1 reply marked as answer

CK Chinnamunia Karthik Chinna Thambi Syncfusion Team February 19, 2024 10:21 AM UTC

Hi Sri Nistala,


Currently, there is no support for redaction at the UI level using the PDF Viewer. However, As a workaround, you can add the redaction for text content using the PDF library. We have provided the sample and steps below for your reference.


Javascript sample:   https://stackblitz.com/edit/ankkds-m4l6ug?file=index.html,index.js


Web service sample:   https://www.syncfusion.com/downloads/support/directtrac/general/ze/Redaction_24.2.6-1895587801.zip


Steps to Redact:


  • Run the web service sample.
  • And then run the Javascript sample.
  • Click the Add Rectangle Annotation button. Select the areas you need to redact.
  • Click the Redact button. The PDF document is now redacted using PDF Library.
  • Additionally, we have reloaded the updated PDF in the PDF Viewer using the "viewer.load()" method.


SN Sri Nistala February 20, 2024 12:52 PM UTC

Thank you. I will try this approach. 



CK Chinnamunia Karthik Chinna Thambi Syncfusion Team February 21, 2024 11:16 AM UTC

Hi Sri Nistala,

Thanks for the update. Kindly try this and
let us know if you have any concerns.



SN Sri Nistala March 12, 2024 11:42 AM UTC

Hi, the example you have shared is using server side rendering, do you have an example that works with client side rendering ? 



JM Johnson Monohar M Syncfusion Team March 13, 2024 05:06 AM UTC

Hi Sri Nistala,


Sorry, there is no direct support for this at the client-side. And so, we are recommending the server-backed PDF Viewer to achieve the redaction.  



SN Sri Nistala March 13, 2024 07:52 AM UTC

Hi,


I have managed to get this working. I followed your approach to capture the annotation and get the bounds of the annotation. I sent the annotation to the server for redaction and it successfully redacted the areas as well. All of this was on my local PC (windows). When I deployed this into Azure App service (linux), it failed with Skiasharp missing dll while doing redaction. I have followed the documentation to add - SkiaSharp.NativeAssets.Linux and HarpBuzzSharp nuget packages. After I have added them, the Redaction areas are being offset and also increasing in height and width as shown in the below screenshot. Is the Annotation bounds selected in the pdfViewer and Redaction process different? 


Image_9865_1710316321405



CK Chinnamunia Karthik Chinna Thambi Syncfusion Team March 14, 2024 01:31 PM UTC

Hi Sri Nistala,

We have tried the reported issue in Azure app service Linux but we were unable to reproduce the issue. We have shared the sample in which we have tried to reproduce the issue in the below link, along with a video recording for your reference.


Javascript sample: https://stackblitz.com/edit/ankkds-jg6xwr?file=index.html,index.js


Web service sample:  https://www.syncfusion.com/downloads/support/directtrac/general/ze/RedactionLinux1617034645.zip


Hosted link:  https://webservicepdfviewer.azurewebsites.net/pdfviewer


Video:  https://www.syncfusion.com/downloads/support/directtrac/general/ze/RedactionLinuxVideo-2052905474.zip


Note: If you are deploying the application in Linux environment, we recommended to use the "Syncfusion.EJ2.PdfViewer.AspNet.Core" which is compatible with Windows, Linux and OSX platforms.


The bound values obtained from the PDF Viewer are in pixels, whereas the bound values used in the Redaction are in points. Therefore, if you are getting the bound values from the PDF Viewer, you need to convert them to points before adding the redaction. We have provided code snippet to convert the pixel to point and point to pixel.


 

private ConvertPixelToPoint = function (number) {

    return (number * (72 / 96));

};

     

private ConvertPointToPixel = function (number) {

    return (number * (96 / 72));

};


Try this sample and revert to us with a modified sample, code snippet and more details about the reported issue if you have any concerns. This will be helpful for us to analyze further and provide the details.


Marked as answer

SN Sri Nistala March 14, 2024 09:07 PM UTC

Thanks a ton Karthik, it worked like a charm. You've saved my day. 


Problem was the the PixelToPoint conversion, however, I followed your approach to loop through the Annotations directly on server and Redact them rather than depending on the conversions from PixelToPoint.  



CK Chinnamunia Karthik Chinna Thambi Syncfusion Team March 15, 2024 10:23 AM UTC

Hi Sri Nistala,

We are glad to know that the reported issue was resolved on your end. So, we are closing this ticket.


Loader.
Up arrow icon