html2canvas

How to convert SVG text element with @font-face to canvas using html2canvas.js?

隐身守侯 提交于 2019-12-11 02:13:16
问题 I'm trying to use html2canvas.js (https://html2canvas.hertzen.com/) to take screenshots with JavaScript. However, I have a problem when the page contains SVG text elements. As you can see on the screenshots below, the text element is duplicated (and only one of the copies keep the right font family). Original body Canvas copy Here is my code HTML <svg width="600" height="200" style="background-color:lightblue;"> <text transform="translate(100, 100)" style="font-size:60px; font-family: 'Oswald

Getting image on page 1 of 2 page pdf

核能气质少年 提交于 2019-12-11 01:07:22
问题 I am creating an image with html2canvas and with jsPDF with Angular4. I want to place this image on page 1 of a 2 page generated pdf. But it seems that the line, doc.save('test.pdf'); needs to be inside the function just after htm2canvas() . Because if I place it outside this it will not include the image in the pdf. generatePDF(){ var doc = new jsPDF(); doc.text(50,90,this.problems.length.toString()); doc.text(50,100,'page 1') doc.addPage(); doc.text(50,100,'page 2') html2canvas(document

Download a webpage in pdf format using angular4

99封情书 提交于 2019-12-10 18:37:07
问题 I am new for angular 4. I need to download a HTML webpage in pdf format and the html webpage contains angular controls like input [(ngModel)] , radio button [checked] . Rather than showing the control values it shows undefined in the pdf file. I tried using jsPdf & html2Pdf But it throws error Error: You need either https://github.com/niklasvh/html2canvas or https://github.com/cburgmer/rasterizeHTML.js at Object.jsPDFAPI.addHTML (jspdf.debug.js?6964:4049) Code for TS File: import { Component,

Using html2canvas to render a highcharts chart to pdf doesn't work on IE and Firefox

丶灬走出姿态 提交于 2019-12-09 16:33:47
问题 We are using html2canvas.js and html2canvas.svg.js (version 0.5.0 beta1) and highcharts.js to download a donut chart into pdf. This works as expected in Chrome, however in IE and Firefox this isnt working. In IE the chart is rendered incorrectly, and in Firefox it is not rendered at all. Below are screenshots of the download in Chrome, IE and Firefox Chrome IE (Edge) Firefox The code i am using to do the html2canvas is as follows: html2canvas($("#container"), { onrendered: function (canvas) {

html2canvas not capturing image

≯℡__Kan透↙ 提交于 2019-12-09 16:11:56
问题 html2canvas.js not capturing image. it leaves white space where the image occurs. function capture() { html2canvas(document.body, { allowTaint: true, logging:true, onrendered: function(canvas) { imagestring = canvas.toDataURL("image/png"); console.log(imagestring); document.body.appendChild(canvas); } }); } I have tried a lot but i cannot find solution . Help is appreciated :) 回答1: It works, when I host it in the server. The security restrictions causes it to fail. 来源: https://stackoverflow

Html2Canvas Not working for webkit-filter - Suggestions for similar

妖精的绣舞 提交于 2019-12-09 07:33:28
Html2Canvas works perfectly to make div content download, but when the div contains css filters the html2Canvas not apply the filters in the generated image. https://github.com/niklasvh/html2canvas/issues/246 Would welcome suggestions for something similar to Html2Canvas to download (image) the contents of a div Thanks for any help 来源: https://stackoverflow.com/questions/34684048/html2canvas-not-working-for-webkit-filter-suggestions-for-similar

Angular2 - Generate pdf from HTML using jspdf

六眼飞鱼酱① 提交于 2019-12-08 16:05:09
问题 For a project I'm working on I need to be able to generate a PDF of the page the user is currently on, for which I'll use jspdf . Since I have a HTML I need to generate a PDF with, I'll need the addHTML() function. There are a lot of topic about this, saying You'll either need to use html2canvas or rasterizehtml . I've chosen to use html2canvas . This is what my code looks like at the moment: import { Injectable, ElementRef, ViewChild } from '@angular/core'; import * as jsPDF from 'jspdf';

SVG Text attribute is doubling - HTML2CANVAS

倾然丶 夕夏残阳落幕 提交于 2019-12-08 14:37:54
问题 Here is mycode and link to JSFiddle. HTML <input type="button" id="export" value="Export"/> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <text x="162" text-anchor="middle" class="highcharts-title" zindex="4" style="color:#333333;font-size:18px;font-weight:normal;text-decoration:normal;font-family:Lucida Grande,Lucida Sans Unicode, Arial, Helvetica, sans-serif;visibility:visible;fill:#333333;width:260px;" y="25">Inventory</text> </svg> JS $(document)

convert html with highcharts graph to image using html2canvas

为君一笑 提交于 2019-12-08 13:37:28
问题 I want to convert an HTML page to an image, when I use the below code I get a result that doesn't quite match what I'd expect. html2canvas($("#sharedOne"), { onrendered: function (canvas) { console.log("canvas",canvas) var imgsrc = canvas.toDataURL("image/png"); console.log(imgsrc); } }); This is a screenshot of the HTML and this is a screenshot for the results of running the code above. When I use the code below I get an error: var canvas = document.getElementById('sharedOne'); console.log(

VUE中将页面导出为图片或者PDF

假如想象 提交于 2019-12-08 13:10:35
导出为图片 1.将页面html转换成图片 npm install html2canvas --save 2.在需要导出的页面引入 import html2canvas from 'html2canvas'; 3.在 methods 中添加方法 dataURLToBlob(dataurl) {//ie 图片转格式 var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1], bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n); while (n--) { u8arr[n] = bstr.charCodeAt(n); } return new Blob([u8arr], {type: mime}) }, downloadResult(name) { let canvasID = document.body let a = document.createElement('a'); html2canvas(canvasID).then(canvas => { let dom = document.body.appendChild(canvas); dom.style.display = "none"; a.style.display = "none