首页 > 解决方案 > 如何添加图像

问题描述

如何添加图像

<!doctype html>
    <html>
        <head>
            <meta charset="utf-8">
            <title>Create PDF</title>
            <header>    
                <script src="../js/jspdf/jsPDF-1.3.2/examples/js/jquery/jquery-1.7.1.min.js"></script>
                <script src="../js/jspdf/jsPDF-1.3.2/examples/js/jquery/jquery-ui-1.8.17.custom.min.js"></script>
                <script src="../js/jspdf/jsPDF-1.3.2/jspdf.js"></script>

                <script type="text/javascript" src="../js/jspdf/jsPDF-1.3.2/plugins/addimage.js"></script>
                <script type="text/javascript" src="../js/jspdf/jsPDF-1.3.2/plugins/from_html.js"></script>
                <script type="text/javascript" src="../js/jspdf/jsPDF-1.3.2/plugins/ie_below_9_shim.js"></script>
                <script type="text/javascript" src="../js/jspdf/jsPDF-1.3.2/plugins/svg.js"></script>
               <script type="text/javascript" src="../js/jspdf/jsPDF-1.3.2/plugins/split_text_to_size.js"></script>
               <script type="text/javascript" src="../js/jspdf/jsPDF-1.3.2/plugins/standard_fonts_metrics.js"></script>
               <script type="text/javascript" src="../js/jspdf/jsPDF-1.3.2/plugins/autoprint.js"></script>  
            </head>

            <body>
                <script>
    
                    var doc = new jsPDF();

                    var name = "Doe, John"
                    doc.setFontType("normal");
                    doc.setFontSize(12);

                    doc.addImage('../PDF/HEADER.jpg', "JPEG", 50, 0, 180, 180);

                    doc.text(20,20,'Name: '+ name);
                    doc.autoPrint();
                    window.open(doc.output('bloburl'), '_blank');
               </script>
         </body>
  </html>

我收到提供的数据不是 JPEG

我认为它需要以某种方式进行转换,但无论我尝试什么都行不通。我很难过

谢谢

标签: jspdf

解决方案


推荐阅读