jspdf

jsPdf add margins to pdf page

蹲街弑〆低调 提交于 2019-12-18 05:17:09
问题 I use jsPdf for creating pdf from html. How can I add margings (top, left, right) to my pdf page? var doc = new jsPDF('p', 'pt', 'letter'); doc.addHTML($('#template_invoice')[0], function () { ... }); Thanks for any help! 回答1: JSPdf allows you to make a margin hash and apply it in your download i.e. margins = { top: 40, bottom: 60, left: 40, width: 522 }; Try this snippet below or this CodePen : $(document).ready(function() { $(".btn").click(function() { var doc = new jsPDF("p", "pt", "letter

Generate PDF file from html using angular2/typescript

我与影子孤独终老i 提交于 2019-12-18 03:22:09
问题 I want to take a part of my HTML template and convert it to PDF file to give the user an option to download it. (After they click a button for example). I found a library called jsPDF, how would I use jsPDF in an Angular2 app (RC4)? thank you 回答1: If you want to use it in production, you definitely don't want to depend on an internet link being referenced in your index.html, like proposed by @khalil_diouri. So, to properly use it in an Angular2/Typescript environment, first install it from

JSPDF - How to export multiple images with various page size (height & width) to a single pdf file

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 21:32:13
问题 I have multiple images of different size(height & width) that need to be converted to PDF using jspdf, but I have trouble to use addPage() function to do that. Is it possible to export images with different page sizes to a single pdf? 回答1: I was actually able to add multiple pages with different image sizes using addPage([imgWidth, imgHeight]) except the first page, which is defined by new jsPDF('l', 'pt', 'a4') . The blank first page can be deleted using .deletePage(1) . You can also add

Cannot make PDF from Html div by jsPDF

核能气质少年 提交于 2019-12-17 20:49:09
问题 I have this js code : var doc = new jsPDF(); $('#pdf_new').click(function(){ var html=$(".wrap_all").html(); doc.fromHTML(html,200,200, { 'width': 500, }); doc.save("Test.pdf"); }); In html I have code like this : <div class = 'wrap_all'> <div id = 'wrap_odd'> <div id = ''>....</div> </div> <div id = 'wrap_even'> <div id = ''>....</div> </div> </div> Nothing works ... Console return to me: Cannot read property #wrap_odd of undefined" (P.S sorry for my English) 回答1: When using 'fromHTML' to

Image in PDF cut off: How to make a canvas fit entirely in a PDF page?

旧城冷巷雨未停 提交于 2019-12-17 19:50:57
问题 When placing the canvas in the PDF using the jspdf library makes the image cut off. html2canvas(myContainer, {background: 'red'}).then (canvas) -> imgData = canvas.toDataURL('image/jpeg', 1.0) window.open(imgData) # this is just a test that opens the image in a new tab and it displays nicely, the entire image pdf = new jsPDF("l", "pt", "b1") # tried a variety of formats but no luck pdf.addImage(imgData, 'JPEG', 0, 0) pdf.save('file.pdf') # the generated pdf that contains the image gets

How to set column width for generating pdf using jsPDF

百般思念 提交于 2019-12-17 18:10:44
问题 I got struck for the last two days, to set a column width for generating PDF using jsPDF. I am able to generate pdf using jsPDF lib from html table , but i am getting problem of overlapping columns. Because I want to display 20 columns in the sheet. I have changed the options portrait to landscape and set the width 5000 in exporting script options as well as html table width. Please help me, to set the pdf column width from jsPDF. Thanks 回答1: I had same problem 4 days back and was able to fix

Highcharts: Export multiple charts using jspdf

耗尽温柔 提交于 2019-12-17 16:54:27
问题 When I try to export several Highcharts charts using jsPdf I'm not getting the graph in the proper way. Could you please help me out in this? JAVASCRIPT CODE Highcharts.chart('container', { title: { text: 'Solar Employment Growth by Sector, 2010-2016' }, subtitle: { text: 'Source: thesolarfoundation.com' }, yAxis: { title: { text: 'Number of Employees' } }, legend: { layout: 'vertical', align: 'right', verticalAlign: 'middle' }, plotOptions: { series: { label: { connectorAllowed: false },

how to use html2canvas and jspdf to export to pdf in a proper and simple way

 ̄綄美尐妖づ 提交于 2019-12-17 15:45:01
问题 I am currently working on a school management software that usually requires exporting of html contents that contains data tables and div tag . I have tried all possible means to write a code that will be able to export my html data in a good way, with css preferably. After checking some question and answers here, I tried using spdf, but no luck. It keeps destroying my table alignment, then I read about html2canvas but to implement it with jspdf was my problem, i would like to capture the

前端页面导出PDF

随声附和 提交于 2019-12-17 10:12:16
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 这是一个封装了的vue组件, 简单设置了导出的头, 内容, 底部. 内容可翻页. 实现导出列表所有页数. 实现是基于html2canvas把页面转换为图片, 然后使用jspdf把生成的图片直接添加到pdf里面. html2canvas 配置参考 地址 JSPDFS Github地址 js操作blob的大小限制, 网上找的图. 使用 <export-pdf-view ref="pdf" :begin="begin" :flush-content="loadList" :end="end" save-name="设备使用记录.pdf" class="recharge"> </export-pdf-view> 注: 回调函数需要返回 Promise , 如果回调函数内部有修改数据, 注意dom刷新后再调用Promise的res. 所有回调函数均在生成前调用 ref 使用ref来调用组件内部的方法 $refs.recharge.exportPDF() 导出pdf 回调函数 begin 开始导出时调用 回调函数 flush-content 开始导出内容时调用, 此方法会重复调用. 直到 Promise 的 res(false) 时结束, //可在这里重复加载列表数据 回调函数 end 生成pdf底部时调用

Export HTML table to pdf using jspdf

依然范特西╮ 提交于 2019-12-17 04:27:11
问题 I need to export the HTML table to pdf file using jspdf. I tried the below code but it displays the blank/empty output in pdf file. Any suggestions or sample code for this would be helpful. ` <script type="text/javascript"> function demo1() { $(function () { var specialElementHandlers = { '#editor': function (element,renderer) { return true; } }; $('#cmd').click(function () { var doc = new jsPDF(); doc.fromHTML($('#htmlTableId').html(), 15, 15, { 'width': 170,'elementHandlers':