jspdf

JSP页面导出PDF格式文件

非 Y 不嫁゛ 提交于 2020-08-05 11:04:39
JSP页面导出PDF格式文件基本在前端页面可以全部完成 <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.0.272/jspdf.debug.js"></script> 添加下载链接的点击事件 <script type="text/javascript"> var downPdf = document.getElementById("downLoad"); downPdf.onclick = function() { downPdf.parentNode.removeChild(downPdf); html2canvas(document.body, { onrendered:function(canvas) { var contentWidth = canvas.width; var contentHeight = canvas.height; //一页pdf显示html页面生成的canvas高度; var pageHeight = contentWidth / 592.28 * 841.89; /

JSPDF旋转页面为横版

柔情痞子 提交于 2020-07-26 12:01:39
JSPDF旋转页面为横版 默认代码 // jsPDF-1.3.2/examples/images.html var doc = new jsPDF('p', 'pt', 'a4', false); doc.setFontSize(40); doc.setDrawColor(0); doc.setFillColor(238, 238, 238); doc.rect(0, 0, 595.28, 841.89, 'F'); doc.text(35, 100, type); doc.addImage(imgData, format, 100, 200, 280, 210, undefined, compress); doc.save(type + '.pdf') 查看源码 // jsPDF-1.3.2/dist/jspdf.debug.js // 通过查看源码,里面有一个参数('p'和'l'),它通过这个参数的值,再手动把宽高互置,达到竖屏转变为横屏的效果 if (orientation) { switch (orientation.substr(0, 1)) { case 'l': if (height > width) orientation = 's'; break; case 'p': if (width > height) orientation = 's'; break; }

Cannot install jspdf 1.5.3

妖精的绣舞 提交于 2020-07-20 08:34:45
问题 I need to convert html to pdf and I am using jspdf 1.5.2. It shows the error Cannot read property 'charAt' of undefined (using with html2canvas). When I try to install jspdf 1.5.3 I get this: npm ERR! path git npm ERR! code ENOENT npm ERR! errno ENOENT npm ERR! syscall spawn git npm ERR! enoent Error while executing: npm ERR! enoent undefined ls-remote -h -t ssh://git@github.com/eligrey/FileSaver.js.git npm ERR! enoent npm ERR! enoent npm ERR! enoent spawn git ENOENT npm ERR! enoent This is

Cannot install jspdf 1.5.3

…衆ロ難τιáo~ 提交于 2020-07-20 08:34:06
问题 I need to convert html to pdf and I am using jspdf 1.5.2. It shows the error Cannot read property 'charAt' of undefined (using with html2canvas). When I try to install jspdf 1.5.3 I get this: npm ERR! path git npm ERR! code ENOENT npm ERR! errno ENOENT npm ERR! syscall spawn git npm ERR! enoent Error while executing: npm ERR! enoent undefined ls-remote -h -t ssh://git@github.com/eligrey/FileSaver.js.git npm ERR! enoent npm ERR! enoent npm ERR! enoent spawn git ENOENT npm ERR! enoent This is

JSPDF .html() function returning blank pdf page

跟風遠走 提交于 2020-06-27 19:29:08
问题 Using the new jsPDF .html() pretty much pulled straight from their docs, but it still results in a blank page: Results in blank page: function saveDoc() { window.html2canvas = html2canvas const doc = document.getElementById('doc') if (doc) { var pdf = new jsPDF('p', 'pt', 'a4') pdf.html(doc.innerHTML, { callback: function (pdf) { pdf.save('DOC.pdf'); } }) } } Results in no PDF generated: function saveDoc() { window.html2canvas = html2canvas const doc = document.getElementById('doc') if (doc)

How to use addHTML in angular 4

扶醉桌前 提交于 2020-06-14 06:12:42
问题 I'm trying to use addHTML function of jspdf library in angular and have already installed html2Canvas but got an error. This is my demo.component.ts file. import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; import * as jsPDF from 'jspdf'; import * as html2canvas from "html2canvas"; @Component({ selector: 'app-demo', templateUrl: './demo.component.html', styleUrls: ['./demo.component.scss'] }) export class DemoComponent implements OnInit { @ViewChild('content') content

How to use addHTML in angular 4

柔情痞子 提交于 2020-06-14 06:10:47
问题 I'm trying to use addHTML function of jspdf library in angular and have already installed html2Canvas but got an error. This is my demo.component.ts file. import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; import * as jsPDF from 'jspdf'; import * as html2canvas from "html2canvas"; @Component({ selector: 'app-demo', templateUrl: './demo.component.html', styleUrls: ['./demo.component.scss'] }) export class DemoComponent implements OnInit { @ViewChild('content') content

jquery插件导出excel和pdf(解决中文乱码问题)

雨燕双飞 提交于 2020-04-28 22:32:07
参考文件:http://jackyrong.iteye.com/blog/2169683 https://my.oschina.net/aruan/blog/418980     https://segmentfault.com/a/1190000013168209 js引用文件地址: https://files.cnblogs.com/files/likui-bookHouse/tableExport.jquery.plugin-master.rar html文件代码: <html> <head> <title>Export html table to excel and csv using jquery</title> <script src= " ~/Content/js/jquery-1.7.1.js " ></script> <link rel= " stylesheet " href= " https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css " > <script type= " text/javascript " src= " ~/Content/js/excel/jquery.base64.js " ></script> <script type= " text

Vue 结合html2canvas和jsPDF实现html页面转pdf

扶醉桌前 提交于 2020-04-26 09:29:39
结合 html2canvas 和 jsPDF 实现 html 页面转 pdf By :授客 QQ : 103355122 实践环境 win10 Vue 2.9.6 axios 0.18.0 html2canvas 1.0.0-rc.3 jspdf 1.5.3 安装 html2canvas 进入vue项目所在目录,然后执行以下安装命令 cd /d E:\MyProjects\TMP\frontend E:\MyProjects\TMP\frontend>npm install html2canvas 安装jspdf 进入vue项目所在目录,然后执行以下安装命令 cd /d E:\MyProjects\TMP\frontend E:\MyProjects\TMP\frontend>npm install jspdf 编写htmlToPdf.js htmlToPdf.js文件路径,例中为src/common/utils/htmlToPdf.js import html2canvas from "html2canvas" import JsPD Ffrom "jspdf" /** * @param ele要生成 pdf 的DOM元素(容器) * @param padfName PDF文件生成后的文件名字 * */ export default { install(Vue, options)

Merge two PDF's generated with jsPDF into one document

旧巷老猫 提交于 2020-04-16 04:49:49
问题 I'm using jsPDF for generation of document from HTML (with using .html() method) and it works fine. But now I need to do next: Create jsPDF object. Add content with using .html() method. Add new page to created document. Add content to second page with using the same .html() method. Save created document. Here is the code example: var doc = new jsPDF({ orientation: 'p', format: 'a4' }); doc.html(document.getElementById('test'), { callback: function (doc) { doc.addPage('a4', 'p'); doc.html