Created
April 10, 2013 16:15
-
-
Save Akiyah/5356076 to your computer and use it in GitHub Desktop.
jsPDFの練習(htmlの例)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jsPDF - Create PDFs with HTML5 JavaScript Library | |
http://jspdf.com/ | |
の練習 | |
htmlをpdfにしてみます |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* { | |
margin: 0; | |
padding: 0; | |
border: 0; | |
} | |
body { | |
background: #ffd; | |
font: 30px sans-serif; | |
} | |
h1, table, tr, td { | |
border:solid thin gray; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="http://jspdf.com/jspdf.js"></script> | |
<script type="text/javascript" src="http://jspdf.com/libs/FileSaver.js/FileSaver.js"></script> | |
<script type="text/javascript" src="http://jspdf.com/libs/Blob.js/Blob.js"></script> | |
<script type="text/javascript" src="http://jspdf.com/libs/Blob.js/BlobBuilder.js"></script> | |
<script type="text/javascript" src="http://jspdf.com/libs/Deflate/deflate.js"></script> | |
<script type="text/javascript" src="http://jspdf.com/libs/Deflate/adler32cs.js"></script> | |
<script type="text/javascript" src="http://jspdf.com/jspdf.plugin.addimage.js"></script> | |
<script type="text/javascript" src="http://jspdf.com/jspdf.plugin.from_html.js"></script> | |
<script type="text/javascript" src="http://jspdf.com/jspdf.plugin.ie_below_9_shim.js"></script> | |
<script type="text/javascript" src="http://jspdf.com/jspdf.plugin.sillysvgrenderer.js"></script> | |
<script type="text/javascript" src="http://jspdf.com/jspdf.plugin.split_text_to_size.js"></script> | |
<script type="text/javascript" src="http://jspdf.com/jspdf.plugin.standard_fonts_metrics.js"></script> | |
<div id="target"> | |
<h1>text</h1> | |
sample | |
<span style="color:blue">sample</span> | |
sample | |
<h1>table</h1> | |
<table> | |
<tr> | |
<td>a</td> | |
<td>b</td> | |
</tr> | |
<tr> | |
<td>c</td> | |
<td>d</td> | |
</tr> | |
</table> | |
</div> | |
<iframe class="preview-pane" width="100%" height="650" frameborder="0"></iframe> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// forked from Akiyah's "jsPDFの練習" http://jsdo.it/Akiyah/heBe | |
var doc = new jsPDF(); | |
// We'll make our own renderer to skip this editor | |
var specialElementHandlers = { | |
'#editor': function(element, renderer){ | |
return true; | |
} | |
}; | |
doc.fromHTML($('#target').get(0), 15, 15, { | |
'width': 170, | |
'elementHandlers': specialElementHandlers | |
}); | |
var string = doc.output('datauristring'); | |
$('.preview-pane').attr('src', string); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment