Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/468.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用Angular2在JSPDF中打印Jquery括号_Javascript_Jquery_Angular_Jspdf - Fatal编程技术网

Javascript 使用Angular2在JSPDF中打印Jquery括号

Javascript 使用Angular2在JSPDF中打印Jquery括号,javascript,jquery,angular,jspdf,Javascript,Jquery,Angular,Jspdf,我使用Jquery括号为体育应用程序生成括号 我使用了以下代码来生成括号 var mData = { teams : [ ["John Anderson", "Peter Robert"], /* first matchup */ ["Maria Lucos", "Usha Elizabeth"] /* second matchup */ ], results : [ [[1,2], [3,4]], /* first

我使用Jquery括号为体育应用程序生成括号

我使用了以下代码来生成括号

 var mData = {
    teams : [
      ["John Anderson", "Peter Robert"], /* first matchup */
      ["Maria Lucos", "Usha Elizabeth"]  /* second matchup */
    ],
    results : [
      [[1,2], [3,4]],       /* first round */
      [[4,6], [2,1]]        /* second round */
    ]
  }


    $(function() {
        $('.demo').bracket({
          init: mData /* data to initialize the bracket with */ })
      })
现在我们有了一个带有html类demo的div。在这里,我们将附加n个括号数据。我们希望将此html数据转换为pdf。为此,我们在jspdf中使用了以下代码:

print_brackets(){
     var pdf = new jsPDF('p', 'pt', 'letter', true);
         pdf.internal.scaleFactor =3.5;
  recursivePDF(0,1,splitTitle);
function recursivePDF(i,n,splitTitle) {

var checkholdin =0;
    if(i == 0){
        var k =100
        var l=80
    }
    else{
        var k = 60
        var l=60
    }
          pdf.addHTML($('#wholebracket'+i+'>#scoresheet'+n+'>div.brackdata>div.jQBracket.lr>div.bracket' ).get(0), 30, l+40, options, function() {

     exportIndex = parseInt(exportIndex) + 1;
     scoreIndex = parseInt(scoreIndex) + 1;
    var scoreLength = $('#wholebracket'+i+'>div.scoresheet').length;
    var holdLength = $('#wholebracket'+i+'>div.holding').length;
      if(exportIndex == exportLength) {
       pdf.setFontSize(10);
       pdf.setTextColor(39, 39, 206);
       pdf.setFontType("bold");
      pdf.text(splitTitle, 300, l-40,'center');
      pdf.setFontType("normal");
     pdf.setFontSize(18);
      pdf.setTextColor(39, 39, 206);
      pdf.text(300, l, "Scoresheet", 'center');                                                pdf.setFontSize(10);pdf.setFontType("normal");
    pdf.setTextColor(0, 0, 0);
     pdf.text(30, l+20,"Division: ");
    pdf.setFontType("bold");
     pdf.text(80, l+20,cname);
     pdf.setTextColor(150);                                                pdf.setFontType("normal");
    pdf.text(520, l+20,day);
    pdf.output('save', 'Bracketed_Scoresheet.pdf');                                             
    $('.demo').hide();                                                $('.score_table').hide();$(".demo").empty();
    $(".score_table").empty();document.getElementById('tournament').value='';
     return true;
     }     
    else {
     pdf.setFontSize(10);
     pdf.setTextColor(39, 39, 206);
      pdf.setFontType("bold");                                                pdf.text(splitTitle, 300, l-40,'center');                  
     pdf.setFontType("normal");
     pdf.setFontSize(18);
     pdf.setTextColor(39, 39, 206);
     pdf.text(300, l, "Scoresheet", 'center');
     pdf.setFontSize(10);
     pdf.setTextColor(0, 0, 0);
      pdf.text(30, l+20,"Division: ");
     pdf.setFontType("bold");
     pdf.text(80, l+20,cname);                                                pdf.setFontType("normal");
    pdf.setTextColor(150);
     pdf.text(520, l+20,day);
     pdf.addPage(); 
    if(scoreLength == n){

     n = 1; 
       i=i+1;
     } 
     else{
    n=n+1;i=i+0;
     }
     var k=0;                                                    recursivePDF(i,n,splitTitle);
     }
       return true;
     });
}
Inside.demo div我们在div#wholeblacket中有n个括号,这些括号是根据括号长度递增的。我们有递归pdf函数,该函数在整个过程中循环以获取所有括号数据,最后,如果循环达到,我们使用pdf.save函数下载pdf

在Safari中,此代码运行良好。但在Chrome和IE中,PDF下载了,但只得到了空白页面

我们还尝试了fromHTML而不是addHTML。但是,jquery括号中的css没有被应用。只是得到一份名单而已

如果有人对此有一些想法,那将是很有帮助的

谢谢,
杰尼德夫