jspdf

How do I get a multi-page pdf from a website using jsPDF and HTML2Canvas?

早过忘川 提交于 2021-02-18 09:58:11
问题 I have a script that uses HTML2Canvas to take a screenshot of a div within the page, and then converts it to a pdf using jsPDF. The problem is the pdf that is generated is only one page, and the screenshot requires more than one page in some instances. For example the screenshot is larger than 8.5x11. The width is fine, but I need it to create more than one page to fit the entire screenshot. Here is my script: var pdf = new jsPDF('portrait', 'pt', 'letter'); $('.export').click(function() {

How can I pass dynamic component in a “renderToString” to convert into string

久未见 提交于 2021-02-11 17:44:50
问题 This is what I mean by the dynamic component (the component which is getting data from the rest API) import React from "react"; import axios from "axios"; class WeatherData extends React.Component { state = { data: null, latitude: "19.970324", longitude: "79.303360", weatherData: {}, _apiKey: "", //NOTE: In my code I have pass the Id here. city: "chandrapur,in" }; componentDidMount() { const { latitude, longitude, _apiKey, city } = this.state; axios .get( `https://cors-anywhere.herokuapp.com

Facing issue while exporting to pdf with more columns

纵然是瞬间 提交于 2021-02-11 16:45:30
问题 I am trying to export JSON data to PDF using jsPDF and I am not sure how to use jsPDF to accommodate around 15 columns in one page. I tried some of the code found on internet but it is splitting the columns to three rows,but I need to fit all columns to page. JSON data jsonResult.Products[{PRODUCT_ID: 123, PRODUCT_NUMBER: "00022", PRODUCT_NAME: "HONDA", PRODUCT_TYPE: "VEHICLE "}, {PRODUCT_ID: 783, PRODUCT_NUMBER: "08412394", PRODUCT_NAME: "HONDA", PRODUCT_TYPE: "MOTOR "}... I want to display

Facing issue while exporting to pdf with more columns

∥☆過路亽.° 提交于 2021-02-11 16:44:19
问题 I am trying to export JSON data to PDF using jsPDF and I am not sure how to use jsPDF to accommodate around 15 columns in one page. I tried some of the code found on internet but it is splitting the columns to three rows,but I need to fit all columns to page. JSON data jsonResult.Products[{PRODUCT_ID: 123, PRODUCT_NUMBER: "00022", PRODUCT_NAME: "HONDA", PRODUCT_TYPE: "VEHICLE "}, {PRODUCT_ID: 783, PRODUCT_NUMBER: "08412394", PRODUCT_NAME: "HONDA", PRODUCT_TYPE: "MOTOR "}... I want to display

讨厌手写,印度小哥开源了一个手写体转换工具,支持中文

≡放荡痞女 提交于 2021-02-10 05:48:57
【导语】:Text-to-Handwriting 是一个在线的开源工具,可以将文字输入转为手写体,并提供图片下载。 简介 Text-to-Handwriting 的开发者是个印度小哥,他讨厌手写作业,所以开发了这个工具,可以将文字输入转化为手写体,并提供图片下载。工具使用了以下第三方库: html2canvas,用于将 dom 元素转化为 canvas; jsPDF,以图片为原型生成对应的PDF文件; cypress,用于测试的库。这个库开源前哨介绍过,是一个很强大的自动化测试工具,详情点击 这里查看 ; serve,用于启动本地服务; 该项目是作者出于好玩开发的,目前存在一些问题,并且这个工具作者不是全职在维护,有些问题疑问无法及时解答,同时也呼吁更多的开发者参与进来。以下是一个已知的问题: 使用自定义字体时,字母之间会有间隙。作为临时解决方案,提供了调整字母间隙和单词间隙的选项来处理这个问题 项目地址: https://github.com/saurabhdaware/text-to-handwriting 简单使用 作者提供了一个在线地址供我们使用,地址是: https://saurabhdaware.github.io/text-to-handwriting/工具使用很简单,在左边 Input 输入需要转化的文字,右边选择手写字体,字体大小,图片尺寸,单词、字母间隙等

I cannot use jsPDF with Angular 10

你离开我真会死。 提交于 2021-02-08 15:06:29
问题 I was trying to print my page using jspdf library. I've tried so many solutions to get it done following examples on here and almost every Google suggestion links but I still couldn't fix it. Here is what I've tried so far: import * as jsPDF from 'jspdf'; ..... openPDF(): void { const DATA = this.couponPage.nativeElement; const doc = new jsPDF('p', 'pt', 'a4'); doc.fromHTML(DATA.innerHTML, 15, 15); doc.output('dataurlnewwindow'); } Trying to import jsPDF like the above creates the following

I cannot use jsPDF with Angular 10

我的未来我决定 提交于 2021-02-08 15:05:40
问题 I was trying to print my page using jspdf library. I've tried so many solutions to get it done following examples on here and almost every Google suggestion links but I still couldn't fix it. Here is what I've tried so far: import * as jsPDF from 'jspdf'; ..... openPDF(): void { const DATA = this.couponPage.nativeElement; const doc = new jsPDF('p', 'pt', 'a4'); doc.fromHTML(DATA.innerHTML, 15, 15); doc.output('dataurlnewwindow'); } Trying to import jsPDF like the above creates the following

error:Incomplete or corrupt PNG file in using jspdf

心不动则不痛 提交于 2021-02-07 19:24:45
问题 I want to add 2 images in my pdf when i click "create-pdf" icon. First image is a canvas that convert to image and it correctly work. var canvas = document.getElementsByClassName("jade-schematic-diagram"); img = canvas[0].toDataURL("image/png"); img.id="pic2"; doc = new jsPDF({ unit:'px', format:'a4' }); doc.addImage(img, 'JPEG', 20, 20,400,150); This section of my code got this error: Error: Incomplete or corrupt PNG file var srcpath; var element = $(".plot-waveforms"); // global variable

Access nested JSON property in jspdf autotable plugin

我是研究僧i 提交于 2021-02-07 09:41:58
问题 I have just started using jsPDF and the AutoTable plugin, and it is almost perfect for what we are using it for. One question... Is it possible to assign a dataKey in the columns definition to a nested property within the JSON that is being mapped to the table? We have a JSON structure that looks like this: "Primary_Key": "12345", "Site_Name": { "Address_Name": "Address 1" }, "Default_Screen_Name": "Bob", "Full_Name": "Bob Smith" If we use the following columns: var columns = [ { title: "ID",

Radiobutton is not visible properly using jsPDF

陌路散爱 提交于 2021-02-06 14:22:42
问题 Hello I want to generate a PDF file of specific div. For that I found , jsPDF may be usefull. I am new to jsPDF and bz googling I found lines of code that will works fine for me. jsPDF code will convert div into an image and then it will save it as a pdf. Mz problem is that I have a radio button in that div but when I convert div into PDF , design of that page will be look alike below image.. I dont know what is an exact issue. Here is code that I have written. var imgData = canvas.toDataURL(