일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Database
- Spring
- 우선순위큐
- springboot
- Greedy
- Effective Java
- 그리디알고리즘
- 다이나믹프로그래밍
- mybatis
- DP
- SQL
- select
- 프로그래머스
- 깊이우선탐색
- 탐욕법
- 이펙티브자바
- java
- 너비우선탐색
- db
- mariaDB
- 데이터베이스
- 백준
- 피보나치
- 알고리즘
- BFS
- 코테
- 정렬
- IntelliJ
- DFS
- join
Archives
- Today
- Total
땀두 블로그
JS에서 html 파일 pdf로 저장하여 다운로드 하기 본문
<script src="https://html2canvas.hertzen.com/dist/html2canvas.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.debug.js"></script>
<script>
html2canvas(여기에 원하는 html 태그 이름).then(function(canvas) {
var imgData = canvas.toDataURL('image/png');
var imgWidth = 210;
var pageHeight = 290;
var imgHeight = canvas.height * imgWidth / canvas.width;
var doc = new jsPDF({
'orientation': 'p',
'unit': 'mm',
'format': 'a4'
});
doc.addImage(imgData, 'PNG', 0, 0, imgWidth, imgHeight);
doc.save('result.pdf');
});
</script>
더 다른 옵션과 설명은 아래 참고
http://raw.githack.com/MrRio/jsPDF/master/docs/index.html
Home - Documentation
jsPDF Generate PDF files in client-side JavaScript. This is a fork of MrRios' jsPDF modified to work with svg2pdf.js, which converts SVG elements to PDF. Since version 2.0.0 this fork is fully compatible to the original version and comes with a large amoun
raw.githack.com
'Web > JSP & JQuery' 카테고리의 다른 글
jQuery 1. (0) | 2020.09.03 |
---|---|
css cursor option (0) | 2020.08.31 |
html 태그 프린트 방법 (0) | 2020.07.30 |
$("selector").val(), $("selector").text(), $("selector").text() (0) | 2020.07.23 |
JQUERY 체크박스 선택 관련 (0) | 2020.07.23 |
Comments