jspdf

how to replace undefined with a empty string

我是研究僧i 提交于 2019-12-05 01:28:43
I am using jsPdf. When a field has been left blank "undefined" is printed on the pdf. I would like to replace that with a empty string. I am trying to use a if statement but I am not getting it. doc.text(30, 190, "Budget : $"); if ($scope.currentItem.JobOriginalBudget == "undefined") { doc.text(50, 190, " "); } else { var y = '' + $scope.currentItem.JobOriginalBudget; doc.text(50, 190, y); }; undefined is a primitive value . Instead of comparing against the identifier undefined , you're comparing against the 9-character string " undefined ". Simply remove the quotes: if ($scope.currentItem

jsPDF fromHTML images cause the pdf to be empty

安稳与你 提交于 2019-12-05 01:02:09
I'm trying to generate a pdf out of Tinymce Content, which I access with AngularJS. For This I use the from_html plugin inside jspdf. First the relevant code parts. Relevant Function & Index.ejs jspdf includes //relevant function var specialElementHandlers = { '#bypassme': function(element, renderer) { return true; } }; var margin = { top: 0, left: 0, right: 0, bottom: 0 }; var tinymceToJSPDFHTML = document.createElement("body"); tinymceToJSPDFHTML.innerHTML = $scope.selectedItem.content; var doc = new jsPDF(); doc.fromHTML(tinymceToJSPDFHTML, 0, 0, { 'width': 100, // max width of content on

doc.save() throwing error with jspdf

与世无争的帅哥 提交于 2019-12-04 22:18:19
When I try and use the save() function for jsPDF it's throwing the following error: ReferenceError: saveAs is not defined I'm just trying a very simple example: var doc = new jsPDF(); doc.text(20, 20, 'Hello world!'); doc.text(20, 30, 'This is client-side Javascript, pumping out a PDF.'); doc.addPage(); doc.text(20, 20, 'Do you like that?'); doc.save('test.pdf'); Anyone have any ideas what's wrong? Owen Davey Found out what the issue was. The saveAs function is part of FileSaver.js so I just needed to include this and everything worked. Kyle Baker I don't have enough to comment yet, so I'm

Create PDF with Table using Javascript

心不动则不痛 提交于 2019-12-04 18:31:31
I'm currently creating a phonegap app that lets you input Data and then creates a PDF with that data. The Input is done, but I can't find anything to make a PDF with Javascript. So far I only found jsPDF, but that doesn't support tables. The App must work offline. Does someone have an Idea? Bytescout PDF Generator SDK for Javascript might come in handy: http://bytescout.com/products/developer/pdfgeneratorsdkjs/index.html Ensure that browser inconsistencies for your targeted devices are taken into account. I wanted to use jsPDF to generate tables so I made a table plugin for it. Check it out!

JSPDF-Autotable colspan/rowpan issue

杀马特。学长 韩版系。学妹 提交于 2019-12-04 16:29:48
I have an html table with rowspan/colspan.I am using jspdf and jspdf-autotable for exporting that html table to pdf. However the pdf getting saved has a table which doesn't contain rowspan/colspan in actual table.How to do colspan/rowspan using jspdf-autotable? My current code is <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title id='title'>HTML Page setup Tutorial</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.0.272/jspdf.debug.js"></script> <script src="https://rawgit.com/someatoms/jsPDF-AutoTable/master/dist/jspdf.plugin

Opening PDF file in ionic 2 app

只谈情不闲聊 提交于 2019-12-04 16:01:17
问题 I am trying to make an ionic 2 app. I have a pdf generated using jsPDF. The code for the same is var doc = new jsPDF(); doc.setFontStyle('Bold'); doc.setFontSize(14); doc.text('Testing PDFs', 20, 20); Now I want to save the open the PDF in the mobile app, but doc.output('save', 'tester.pdf'); doesn't seem to work in the mobile app. Please can you tell me which plugin can I install so as to view and share the newly made pdf. 回答1: I think includes script via external URL may not a good option

HTML to PDF (by javascript) how can I add css or table?

浪尽此生 提交于 2019-12-04 12:54:43
问题 In a project I have convert html file into pdf,than it's working fine.But this output not showing css design.Now I need a suggestion how can I add css design with this pdf file? Here the js function code : $(function(){ var doc = new jsPDF(); var specialElementHandlers = { '#editor': function (element, renderer) { return true; } }; $('#cmd').click(function () { doc.fromHTML($('#StudentInfoListTable').html(), 15, 15, { 'width': 170, 'elementHandlers': specialElementHandlers }); doc.save(

How to converted SVG Files into PDF in JSPDF using javascript

强颜欢笑 提交于 2019-12-04 10:56:05
I struggled to converted SVG Files into PDF using JSPDF. Here i Worked in following code. var doc = new jsPDF(); var test = $.get('amChart.svg', function(svgText){ // console.log(svgText); var svgAsText = new XMLSerializer().serializeToString(svgText.documentElement); console.log(svgAsText); doc.addSVG(svgAsText, 20, 20, doc.internal.pageSize.width - 20*2) //console.log(doc); // Save the PDF doc.output('datauri'); }); I get this script from this SO Answer .Its results only blank PDF .When i console.log(doc) before output it will shown results.But it will not results in PDF ... And I also i

how to use jsPDF and jspdf-autotable in angular 5

浪尽此生 提交于 2019-12-04 07:23:17
I am trying to use jsPDF and jspdf-autotable in my Angular 5.2.0 project. My package.json is below (related parts): "dependencies": { ... "jspdf": "^1.3.5", "jspdf-autotable": "^2.3.2" ... } My angular-cli.json is below (related parts): "scripts": [ ... "../node_modules/jspdf/dist/jspdf.min.js", "../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js" ... ] My component (related parts ): import * as jsPDF from 'jspdf'; import 'jspdf-autotable'; @Component({ selector: "energy-login", templateUrl: "./login.component.html", styleUrls: ["./login.component.scss"] }) export class MyComponent

How to send a jsPDF converted pdf file to backend server?

笑着哭i 提交于 2019-12-04 06:29:03
问题 I need to send a png file to the backend server. I converted it to pdf using jsPDF: var doc = new jsPDF('l', 'mm', [210, 210]); doc.addImage(myPngData, 'PNG', 0, 0, 210, 210); Now I need to send it to the server using my old-school JQuery project: $.post(url, { key1: val1, key2: val2, pdf: //pdf file goes here, will doc work?, }, But what should I really send? Cause sending doc just won't work? Unfortunately I cannot just send and check it as the backend is not ready yet. 回答1: You can use doc