Skip to content

issue with displaying HTML element with .html() method : jsPDF 2.1.1 #2986

@lazoir

Description

@lazoir

Hello ,
I am faced issue when i try to use .html() method, i got a word by line in PDF file .
is it bug or i missed some parameters ? thank to find below the code

<html>
<header>

 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <link rel="stylesheet" type="text/css" href="css/smoothness/jquery-ui-1.8.17.custom.css">
  <link rel="stylesheet" type="text/css" href="css/main.css">

  <script type="text/javascript" src="js/jquery/jquery-1.7.1.min.js"></script>
  <script type="text/javascript" src="js/jquery/jquery-ui-1.8.17.custom.min.js"></script>
  <script type="text/javascript" src="../dist/jspdf.umd.js"></script>
  <script type="text/javascript" src="js/basic.js"></script>
  <script type="text/javascript" src="../../DOMPurify-main/dist/purify.min.js"></script>
  <script src="https://html2canvas.hertzen.com/dist/html2canvas.js"></script>

  
</header>
<script>

var varHeight = 130; // Starting point from the top

//create new Document
var doc = new jspdf.jsPDF({unit: "px"});
	

 var source = "<p>Hello world!jkkkkkkkk kkkkkk kkkkkkk  kkkkkkkk hhhhhhhhhhh kkkkkkk kkkkkk kkkkkkkkk hiuhih </p>" ; 	
	
//  handle content from HTML 
var specialElementHandlers = {
		'#ignorePDF' : function(element, renderer){      // we should specifie the div will be treated , by ID or class name
		return true;
						}
			};


doc.setFont("times","normal");
doc.html(source, {
    html2canvas: {
        // insert html2canvas options here, e.g.
        scale: 0.6,	
        width: 360,
        		
    },
   callback: function (doc) {
     //doc.save();	 
       addApprovers(doc);
   },
   x: 40,
   y: varHeight + 85,
   
});

// manage approvers part 
function addApprovers(doc){
doc.text(20, varHeight + 200, 'second text');
doc.save();
}
</script>
</body>
</html>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions