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
Can i get any feedback on this please
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" }; |
Steps to remove the border:
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>
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
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
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
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
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 .
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