Skip to content

Commit 4c8cb72

Browse files
committed
Fix up issues when accessing from file://
1 parent 816a33a commit 4c8cb72

3 files changed

Lines changed: 160 additions & 134 deletions

File tree

examples/js/editor.js

Lines changed: 23 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/js/user-input.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ for(var i = 1; i <= 12; i ++) {
2222

2323
// You wouldn't normally call this - this is just to make the
2424
// demo not look broken as we've disabled auto update.
25-
jsPDFEditor.update(true);
25+
if (jsPDFEditor !== undefined) {
26+
jsPDFEditor.update(true);
27+
}

index.html

Lines changed: 134 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -8,174 +8,176 @@
88
<meta name="description" content="">
99
<meta name="author" content="">
1010

11-
<!-- Bootstrap -->
11+
<!-- Bootstrap -->
1212
<link href="./examples/bootstrap/css/bootstrap.css" rel="stylesheet">
1313
<link href="./examples/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
1414

15-
<!-- Editor CSS -->
16-
<link href="./examples/css/editor.css" rel="stylesheet">
15+
<!-- Editor CSS -->
16+
<link href="./examples/css/editor.css" rel="stylesheet">
1717

18-
<!-- See closing body for JS -->
18+
<!-- See closing body for JS -->
1919

20-
<script src="http://use.edgefonts.net/source-code-pro.js"></script>
20+
<script src="http://use.edgefonts.net/source-code-pro.js"></script>
2121
</head>
2222

2323
<body>
2424
<div class="container">
2525

26-
<div class="masthead">
27-
<div class="pull-right">
28-
<div class="tweet-buttons">
29-
<a href="https://twitter.com/share" class="twitter-share-button" data-via="MrRio" data-size="large">Tweet</a>
30-
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
31-
<a href="https://twitter.com/MrRio" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @MrRio</a>
32-
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
33-
</div>
34-
<a class="btn btn-primary btn-large" href="https://github.com/MrRio/jsPDF/zipball/master">Download Now</a>
35-
<p class="muted" style="text-align: right;">Version 0.9.0rc1</p>
26+
<div class="masthead">
27+
<div class="pull-right">
28+
<div class="tweet-buttons">
29+
<a href="https://twitter.com/share" class="twitter-share-button" data-via="MrRio" data-size="large">Tweet</a>
30+
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
31+
<a href="https://twitter.com/MrRio" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @MrRio</a>
32+
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
33+
</div>
34+
<a class="btn btn-primary btn-large" href="https://github.com/MrRio/jsPDF/zipball/master">Download Now</a>
35+
<p class="muted" style="text-align: right;">Version 0.9.0rc1</p>
3636

37-
</div>
38-
<h1 class="muted">jsPDF</h1>
39-
<h4>HTML5 JavaScript PDF generation library from <a href="http://twitter.com/MrRio">@MrRio</a></h4>
40-
</div>
41-
42-
<div class="row-fluid">
43-
<div class="span6" style="float: right">
44-
<iframe class="preview-pane" width="100%" height="650" frameborder="0"></iframe>
45-
</div>
46-
<div class="span5 no-gutter">
37+
</div>
38+
<h1 class="muted">jsPDF</h1>
39+
<h4>HTML5 JavaScript PDF generation library from <a href="http://twitter.com/MrRio">@MrRio</a></h4>
40+
</div>
41+
42+
<div class="row-fluid">
43+
<div class="span6" style="float: right">
44+
<iframe class="preview-pane" width="100%" height="650" frameborder="0"></iframe>
45+
</div>
46+
<div class="span5 no-gutter">
4747

48-
<h2>Have a play.</h2>
48+
<h2>Have a play.</h2>
4949

50-
<p>A HTML5 client-side solution for generating PDFs. Perfect for event tickets, reports, certificates, you name it! </p>
50+
<p>A HTML5 client-side solution for generating PDFs. Perfect for event tickets, reports, certificates, you name it! </p>
5151

52-
<p>No servers were used or harmed in this demo.</p>
52+
<p><b>No servers were used in the making of this demo.</b></p>
53+
54+
<div class="template-picker">
55+
<label for="template">Choose example</label>
56+
<select id="template" name="template">
57+
<option>Hold your horses...</option>
58+
</select>
59+
</div>
60+
</div>
5361

54-
<label for="template">Choose example</label>
55-
<select id="template" name="template">
56-
<option>Hold your horses...</option>
57-
</select>
58-
</div>
62+
<div id="editor" class="bypass"></div>
63+
64+
<div class="controls">
65+
<div class="pull-right">
66+
<a href="#" class="btn btn-primary">Download Your Code</a>
67+
<a href="#" class="btn btn-primary download-pdf">Download PDF</a>
68+
</div>
5969

60-
<div id="editor" class="bypass"></div>
61-
62-
<div class="controls">
63-
<div class="pull-right">
64-
<a href="#" class="btn btn-primary">Download Your Code</a>
65-
<a href="#" class="btn btn-primary download-pdf">Download PDF</a>
66-
</div>
70+
<label class="checkbox">
71+
<input type="checkbox" id="auto-refresh" checked="checked"> Auto refresh on changes?
72+
</label>
73+
<a href="#" class="run-code hide btn btn-success">Run Code</a>
6774

68-
<label class="checkbox">
69-
<input type="checkbox" id="auto-refresh" checked="checked"> Auto refresh on changes?
70-
</label>
71-
<a href="#" class="run-code hide btn btn-success">Run Code</a>
75+
<div class="alert hide">
76+
Auto refresh disabled for this
77+
</div>
7278

73-
<div class="alert hide">
74-
Auto refresh is turned off for this example
75-
</div>
79+
</div>
7680

77-
</div>
81+
</div>
82+
<div class="clerfix"></div>
83+
<div class="span12 credits">
7884

79-
</div>
80-
<div class="clerfix"></div>
81-
<div class="span12 credits">
85+
<h2>The Basics</h2>
8286

83-
<h2>The Basics</h2>
87+
<p>Simply include the jsPDF library in your <span class="source">&lt;head&gt;</span>, generate your PDF using the <i>many</i> built-in functions, then hook up a button to trigger the download. All the examples here use jQuery.</p>
8488

85-
<p>Simply include the jsPDF library in your <span class="source">&lt;head&gt;</span>, generate your PDF using the <i>many</i> built-in functions, then hook up a button to trigger the download. All the examples here use jQuery.</p>
89+
<h2>Credits</h2>
8690

87-
<h2>Credits</h2>
91+
<p>Big thanks to Daniel Dotsenko from <a href="http://willow-systems.com">Willow Systems Corporation</a> for making huge contributions to the codebase. </p>
8892

89-
<p>Big thanks to Daniel Dotsenko from <a href="http://willow-systems.com">Willow Systems Corporation</a> for making huge contributions to the codebase. </p>
93+
<p>Thanks to Ajaxian.com for <a href="http://ajaxian.com/archives/dynamically-generic-pdfs-with-javascript">featuring us back in 2009</a>.</p>
9094

91-
<p>Thanks to Ajaxian.com for <a href="http://ajaxian.com/archives/dynamically-generic-pdfs-with-javascript">featuring us back in 2009</a>.</p>
95+
<p>Everyone else that's contributed patches or bug reports. You rock.</p>
9296

93-
<p>Everyone else that's contributed patches or bug reports. You rock.</p>
97+
<h2>License</h2>
9498

95-
<h2>License</h2>
99+
<p>(MIT License)</p>
96100

97-
<p>(MIT License)</p>
101+
<p>Copyright (c) 2010-2012 James Hall, <a href="https://github.com/MrRio/jsPDF">https://github.com/MrRio/jsPDF</a></p>
98102

99-
<p>Copyright (c) 2010-2012 James Hall, <a href="https://github.com/MrRio/jsPDF">https://github.com/MrRio/jsPDF</a></p>
103+
<p>Permission is hereby granted, free of charge, to any person obtaining
104+
a copy of this software and associated documentation files (the
105+
"Software"), to deal in the Software without restriction, including
106+
without limitation the rights to use, copy, modify, merge, publish,
107+
distribute, sublicense, and/or sell copies of the Software, and to
108+
permit persons to whom the Software is furnished to do so, subject to
109+
the following conditions:</p>
100110

101-
<p>Permission is hereby granted, free of charge, to any person obtaining
102-
a copy of this software and associated documentation files (the
103-
"Software"), to deal in the Software without restriction, including
104-
without limitation the rights to use, copy, modify, merge, publish,
105-
distribute, sublicense, and/or sell copies of the Software, and to
106-
permit persons to whom the Software is furnished to do so, subject to
107-
the following conditions:</p>
111+
<p>The above copyright notice and this permission notice shall be
112+
included in all copies or substantial portions of the Software.</p>
108113

109-
<p>The above copyright notice and this permission notice shall be
110-
included in all copies or substantial portions of the Software.</p>
114+
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
115+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
116+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
117+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
118+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
119+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
120+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
111121

112-
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
113-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
114-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
115-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
116-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
117-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
118-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
119122

120-
121-
</div>
123+
</div>
122124

123125
</div> <!-- /container -->
124126

125-
<footer>&copy; 2013 James Hall</footer>
126-
127-
128-
<!-- Scripts down here -->
129-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
130-
131-
<!-- Code editor -->
132-
133-
<script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
134-
135-
<!-- Scripts in development mode -->
136-
<script type="text/javascript" src="jspdf.js"></script>
137-
<script type="text/javascript" src="./libs/FileSaver.js/FileSaver.js"></script>
138-
<script type="text/javascript" src="./libs/BlobBuilder.js/BlobBuilder.js"></script>
139-
<script type="text/javascript" src="./jspdf.plugin.addimage.js"></script>
140-
<script type="text/javascript" src="./jspdf.plugin.from_html.js"></script>
141-
<script type="text/javascript" src="./jspdf.plugin.sillysvgrenderer.js"></script>
142-
<script type="text/javascript" src="./jspdf.plugin.split_text_to_size.js"></script>
143-
<script type="text/javascript" src="./jspdf.plugin.standard_fonts_metrics.js"></script>
144-
145-
<!-- Editor -->
146-
<script type="text/javascript" src="./examples/js/editor.js"></script>
147-
148-
<!-- Analytics -->
149-
<script type="text/javascript">
150-
151-
var _gaq = _gaq || [];
152-
_gaq.push(['_setAccount', 'UA-32767308-2']);
153-
_gaq.push(['_trackPageview']);
154-
155-
(function() {
156-
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
157-
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
158-
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
159-
})();
160-
161-
</script>
162-
<script type="text/javascript">
163-
adroll_adv_id = "P3OVQHTGMBA37E2Z6M77AQ";
164-
adroll_pix_id = "GHWLXTPCARHSXCCSWFFDR7";
165-
(function () {
166-
var oldonload = window.onload;
167-
window.onload = function(){
168-
__adroll_loaded=true;
169-
var scr = document.createElement("script");
170-
var host = (("https:" == document.location.protocol) ? "https://s.adroll.com" : "http://a.adroll.com");
171-
scr.setAttribute('async', 'true');
172-
scr.type = "text/javascript";
173-
scr.src = host + "/j/roundtrip.js";
174-
((document.getElementsByTagName('head') || [null])[0] ||
175-
document.getElementsByTagName('script')[0].parentNode).appendChild(scr);
176-
if(oldonload){oldonload()}};
177-
}());
178-
</script>
127+
<footer>&copy; 2013 James Hall</footer>
128+
129+
130+
<!-- Scripts down here -->
131+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
132+
133+
<!-- Code editor -->
134+
135+
<script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
136+
137+
<!-- Scripts in development mode -->
138+
<script type="text/javascript" src="jspdf.js"></script>
139+
<script type="text/javascript" src="./libs/FileSaver.js/FileSaver.js"></script>
140+
<script type="text/javascript" src="./libs/BlobBuilder.js/BlobBuilder.js"></script>
141+
<script type="text/javascript" src="./jspdf.plugin.addimage.js"></script>
142+
<script type="text/javascript" src="./jspdf.plugin.from_html.js"></script>
143+
<script type="text/javascript" src="./jspdf.plugin.sillysvgrenderer.js"></script>
144+
<script type="text/javascript" src="./jspdf.plugin.split_text_to_size.js"></script>
145+
<script type="text/javascript" src="./jspdf.plugin.standard_fonts_metrics.js"></script>
146+
147+
<!-- Editor -->
148+
<script type="text/javascript" src="./examples/js/editor.js"></script>
149+
150+
<!-- Analytics -->
151+
<script type="text/javascript">
152+
153+
var _gaq = _gaq || [];
154+
_gaq.push(['_setAccount', 'UA-32767308-2']);
155+
_gaq.push(['_trackPageview']);
156+
157+
(function() {
158+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
159+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
160+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
161+
})();
162+
163+
</script>
164+
<script type="text/javascript">
165+
adroll_adv_id = "P3OVQHTGMBA37E2Z6M77AQ";
166+
adroll_pix_id = "GHWLXTPCARHSXCCSWFFDR7";
167+
(function () {
168+
var oldonload = window.onload;
169+
window.onload = function(){
170+
__adroll_loaded=true;
171+
var scr = document.createElement("script");
172+
var host = (("https:" == document.location.protocol) ? "https://s.adroll.com" : "http://a.adroll.com");
173+
scr.setAttribute('async', 'true');
174+
scr.type = "text/javascript";
175+
scr.src = host + "/j/roundtrip.js";
176+
((document.getElementsByTagName('head') || [null])[0] ||
177+
document.getElementsByTagName('script')[0].parentNode).appendChild(scr);
178+
if(oldonload){oldonload()}};
179+
}());
180+
</script>
179181

180182
</body>
181183
</html>

0 commit comments

Comments
 (0)