mirror of
https://github.com/jzillmann/pdf-to-markdown.git
synced 2024-11-25 09:13: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 = {
|
||||
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>
|
||||
<pre style={ textItem.annotation ? {
|
||||
color: textItem.annotation.color,
|
||||
display: 'inline-block',
|
||||
} : {
|
||||
display: 'inline-block'
|
||||
} }>{ textItem.text }</pre>
|
||||
{ showWhitespaces ? (
|
||||
<pre style={ textItem.annotation ? {
|
||||
color: textItem.annotation.color,
|
||||
display: 'inline-block',
|
||||
} : {
|
||||
display: 'inline-block'
|
||||
} }>{ textItem.text }</pre>
|
||||
) : (textItem.text) }
|
||||
</td>
|
||||
<td>
|
||||
{ textItem.x }
|
||||
|
@ -8,6 +8,7 @@ export default class RemoveWhitespaces extends ToPdfViewTransformation {
|
||||
|
||||
constructor() {
|
||||
super("Remove Whitespaces");
|
||||
this.showWhitespaces = true;
|
||||
}
|
||||
|
||||
transform(pages:PdfPage[]) {
|
||||
|
@ -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[]) {
|
||||
|
Loading…
Reference in New Issue
Block a user