I'm using Html2Canvas for capture the screenshot of my screen i want to get a output as a PDF file now i'm getting output in png image how to convert or get output in pdf
function genScreenshot[] {
html2canvas[document.body, {
onrendered: function[canvas] {
$['#box1'].html[""];
$['#box1'].append[canvas];
if [navigator.userAgent.indexOf["MSIE "] > 0 ||
navigator.userAgent.match[/Trident.*rv\:11\./]]
{
var blob = canvas.msToBlob[];
window.navigator.msSaveBlob[blob,'Test file.png'];
}
else {
$['#test'].attr['href', canvas.toDataURL["image/png"]];
$['#test'].attr['download','Test file.png'];
$['#test'][0].click[];
}
}
}];
}
asked Aug 16, 2018 at 8:23
Alfreds Futterkiste | Maria Anders | Germany |
Centro comercial Moctezuma | Francisco Chang | Mexico |
Ernst Handel | Roland Mendel | Austria |
Island Trading | Helen Bennett | UK |
Laughing Bacchus Winecellars | Yoshi Tannamuri | Canada |
Magazzini Alimentari Riuniti | Giovanni Rovelli | Italy |
answered Aug 18, 2018 at 7:12
The Coding BusThe Coding Bus
4431 gold badge4 silver badges17 bronze badges
3
You can do that with this library. //github.com/tsayen/dom-to-image
import domtoimage from 'dom-to-image';
...
domtoimage.toJpeg[document.getElementById["wrapperContainer"], { bgcolor: '#2d3138', quality: 0.95 }]
.then[[dataURI] => {
...
}].catch[[error] => {
...
}];
answered Oct 25, 2018 at 9:02
1
How do I turn a print screen into a PDF?
On Windows.
Right-click on your image. Hover over the Open With option and select photos. Select the Print icon, and in the printer drop-down menu, select Microsoft Print to PDF.
How do I print a PDF in JavaScript?
How to print a PDF file using Javascript.
.
function print[] {.
var frame = document. getElementById['frame'];.
frame. contentWindow. focus[];.
frame. contentWindow. print[];.
.
.
How do I export my HTML page as PDF using JavaScript?
Generate PDF using JavaScript
The following example shows how to use the jsPDF library to generate PDF file using JavaScript. Specify the content in text[] method of jsPDF object. Use the addPage[] method to add new page to PDF. Use the save[] method to generate and download PDF file.
Can you take a screenshot with JavaScript?
A screenshot of any element in JavaScript can be taken using the html2canvas library. This library can be downloaded from its official website.