Skip to content

Commit a8e1fbd

Browse files
834573: updated comments
1 parent 2dc7168 commit a8e1fbd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

How to/Library Bounds to Viewer Bounds/src/app/app.component.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export class AppComponent implements OnInit {
5555
console.log(viewer.textSearch.findText(['pdf', 'adobe'], false, 7));
5656
}
5757

58+
// Event for AJAX request success
5859
handleAjaxRequestSuccess(args: any) {
5960
if (args.action === 'Load') {
6061
const objLength = Object.keys(args.data.pageSizes).length;
@@ -65,17 +66,24 @@ export class AppComponent implements OnInit {
6566
}
6667
}
6768

69+
// Event for export success
6870
handleExportSuccess(args: any) {
6971
const blobURL = args.exportData;
72+
// Converting the exported blob into object
7073
this.convertBlobURLToObject(blobURL)
7174
.then(objectData => {
7275
console.log(objectData);
7376
const shapeAnnotationData = objectData.pdfAnnotation[0].shapeAnnotation;
7477
shapeAnnotationData.forEach((data:any) => {
7578
if (data && data.rect && parseInt(data.rect.width)) {
7679
const pageHeight = this.pageSizes[parseInt(data.page)].Height;
80+
81+
// Converting PDF Library values into PDF Viewer values.
7782
const rect = {
7883
x: (parseInt(data.rect.x) * 96) / 72,
84+
85+
// Converting pageHeight from pixels(PDF Viewer) to points(PDF Library) for accurate positioning
86+
// The conversion factor of 72/96 is used to change pixel values to points
7987
y: (parseInt(pageHeight) * 72 / 96 - parseInt(data.rect.height)) * 96 / 72,
8088
width: (parseInt(data.rect.width) - parseInt(data.rect.x)) * 96 / 72,
8189
height: (parseInt(data.rect.height) - parseInt(data.rect.y)) * 96 / 72,
@@ -91,6 +99,7 @@ export class AppComponent implements OnInit {
9199
});
92100
}
93101

102+
// Function to convert Blob URL to object
94103
convertBlobURLToObject(blobURL: string): Promise<any> {
95104
return fetch(blobURL)
96105
.then(response => response.blob())

0 commit comments

Comments
 (0)