Skip to content

Commit d9c6d8f

Browse files
834573: updated comments
1 parent e656697 commit d9c6d8f

File tree

1 file changed

+9
-1
lines changed
  • How to/Library Bounds to Viewer Bounds/src

1 file changed

+9
-1
lines changed

How to/Library Bounds to Viewer Bounds/src/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class App extends React.Component {
2222
this.viewerRef = React.createRef();
2323
}
2424

25+
// Event for AJAX request success
2526
handleAjaxRequestSuccess = (args) => {
2627
if (args.action === 'Load') {
2728
const objLength = Object.keys(args.data.pageSizes).length;
@@ -32,20 +33,26 @@ class App extends React.Component {
3233
}
3334
};
3435

36+
// Event for export success
3537
handleExportSuccess = (args) => {
3638
console.log(args.exportData);
3739
const blobURL = args.exportData;
3840

41+
// Converting the exported blob into object
3942
this.convertBlobURLToObject(blobURL)
4043
.then((objectData) => {
4144
console.log(objectData);
4245
const shapeAnnotationData = objectData['pdfAnnotation'][0]['shapeAnnotation'];
4346
shapeAnnotationData.forEach((data) => {
4447
if (data && data.rect && parseInt(data.rect.width)) {
4548
const pageHeight = this.pageSizes[parseInt(data.page)].Height;
46-
49+
50+
// Converting PDF Library values into PDF Viewer values.
4751
const rect = {
4852
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
4956
y: (parseInt(pageHeight) * 72 / 96 - parseInt(data.rect.height)) * 96 / 72,
5057
width: (parseInt(data.rect.width) - parseInt(data.rect.x)) * 96 / 72,
5158
height: (parseInt(data.rect.height) - parseInt(data.rect.y)) * 96 / 72,
@@ -77,6 +84,7 @@ class App extends React.Component {
7784
});
7885
};
7986

87+
// Function to convert Blob URL to object
8088
convertBlobURLToObject(blobURL) {
8189
return fetch(blobURL)
8290
.then((response) => response.blob())

0 commit comments

Comments
 (0)