round y to not crush lines

This commit is contained in:
Johannes Zillmann 2017-01-06 10:07:06 +01:00
parent 7810d81792
commit 409e9a070f
3 changed files with 11 additions and 7 deletions

View File

@ -19,7 +19,6 @@
"url": "https://github.com/jzillmann/pdf-to-markdown"
},
"dependencies": {
"keen-ui": "^0.8.9",
"pdfjs-dist": "^1.6.317",
"vue": "^2.0.5",
"vue-material": "^0.3.3"

View File

@ -29,6 +29,8 @@ h1, h2 {
font-weight: normal;
}
textarea { font-size: 18px; }
ul {
list-style-type: none;
padding: 0;

View File

@ -28,20 +28,23 @@ export default {
var text = '';
var line;
var lineY;
// console.debug("Page " + rawPage.index + "-------");
rawPage.textItems.forEach(textItem => {
console.debug(textItem);
const yRounded = Math.round(textItem.y);
if (!line) {
// console.debug("First line: "+item.str);
lineY = textItem.y;
// console.debug("First line: " + textItem.text);
lineY = yRounded;
line = textItem.text;
} else {
if (textItem.y === lineY) {
//console.debug("Add to line: "+line +" / "+ item.str);
if (yRounded === lineY) {
// console.debug("Add to line: " + line + " / " + textItem.text);
line += textItem.text;
} else {
// console.debug("Start line: "+line+ " / " +item.str);
// console.debug("Start line: " + line + " / " + textItem.text);
text += line + '\n';
line = textItem.text;
lineY = textItem.y;
lineY = yRounded;
}
}
});