2016-07-02 2 views
0

저는 지난 여름에 시작한 프로젝트에서 일하는 선생님입니다. HTML로 작성한 양식을 PDF로 변환하려고합니다. 결국이 PDF를 mySQL 데이터베이스에 저장하고 네트워크상의 지정된 프린터로 인쇄하고 싶습니다.jspdf를 사용하여 HTML을 PDF로 변환하는 데 문제가 있습니다.

내가 가진 문제는 아무 일도 일어나지 않는다는 것입니다. 페이지가 PDF로 변경되지 않습니다. 이 프로세스의 몇 가지 예를 살펴 보았습니다. 코드가 아무 것도하지 않는 것처럼 보입니다.

여기 ------- 형태

-------------------------- HTML을 시작하기를 포함하는 내 HTML입니다 -------------------------------

<!DOCTYPE html> 
<html> 
<?php 
    $img_1 = 'new_checkbox_empty.gif'; 
?> 
<head> 
<title>OUSD URF</title> 
</head> 

<body> 
<div id="urfForm"> 
<center> 
<table border="1" width="100%"> 
    <table width="100%"> 
    <tr> 
     <td><IMG SRC="OUSD_URF_Logo.jpg"></td> 
     <td>Universal Office Discipline Referral Form</td> 
    </tr> 
    </table> 
    <table width="100%"> 
    <tr> 
     <td>Student________________________</td> 
     <td>Grade______</td> 
     <td>Referring Staff___________________________</td> 
     <td>Date_________</td> 
     <td>Time_________</td> 
    </tr> 
    </table> 
    <HR width="100%"> 
    <table border="1" width="100%"> 
    <thead>Pre-referral Interventions (For Minor Behaviors). Before making an office Referral, please complete at least 3 pre-referral interventions.<br>Minor Behaviors may include: Disrespect/non-compliance, Dress code Violation, Electronic Device, Horseplay, Inappropriate language, Inappropriate physical contact, Misuse/destruction of property, Tardy</thead> 
    <tr> 
     <td width="33%"><IMG SRC="<?php echo $img_1?>" style="margin: 0px 5px" style="margin: 0px 5px">5-1 Positive Reinforcement</td> 
     <td width="33%"><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px" style="margin: 0px 5px">Parent Consultation</td> 
     <td width="33%"><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px" style="margin: 0px 5px">Restorative Conversation</td> 
    </tr> 
    <tr> 
     <td><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px">Buddy Room (15 Minutes Max)</td> 
     <td><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px">Problem Solving Conference</td> 
     <td><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px">Reviewed IEP/504</td> 
    </tr> 
    <tr> 
     <td><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px">Behavior Contract</td> 
     <td><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px">Prompting Desired Behavior</td> 
     <td><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px">Re-teaching Desired Behavior</td> 
    </tr> 
    <tr> 
     <td><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px">Conflict Mediation</td> 
     <td><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px">Proximity or Seat change</td> 
     <td><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px">Reviewed IEP/504</td> 
    </tr> 
    <tr> 
     <td colspan="2"><IMG SRC="new_checkbox_empty.gif" style="margin: 0px 5px">Explicitly taught & Rehearsed Rules & Expectations</td> 
    </tr> 
    </table> 
</table> 
</center> 
</div> 
<br><br> 


<a href="javascript:urf2PDF()">Submit Form</a> 
<hr /> 

<script src="jsPDF/jspdf.js"></script> 
<script src="jsPDF/jquery.js"></script> 
<script src="jsPDF/test.js"></script> 

</body> 

</html> 

------------ ------------- End HTML ----------------------------------- -----

그리고 여기에 ----------------------------- 시작 JS- 내 JS

입니다 -----------------------------------

function urf2PDF() { 
var doc = new jsPDF('p', 'pt', 'letter'); 
source = $('#urfForm') [0]; 
var specialElementHandlers = { 
    '#bypassme': function(element, renderer){ 
     return true 
    } 
}; 

margins = { 
    top: 40, 
    left: 50, 
    width: 545 
}; 

pdf.fromHTML(
    source 
    , margins.left 
    , margins.top 
    , { 
     'width" : margins.width 
     , 'elementHandlers': specialElementHandlers 
    }, 
    function (dispose) { 
     pdf.save('urfForm.pdf'); 
    } 
) 
} 

------------------------- 끝 JS ---------------- -------------------------

도움을 주셔서 감사합니다.

-Kenny

+0

을 시도하고 알려

건배 할 수 있습니까? – 4castle

+0

아무 것도 발생하지 않았습니다. 파일이 작성되지 않았습니다. PDF가 작성되었음을 나타내는 화면이 표시되지 않습니다. – KenWill1978

+0

제공 한 내용을 살펴 보았습니다. zan 거기에 오타가 있음을 보여줍니다. 확실히 수정하십시오. 그 외에도 'plugins/from_html.js'를 포함시켜 'doc.fromHTML()'을 호출 할 수 있어야합니다. 정의되지 않은 pdf 오류가 있습니다. ---- 'from_html.js : 537 잡히지 않는 타입 오류 : renderer.pdf.sHashCode가 함수가 아닙니다. - 다음 문제입니다. 첫 번째 2 가지 수정 사항을 구현하고 라이브러리를 업데이트하는 것이 좋습니다. 이 문제는 최신 버전의 pdfJS에서 해결되었을 수 있습니다. 행운을 빕니다! – Conceptz

답변

1

는 pdf.fromHTML 기능에 '표시에 문제가 있습니다. 당신은 '쓴 대신 순서를 돌파하는 "의 나는 오류 아래 수정했습니다;.

function urf2PDF() { 
 
var doc = new jsPDF('p', 'pt', 'letter'); 
 
source = $('#urfForm') [0]; 
 
var specialElementHandlers = { 
 
    '#bypassme': function(element, renderer){ 
 
     return true 
 
    } 
 
}; 
 

 
margins = { 
 
    top: 40, 
 
    left: 50, 
 
    width: 545 
 
}; 
 

 
pdf.fromHTML(
 
    source 
 
    , margins.left 
 
    , margins.top 
 
    , { 
 
     "width" : margins.width, 
 
     "elementHandlers": specialElementHandlers 
 
    }, 
 
    function (dispose) { 
 
     pdf.save('urfForm.pdf'); 
 
    }) 
 
}

당신이

+0

나는 당신이 만든 교정을 시도했지만 여전히 아무 일도 일어나지 않고있다. 또한 기본 자습서를 한 줄씩 시도했지만 아무 것도 작동하지 않습니다. 나는 사파리와 크롬 모두를 시험해 보았다. 그림이 이것들에서 작동하지 않는다면 파이어 폭스를 시도해 볼 필요가 없다. 또한 최근의 문서에는 다른 변수가 있음을 알게되었습니다. 'doc.text'대신 'jsPDF.text'가 있습니다. 코드 복사 및 붙여 넣기가 불편하고 여전히 작동하지 않습니다. 아직도 배우는 것에 관심이 있고 나는 당신의 응답에 감사한다! !!! – KenWill1978

관련 문제