mirror of
https://github.com/jzillmann/pdf-to-markdown.git
synced 2025-07-11 19:45:20 +02:00
30 lines
751 B
JavaScript
30 lines
751 B
JavaScript
import PageItem from './PageItem.jsx'
|
|
import Word from './Word.jsx'
|
|
|
|
//A line within a page
|
|
export default class LineItem extends PageItem {
|
|
|
|
constructor(options) {
|
|
super(options);
|
|
this.x = options.x;
|
|
this.y = options.y;
|
|
this.width = options.width;
|
|
this.height = options.height;
|
|
this.words = options.words || [];
|
|
if (options.text && !options.words) {
|
|
this.words = options.text.split(" ").filter(string => string.trim().length > 0).map(wordAsString => new Word({
|
|
string: wordAsString
|
|
}));
|
|
}
|
|
}
|
|
|
|
text() {
|
|
return this.wordStrings().join(" ");
|
|
}
|
|
|
|
wordStrings() {
|
|
return this.words.map(word => word.string);
|
|
}
|
|
|
|
}
|