@@ -22,6 +22,7 @@ class App extends React.Component {
22
22
this . viewerRef = React . createRef ( ) ;
23
23
}
24
24
25
+ // Event for AJAX request success
25
26
handleAjaxRequestSuccess = ( args ) => {
26
27
if ( args . action === 'Load' ) {
27
28
const objLength = Object . keys ( args . data . pageSizes ) . length ;
@@ -32,20 +33,26 @@ class App extends React.Component {
32
33
}
33
34
} ;
34
35
36
+ // Event for export success
35
37
handleExportSuccess = ( args ) => {
36
38
console . log ( args . exportData ) ;
37
39
const blobURL = args . exportData ;
38
40
41
+ // Converting the exported blob into object
39
42
this . convertBlobURLToObject ( blobURL )
40
43
. then ( ( objectData ) => {
41
44
console . log ( objectData ) ;
42
45
const shapeAnnotationData = objectData [ 'pdfAnnotation' ] [ 0 ] [ 'shapeAnnotation' ] ;
43
46
shapeAnnotationData . forEach ( ( data ) => {
44
47
if ( data && data . rect && parseInt ( data . rect . width ) ) {
45
48
const pageHeight = this . pageSizes [ parseInt ( data . page ) ] . Height ;
46
-
49
+
50
+ // Converting PDF Library values into PDF Viewer values.
47
51
const rect = {
48
52
x : ( parseInt ( data . rect . x ) * 96 ) / 72 ,
53
+
54
+ // Converting pageHeight from pixels(PDF Viewer) to points(PDF Library) for accurate positioning
55
+ // The conversion factor of 72/96 is used to change pixel values to points
49
56
y : ( parseInt ( pageHeight ) * 72 / 96 - parseInt ( data . rect . height ) ) * 96 / 72 ,
50
57
width : ( parseInt ( data . rect . width ) - parseInt ( data . rect . x ) ) * 96 / 72 ,
51
58
height : ( parseInt ( data . rect . height ) - parseInt ( data . rect . y ) ) * 96 / 72 ,
@@ -77,6 +84,7 @@ class App extends React.Component {
77
84
} ) ;
78
85
} ;
79
86
87
+ // Function to convert Blob URL to object
80
88
convertBlobURLToObject ( blobURL ) {
81
89
return fetch ( blobURL )
82
90
. then ( ( response ) => response . blob ( ) )
0 commit comments