mirror of
https://github.com/jzillmann/pdf-to-markdown.git
synced 2025-02-18 02:40:49 +01:00
Show pdf item text in pre only for the whitespace transformation
This commit is contained in:
parent
41bc2f6c34
commit
c08105ecaf
@ -7,17 +7,19 @@ export default class PdfPageView extends React.Component {
|
|||||||
static propTypes = {
|
static propTypes = {
|
||||||
pdfPage: React.PropTypes.object.isRequired,
|
pdfPage: React.PropTypes.object.isRequired,
|
||||||
modificationsOnly: React.PropTypes.bool.isRequired,
|
modificationsOnly: React.PropTypes.bool.isRequired,
|
||||||
|
showWhitespaces: React.PropTypes.bool
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const header = "Page " + (this.props.pdfPage.index + 1);
|
const header = "Page " + (this.props.pdfPage.index + 1);
|
||||||
|
const {modificationsOnly, showWhitespaces} = this.props;
|
||||||
var textItems = this.props.pdfPage.textItems;
|
var textItems = this.props.pdfPage.textItems;
|
||||||
var content = <div/>
|
if (modificationsOnly) {
|
||||||
if (this.props.modificationsOnly) {
|
|
||||||
textItems = textItems.filter(item => item.annotation);
|
textItems = textItems.filter(item => item.annotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.props.modificationsOnly || textItems.length > 0) {
|
var content = <div/>
|
||||||
|
if (!modificationsOnly || textItems.length > 0) {
|
||||||
content = <div>
|
content = <div>
|
||||||
<h2>{ header }</h2>
|
<h2>{ header }</h2>
|
||||||
<Table responsive>
|
<Table responsive>
|
||||||
@ -60,12 +62,14 @@ export default class PdfPageView extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre style={ textItem.annotation ? {
|
{ showWhitespaces ? (
|
||||||
color: textItem.annotation.color,
|
<pre style={ textItem.annotation ? {
|
||||||
display: 'inline-block',
|
color: textItem.annotation.color,
|
||||||
} : {
|
display: 'inline-block',
|
||||||
display: 'inline-block'
|
} : {
|
||||||
} }>{ textItem.text }</pre>
|
display: 'inline-block'
|
||||||
|
} }>{ textItem.text }</pre>
|
||||||
|
) : (textItem.text) }
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{ textItem.x }
|
{ textItem.x }
|
||||||
|
@ -8,6 +8,7 @@ export default class RemoveWhitespaces extends ToPdfViewTransformation {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super("Remove Whitespaces");
|
super("Remove Whitespaces");
|
||||||
|
this.showWhitespaces = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
transform(pages:PdfPage[]) {
|
transform(pages:PdfPage[]) {
|
||||||
|
@ -11,6 +11,7 @@ export default class ToPdfViewTransformation extends Transformation {
|
|||||||
if (this.constructor === ToPdfViewTransformation) {
|
if (this.constructor === ToPdfViewTransformation) {
|
||||||
throw new TypeError("Can not construct abstract class.");
|
throw new TypeError("Can not construct abstract class.");
|
||||||
}
|
}
|
||||||
|
this.showWhitespaces = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
showPageSelection() {
|
showPageSelection() {
|
||||||
@ -22,7 +23,11 @@ export default class ToPdfViewTransformation extends Transformation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createPageView(page, modificationsOnly) {
|
createPageView(page, modificationsOnly) {
|
||||||
return <PdfPageView key={ page.index } pdfPage={ page } modificationsOnly={ modificationsOnly } />;
|
return <PdfPageView
|
||||||
|
key={ page.index }
|
||||||
|
pdfPage={ page }
|
||||||
|
modificationsOnly={ modificationsOnly }
|
||||||
|
showWhitespaces={ this.showWhitespaces } />;
|
||||||
}
|
}
|
||||||
|
|
||||||
transform(pdfPages:PdfPage[]) {
|
transform(pdfPages:PdfPage[]) {
|
||||||
|
Loading…
Reference in New Issue
Block a user