Files
pdf-to-markdown/src/javascript/models/transformations/RoundCoordinates.jsx
2017-01-29 16:05:26 +01:00

32 lines
874 B
JavaScript

import Transformation from './Transformation.jsx';
import PdfPage from '../PdfPage.jsx';
import ContentView from '../ContentView.jsx';
export default class RoundCoordinates extends Transformation {
constructor() {
super("Round Coordinates");
}
contentView() {
return ContentView.PDF;
}
transform(pdfPages:PdfPage[]) {
return pdfPages.map(pdfPage => {
return {
...pdfPage,
textItems: pdfPage.textItems.map(textItem => {
return {
...textItem,
x: Math.round(textItem.x),
y: Math.round(textItem.y),
width: Math.round(textItem.width),
height: Math.round(textItem.height)
}
})
};
});
}
}