打印PDF时出现html2canvas错误

时间:2017-03-05 03:19:22

标签: javascript html2canvas

我正在使用#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]){ if (argc<3) //error checking return -1; int size = atoi(argv[2]); int a[size]; int i, j, temp=0; printf("Enter %d numbers\n", size); //user array input for size and n values for(i = 0; i < size; i++) scanf("%d", &a[i]); for(i=0; i < size; i++){ //sorting array for(j = i+1; j <size; j++){ if( a[i] < a[j]){ temp = a[i]; a[i] = a[j]; a[j] = temp; } } } FILE *input; input = fopen(argv[1], "r"); if(input ==NULL) //error checking return -1; if(fscanf(input, "%d", &temp) != 1) return -1; while(fscanf(input, "%d", &temp) ==1){ //loop while there is file input for(i =1 < size; i++){ //check if temp is larger than array values if(temp > a[i] && temp < a[i-1]){ for(j = size-1; j >= i; j--) //slide down the rest of the array a[j] = a[j-1]; a[i] = temp; } } } for(i=0; i <size; i++){ //print out array printf("%d ", a[i]); } return (0); } ,但我遇到了一个问题:它没有将整个页面呈现为PDF,只返回页面的一半。那是为什么?

这是我的代码:

a[5] = {10, 8, 6, 4, 2};
number = 5;   // number++  number = 6 number = 7... until 10
result: a[5] = {10, 9, 8, 7, 6};

1 个答案:

答案 0 :(得分:0)

尝试

 function generatepdf() {
        html2canvas(document.getElementById('pdf'), {
           onrendered: function(canvas) {
               var data = canvas.toDataURL("image/png");
               var docDefinition = {
                   content: [{
                           image: data,
                            width: 500,
                            height:400,
                       }],
                   pageMargins: [ 50, 20, 20, 10 ]
               };

               pdfMake.createPdf(docDefinition).print("budget.pdf");
           },                     
           logging: true,
           useCORS:true,           
       });
       }