Show pdf item text in pre only for the whitespace transformation

This commit is contained in:
Johannes Zillmann 2017-02-14 22:03:58 +01:00
parent 41bc2f6c34
commit c08105ecaf
3 changed files with 20 additions and 10 deletions

View File

@ -7,17 +7,19 @@ export default class PdfPageView extends React.Component {
static propTypes = {
pdfPage: React.PropTypes.object.isRequired,
modificationsOnly: React.PropTypes.bool.isRequired,
showWhitespaces: React.PropTypes.bool
};
render() {
const header = "Page " + (this.props.pdfPage.index + 1);
const {modificationsOnly, showWhitespaces} = this.props;
var textItems = this.props.pdfPage.textItems;
var content = <div/>
if (this.props.modificationsOnly) {
if (modificationsOnly) {
textItems = textItems.filter(item => item.annotation);
}
if (!this.props.modificationsOnly || textItems.length > 0) {
var content = <div/>
if (!modificationsOnly || textItems.length > 0) {
content = <div>
<h2>{ header }</h2>
<Table responsive>
@ -60,12 +62,14 @@ export default class PdfPageView extends React.Component {
</div>
</td>
<td>
{ showWhitespaces ? (
<pre style={ textItem.annotation ? {
color: textItem.annotation.color,
display: 'inline-block',
} : {
display: 'inline-block'
} }>{ textItem.text }</pre>
) : (textItem.text) }
</td>
<td>
{ textItem.x }

View File

@ -8,6 +8,7 @@ export default class RemoveWhitespaces extends ToPdfViewTransformation {
constructor() {
super("Remove Whitespaces");
this.showWhitespaces = true;
}
transform(pages:PdfPage[]) {

View File

@ -11,6 +11,7 @@ export default class ToPdfViewTransformation extends Transformation {
if (this.constructor === ToPdfViewTransformation) {
throw new TypeError("Can not construct abstract class.");
}
this.showWhitespaces = false;
}
showPageSelection() {
@ -22,7 +23,11 @@ export default class ToPdfViewTransformation extends Transformation {
}
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[]) {