How to get the co-ordinates of the selected text/lines in ng2-pdf-viewer.
Ashish0016 opened this issue · 0 comments
I want to perform redaction operation in the pdf for selected text/lines using an Aspose.pdf (.NET).
For redaction in the backend, I am using the below code
`Aspose.Pdf.Document doc = new Aspose.Pdf.Document(stream);
RedactionAnnotation annot = new RedactionAnnotation(doc.Pages[1], new Aspose.Pdf.Rectangle(200, 500, 300, 600));
annot.FillColor = Aspose.Pdf.Color.Black;
annot.BorderColor = Aspose.Pdf.Color.Yellow;
annot.Color = Aspose.Pdf.Color.Blue;
annot.TextAlignment = Aspose.Pdf.HorizontalAlignment.Center;
doc.Pages[1].Annotations.Add(annot);
annot.Redact();`
new Aspose.Pdf.Rectangle(200, 500, 300, 600) This requires the co-ordinates of selected text/line as rectangle.
Angular :-
`
<button color="accent" mat-icon-button matTooltip="Redact" (click)="redact()">
tab
<pdf-viewer [src]="fileUrl" [render-text]="true" [rotation]="rotation" [zoom]="zoom" [zoom-scale]="zoomScale"
[original-size]="false" [fit-to-page]="false" [page]="page" [show-all]="true" [autoresize]="false"
[show-borders]="false" (after-load-complete)="afterLoadComplete($event)" (error)="onError($event)"
(on-progress)="onProgress($event)"
#pdfViewer
(text-layer-rendered)="textLayerRendered($event)"
(page-rendered)="pageRendered($event)"
(mouseup)="selectedText()"
class="example-full-width pdfBorder" [style.height]="getWindowHeight * 0.1 + 'vh'">
By using mouseup event I am getting the selected text but I need help to get the co-ordinates of the selected text in the form of rectangle.
selectedText() {
console.log(getSelection().toString());
}
I wanted to send the co-ordinates in the form of this public Rectangle(double llx, double lly, double urx, double ury);