jspdf

How to calculate div height which is converted as image to fit the PDF using jsPDF & html2Canvas?

余生长醉 提交于 2020-01-16 02:04:48
问题 I am converting div to image by using html2canvas. I want to calculate height of the div(in px) such that it will fit on the PDF page maintaining the aspect ratio of image It should work on all window sizes(larger screens, IPAD, Desktop, laptop). I am using jsPDF for generating PDF Here is the fiddle example http://jsfiddle.net/akshay1818/ys0z984x/51/ HTML Code <div id="target"> Set div height(in px) such that it will fit on the page maintaing the aspect ratio </div> <button onclick=

jsPDF is not supported in remote server for IE-11

萝らか妹 提交于 2020-01-13 06:34:28
问题 I created a java script for creating a PDF file using jsPDF and its working on all the latest version of browser including IE11,chrome and firefox . below is the code <html> <head> <link rel="stylesheet" type="text/css" href="Wrs_Export_Report.css"> <script src="html2canvas.js"></script> <script src="jspdf.debug.js"></script> <script type="text/javascript"> function PDF() { var vTable = '<br>'; vTable += '<table class="wrs_export">'; vTable += '<tr class="wrs_export">'; vTable += '<th class =

How to reduce the file size created by JSPDF?

你说的曾经没有我的故事 提交于 2020-01-11 10:37:14
问题 I'm using jspdf.js to create pdf from HTML 5 canvas. However, regardless of what the contents are and how big the canvas size is, the generated file size is always 32,874 KB, even when the canvas is completey empty. Why the file size is always the same? jsPDF version is 1.1.135. My code is like this: var imgData = canvas.toDataURL("image/jpeg", 1.0); var width = $("canvas").attr('width'); var height = $("canvas").attr('height'); var pdf = new jsPDF('p', 'pt', [width,height]); pdf.addImage

Custom font faces in jsPDF?

允我心安 提交于 2020-01-10 08:00:34
问题 Is it possible to include custom fonts in jsPDF ? With the basic library, if I console log 'doc.getFontList()' I get: Courier, Helvetica, Times, courier, helvetica, times But, say I want to use 'Comic Sans' ( not that I would ;o) ) can it be done ? Even better, could I use a font is locally stored and has been declared in the site with @font-face ? 回答1: I found this was possible by modifying jsPDF.js to expose the existing addFont method in the public API. In jsPDF.js , look for: //----------

How to attach a PDF generated using jsPDF to the mail using asp.net c#

别说谁变了你拦得住时间么 提交于 2020-01-09 10:51:29
问题 I need to know if there is any way to attach a PDF file generated using jsPDF and mail it in asp.net C#? I have the following code in c# MailMessage message = new MailMessage(fromAddress, toAddress); message.Subject = subject; message.IsBodyHtml = true; message.Body = StrContent.ToString(); //message.Attachments.Add(new Attachment("getDPF()")); smtp.Send(message); and I'm using a JsPDF library as follows: <script type="text/javascript" src="jsPdf/jspdf.min.js"></script> <script type="text

Intel-XDK + jsPDF

一笑奈何 提交于 2020-01-07 05:06:08
问题 I'm trying to export an table from my app to an pdf file! This working normal in emulator, but I can't save the file when the app is installed in my Moto G, I'm using the code bellow: var pdf = new jsPDF('p', 'pt', 'a4'); var source = $('#tabelagastos')[0]; pdf.fromHTML(source, 15, 15, {'width': 170}, function (dispose) { var arquivo = prompt("File name"); pdf.save(arquivo +'.pdf'); }); Maybe I need to do some kind of configuration to enable this function... I heard that I need to use the

Set default filename when downloading a PDF open with Chrome PDF viewer

末鹿安然 提交于 2020-01-05 07:14:45
问题 My angular app has an iframe that renders a PDF: <iframe ng-src="{{PCtrl.docSrc}}" type="application/pdf" ...></iframe> docSrc is generated as a BASE64 encoded string, something like: "data:application/pdf;base64,JVBERi0xLjMKMyA..." Chrome renders the embedded PDF just fine. The PDF can be downloaded clicking on download, and the user will be presented with a "save as" dialog. The default filename given by the Chrome PDF viewer is "download.pdf", how do I change it? 回答1: window.onload = () =>

String overlaps next column with jspdf-autotable and overflow linebreak

做~自己de王妃 提交于 2020-01-04 05:36:14
问题 I'm using jspdf-autoTable with the option overflow: 'linebreak' to create a pdf. The problem is that some long texts are overlapping the next column. For example, if my text is "Hai hello welcome" it will print as "Hai hello wel" with the remaining "come" overlapped on the next column. How can I use linebreak without overlapping the next column? Note: Linebreak works fine until I'm changing the text in the drawCell method . I get this weird behavior as well: What I send in: Paragraph writing

unable to load multiple images in jspdf

心不动则不痛 提交于 2020-01-03 21:30:13
问题 I am trying to load multiple images which generates dynamically. I want to convert those images into PDF format. Here is the HTML code: <html> <body> <input type='submit' id='test' style='align:center' value='Generate'> </body> </html> and the script to generate pdf using jspdf is: <script> window.onload = function(){ var t = document.getElementById("test"); t.addEventListener("click", sayHi, false); function sayHi(){ var getImageFromUrl = function(url, callback) { var img = new Image(); img

PDF File generated using jsPDF doesn't show on Microsoft Edge

孤街醉人 提交于 2020-01-03 06:27:08
问题 I'm currently working on a project, where I have to generate a report on a button click using jsPDF. The code works perfectly fine in Google Chrome and Mozilla Firefox but doesn't work on Microsoft Edge. The PDF document loads in an iframe in the background but the page is white and blank. Can anyone suggest a solution for displaying the PDF correctly in Microsoft Edge? Note: I cannot share the code because it causes copyright infringement. I'm sorry. Also, the debugger shows no such