@@ -55,6 +55,7 @@ export class AppComponent implements OnInit {
55
55
console . log ( viewer . textSearch . findText ( [ 'pdf' , 'adobe' ] , false , 7 ) ) ;
56
56
}
57
57
58
+ // Event for AJAX request success
58
59
handleAjaxRequestSuccess ( args : any ) {
59
60
if ( args . action === 'Load' ) {
60
61
const objLength = Object . keys ( args . data . pageSizes ) . length ;
@@ -65,17 +66,24 @@ export class AppComponent implements OnInit {
65
66
}
66
67
}
67
68
69
+ // Event for export success
68
70
handleExportSuccess ( args : any ) {
69
71
const blobURL = args . exportData ;
72
+ // Converting the exported blob into object
70
73
this . convertBlobURLToObject ( blobURL )
71
74
. then ( objectData => {
72
75
console . log ( objectData ) ;
73
76
const shapeAnnotationData = objectData . pdfAnnotation [ 0 ] . shapeAnnotation ;
74
77
shapeAnnotationData . forEach ( ( data :any ) => {
75
78
if ( data && data . rect && parseInt ( data . rect . width ) ) {
76
79
const pageHeight = this . pageSizes [ parseInt ( data . page ) ] . Height ;
80
+
81
+ // Converting PDF Library values into PDF Viewer values.
77
82
const rect = {
78
83
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
79
87
y : ( parseInt ( pageHeight ) * 72 / 96 - parseInt ( data . rect . height ) ) * 96 / 72 ,
80
88
width : ( parseInt ( data . rect . width ) - parseInt ( data . rect . x ) ) * 96 / 72 ,
81
89
height : ( parseInt ( data . rect . height ) - parseInt ( data . rect . y ) ) * 96 / 72 ,
@@ -91,6 +99,7 @@ export class AppComponent implements OnInit {
91
99
} ) ;
92
100
}
93
101
102
+ // Function to convert Blob URL to object
94
103
convertBlobURLToObject ( blobURL : string ) : Promise < any > {
95
104
return fetch ( blobURL )
96
105
. then ( response => response . blob ( ) )
0 commit comments