Skip to content

Commit 520eeab

Browse files
committed
PDF export
1 parent 8ecb43f commit 520eeab

File tree

6 files changed

+77
-24
lines changed

6 files changed

+77
-24
lines changed

README.markdown

+13-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ Building the dist version of the project is as easy as running `npm run build`
1515

1616
If you want to deploy the slideshow to surge, run `npm run deploy`
1717

18+
## PDF Export
19+
20+
Exporting a totally sweet looking PDF from your totally sweet looking Spectacle presentation is asburdly easy.
21+
22+
- Run `npm start`
23+
- Hit [http://localhost:3000/#/?export](http://localhost:3000/#/?export)
24+
- Bring up the print dialog `(ctrl or cmd + p)`
25+
- Check "Background Graphics" to on if you are about that life
26+
- Change destination to "Save as PDF", as shown below:
27+
28+
![http://i.imgur.com/t6GL5Oc.png](http://i.imgur.com/t6GL5Oc.png)
29+
1830
## Basic Concepts
1931

2032
### Main file
@@ -268,7 +280,7 @@ Every component above that has `(Base)` after it has been extended from a common
268280
| bold | React.PropTypes.boolean | Set `fontWeight` to `bold ` |
269281
| caps | React.PropTypes.boolean | Set `textTransform` to `uppercase ` |
270282
| margin | React.PropTypes.number or string | Set `margin` value|
271-
| padding | React.PropTypes.number or string | Set `padding` value|
283+
| padding | React.PropTypes.number or string | Set `padding` value|
272284
| textColor | React.PropTypes.string | Set `color` value|
273285
| textSize | React.PropTypes.string | Set `fontSize` value|
274286
| textAlign | React.PropTypes.string | Set `textAlign` value|

dist/spectacle.0.0.1.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/spectacle.0.0.1.js

+15-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/appear.jsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,15 @@ const Appear = React.createClass({
4040
this.setState({
4141
active: state.fragments[slide][key].visible
4242
}, () => {
43+
let endVal = this.state.active ? 1 : 0;
44+
if (this.context.router.state.location.query &&
45+
'export' in this.context.router.state.location.query) {
46+
endVal = 1;
47+
}
4348
this.tweenState('opacity', {
4449
easing: tweenState.easingTypes.easeInOutQuad,
4550
duration: 300,
46-
endValue: this.state.active ? 1 : 0
51+
endValue: endVal
4752
});
4853
});
4954
}

src/deck.jsx

+36-5
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,23 @@ class Deck extends React.Component {
186186
let slide = 'slide' in this.context.router.state.params ?
187187
parseInt(this.context.router.state.params.slide) : 0;
188188
let child = this.props.children[slide];
189-
return cloneWithProps(
190-
child,
191-
{
189+
if (this.context.router.state.location.query &&
190+
'export' in this.context.router.state.location.query) {
191+
return this.props.children.map((child, index) => {
192+
return cloneWithProps(child, {
193+
key: index,
194+
slideIndex: slide,
195+
lastSlide: this.state.lastSlide,
196+
transition: child.props.transition.length ?
197+
child.props.transition :
198+
this.props.transition,
199+
transitionDuration: child.props.transition.transitionDuration ?
200+
child.props.transitionDuration :
201+
this.props.transitionDuration
202+
});
203+
});
204+
} else {
205+
return cloneWithProps(child, {
192206
key: slide,
193207
slideIndex: slide,
194208
lastSlide: this.state.lastSlide,
@@ -199,8 +213,24 @@ class Deck extends React.Component {
199213
child.props.transitionDuration :
200214
this.props.transitionDuration
201215
});
216+
}
202217
}
203218
render() {
219+
let exportMode = false;
220+
221+
if (this.context.router.state.location.query &&
222+
'export' in this.context.router.state.location.query) {
223+
exportMode = true;
224+
}
225+
226+
let globals = exportMode ? {
227+
body: {
228+
minWidth: 1100,
229+
minHeight: 850,
230+
overflow: 'auto'
231+
}
232+
} : {};
233+
204234
let styles = {
205235
position: 'absolute',
206236
top: 0,
@@ -210,16 +240,17 @@ class Deck extends React.Component {
210240
perspective: 1000,
211241
transformStyle: 'preserve-3d'
212242
};
243+
213244
return (
214245
<div
215246
className="spectacle-deck"
216247
style={[styles]}
217248
onClick={this._handleClick}
218249
{...this._getTouchEvents()}>
219-
<TransitionGroup component="div">
250+
<TransitionGroup component="div" style={{height: '100%'}}>
220251
{this._renderSlide()}
221252
</TransitionGroup>
222-
<Style rules={this.context.styles.global} />
253+
<Style rules={assign(this.context.styles.global, globals)} />
223254
</div>
224255
)
225256
}

src/slide.jsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,14 @@ const Slide = React.createClass({
3232
window.removeEventListener('resize', this.setZoom);
3333
},
3434
render() {
35+
let exportMode = false;
36+
if (this.context.router.state.location.query &&
37+
'export' in this.context.router.state.location.query) {
38+
exportMode = true;
39+
}
3540
let styles = {
3641
outer: {
37-
position: 'absolute',
42+
position: exportMode ? 'relative' : 'absolute',
3843
top: 0,
3944
left: 0,
4045
width: '100%',

0 commit comments

Comments
 (0)