how can i remove border around annotations

i want to get rid of these red borders from the annotation.. or I simply want to open the PDF in reading mode as It looks like in any PDF viewer, with no borders around annotations 


Image_9661_1701657740204


9 Replies

AA Adnan Ali December 5, 2023 10:41 AM UTC

Can i get any feedback on this please 



CK Chinnamunia Karthik Chinna Thambi Syncfusion Team December 6, 2023 10:38 AM UTC

To remove the border for the newly added annotations, you need to set the StrokeColor as transparent in the PdfViewerRectangleSettings. We have provided the code snippet and sample for this functionality.


Code snippet:


 

<SfPdfViewerServer @ref="@viewer"

    DocumentPath="@DocumentPath" Height="640px" Width="100%" RectangleSettings="@RectangleSettings">

    <PdfViewerEvents ></PdfViewerEvents>

</SfPdfViewerServer>

 

PdfViewerRectangleSettings RectangleSettings = new PdfViewerRectangleSettings()

{

    StrokeColor ="transparent"

};


Sample:  https://www.syncfusion.com/downloads/support/directtrac/general/ze/RemoveBorderColorBlazor696932127.zip


Steps to remove the border:


  • Run the sample.
  • Add the rectangle annotation. Now, the border is in transparent.


AA Adnan Ali December 7, 2023 11:15 AM UTC

Annotations are already added but they are without borders, but when i open that pdf in the pdf viewer with these settings a border is still attached to the annotations,. i added the isLock="true" to disable user interaction but i don't want to show the border. and i want to show the annotations and pdf just the way it is opening up in any pdf viewer or browser.

<SfPdfViewer EnableRtl="true" RectangleSettings="@RectangleSettings" EnablePrintRotation="true" EnableToolbar="true" EnableAnnotation="true" @ref="@PDFViewer" DocumentPath="@Session.Path" Height="800px" ZoomValue="150" ServiceUrl="api/PdfViewer">

     <PdfViewerAnnotationSettings IsLock="true"></PdfViewerAnnotationSettings>

     <PdfViewerAnnotationSelectorSettings SelectionBorderColor="white" ResizerBorderColor="white"></PdfViewerAnnotationSelectorSettings>

</SfPdfViewer>



SK Sinthiya Kalimuthu Syncfusion Team December 12, 2023 11:53 AM UTC

Hi Adnan Ali,


We were able to reproduce the reported issue “RectangleSetting property is not working properly” and suspect this to be a defect. We will analyze further on this and update you with more details on Dec 14, 2023.


Regards,

Sinthiya K



SK Sinthiya Kalimuthu Syncfusion Team December 14, 2023 02:05 PM UTC

Hi Adnan Ali,

Currently, we do not have support for removing the border color of the rectangle when loading a document containing rectangle annotations. However, you can fulfill this requirement by utilizing the Syncfusion library packages.

When you create a document, you can remove the border of the rectangle annotation. Then, you can load it again using the PDF viewer

We have provided a code snippet and a sample for your reference. Please review it, and feel free to reach out if you have any concerns.


Code Snippet:

public PdfViewerRectangleSettings RectangleSettings = new PdfViewerRectangleSettings()

{

    StrokeColor = "transparent"

};

 

public async Task CreateDocument()

{

    Stream stream = new MemoryStream();

    httpClients.BaseAddress = new Uri(navigationManagerURI.Uri);

    HttpResponseMessage response = await httpClients.GetAsync("data/Single.pdf");

    if (response.IsSuccessStatusCode)

    {

        await response.Content.CopyToAsync(stream);

        // Reset the stream position to the beginning

        stream.Position = 0;

    }

    MemoryStream newStream = new MemoryStream();

    // load the PDF document.

    PdfLoadedDocument ldoc = new PdfLoadedDocument(stream);

    // get the first page from the document.

    foreach (Syncfusion.Pdf.Interactive.PdfAnnotation annot in ldoc.Pages[0].Annotations)

    {

        // set the border.

        annot.Border = new PdfAnnotationBorder(0, 0, 0);

        // set the opacity.

        annot.Opacity = 0;

    }

    // save the PDF document.

    ldoc.Save(newStream);

    // close the PDF document.

    ldoc.Close(true);

    // reset the stream position.

    newStream.Position = 0;

    // load the PDF document into PDF viewer control.

    await PDFViewer.LoadAsync(newStream);

}


Sample - https://www.syncfusion.com/downloads/support/directtrac/general/ze/HideAnnotation-1468616409.zip


Thanks,

Sinthiya K



AA Adnan Ali December 23, 2023 01:27 PM UTC

I am using the Blazor Server web app and all the controls are being loaded from a api controller, 

I created this pdf viewer using the help provided in this forum request. link is given below 

https://www.syncfusion.com/forums/180038/pdf-viewer-does-not-load-pdf-in-a-dialog-it-keeps-loading

I have attached a file that i used to create the pdf controller. I tried to implement the solution provided above but  the pdf still loads with the border attached around annotations. Here is the sample code 

Image_8374_1703338057642


Attachment: Web_Service_URL_e9adce9b_ac181f2c.zip


SK Sathiyaseelan Kannigaraj Syncfusion Team December 26, 2023 12:27 PM UTC

Hi Adnan Ali,

Rather than placing the code inside the ImportAnnotations method, insert it into the Load() method before loading the document into the viewer. We've included a code snippet and a sample of the web service for reference.

Code Snippet:

MemoryStream newStream = new MemoryStream();

PdfLoadedDocument ldoc = new PdfLoadedDocument(stream);

// get the first page from the document.

foreach (Syncfusion.Pdf.Interactive.PdfAnnotation annot in ldoc.Pages[0].Annotations)

{

    // set the border.

    annot.Border = new PdfAnnotationBorder(0, 0, 0);

    // set the opacity.

    annot.Opacity = 0;

}

// save the PDF document.

ldoc.Save(newStream);

// close the PDF document.

ldoc.Close(true);

// reset the stream position.

newStream.Position = 0;

jsonResult = pdfviewer.Load(newStream, jsonObject);

return Content(JsonConvert.SerializeObject(jsonResult));


Sample - https://www.syncfusion.com/downloads/support/directtrac/general/ze/PDFViewerWebService340667945.zip

Regards,

Sathiyaseelan



AA Adnan Ali February 11, 2024 01:29 PM UTC

I am still unable to remove or hide borders around annotations 

I switched to Server app and here are the code snippets I am using .

Image_6878_1707657946681


Image_4793_1707658067272




SK Sathiyaseelan Kannigaraj Syncfusion Team February 13, 2024 01:13 PM UTC

Hi Adnan Ali,

We have tested the scenario, but the issue did not reproduce in the server component, the rectangle border is also hidden as expected. We have provided the sample below. If you are still experiencing any issues, please share a sample or demo video to help identify the problem.
 
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/BlazorServer1113008115.zip


Regards,
Sathiyaseelan 


Loader.
Up arrow icon