Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to preview PDF on Visual preview mode #325

Merged
merged 1 commit into from
Jun 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions app/ui/components/viewers/response-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, {PropTypes, PureComponent} from 'react';
import iconv from 'iconv-lite';
import autobind from 'autobind-decorator';
import {shell} from 'electron';
import {SimplePDF} from 'simple-react-pdf';
import CodeEditor from '../codemirror/code-editor';
import ResponseWebView from './response-webview';
import ResponseRaw from './response-raw';
Expand Down Expand Up @@ -151,6 +152,17 @@ class ResponseViewer extends PureComponent {
url={url}
/>
);
} else if (previewMode === PREVIEW_MODE_FRIENDLY && ct.indexOf('application/pdf') === 0) {
const justContentType = contentType.split(';')[0];
return (
<div className="scrollable-container tall wide">
<div className="scrollable">
<SimplePDF
file={`data:${justContentType};base64,${base64Body}`}
/>
</div>
</div>
);
} else if (previewMode === PREVIEW_MODE_RAW) {
const match = contentType.match(/charset=([\w-]+)/);
const charset = (match && match.length >= 2) ? match[1] : 'utf-8';
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
"redux": "3.3.1",
"redux-thunk": "2.0.1",
"reselect": "2.5.4",
"simple-react-pdf": "^1.0.8",
"srp-js": "0.2.0",
"tough-cookie": "2.3.1",
"uuid": "3.0.0",
Expand Down