|  |  | 
 |  |  | <apex:page controller="InsReportPDFController" showHeader="false" sidebar="false" renderAs="PDF" action="{!init}" applyHtmlTag="false"> | 
 |  |  | <apex:page controller="InsReportPDFController" showHeader="false" sidebar="false" action="{!init}" applyHtmlTag="false"> | 
 |  |  | <html> | 
 |  |  | <apex:stylesheet value="{!URLFOR($Resource.BeforeOPDPDF)}"/> | 
 |  |  |  | 
 |  |  | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |          | 
 |  |  |         table {border-collapse: collapse;} | 
 |  |  |         table {border-collapse: collapse;border: 0px;} | 
 |  |  |          | 
 |  |  |         th {text-align: center;} | 
 |  |  |         th.border-thick-title { border-width: 1pt 0pt 1pt 0pt; border-style: solid; border-color: black; text-align: center;} | 
 |  |  |         td.middle {text-align: center;} | 
 |  |  |         td.topClear {border-top-color: white;} | 
 |  |  |  | 
 |  |  |         /* 20220221 PI改造 by 徐亮 start */ | 
 |  |  |         body{margin: 0 auto; | 
 |  |  |         width: 780px;} | 
 |  |  |         #title1{height: 30px;} | 
 |  |  |         #title2{height: 80px;} | 
 |  |  |         .dianjian td{border: 1px #000 solid} | 
 |  |  |         /* 20220221 PI改造 by 徐亮 end */ | 
 |  |  |         </style> | 
 |  |  |          <!-- 20220221 PI改造 by 徐亮 start  --> | 
 |  |  |          <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" /> | 
 |  |  |          <apex:includeScript value="{!URLFOR($Resource.connection20)}"/> | 
 |  |  |          <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/> | 
 |  |  |          <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/> | 
 |  |  |          <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/> | 
 |  |  |          <apex:includeScript value="{!URLFOR($Resource.jspdf)}"/> | 
 |  |  |          <apex:includeScript value="{!URLFOR($Resource.html2canvas)}"/> | 
 |  |  |   | 
 |  |  |          <!-- 20220221 PI改造 by 徐亮 end  --> | 
 |  |  |         <script> | 
 |  |  |         </script> | 
 |  |  |     </head> | 
 |  |  |      | 
 |  |  |     <body style="font-family: Arial Unicode MS;"> | 
 |  |  |         <div id="pdf-wrapper"> | 
 |  |  |             <div id="title1"></div> | 
 |  |  |         <table border="0" style="width:100%;"> | 
 |  |  |             <tr> | 
 |  |  |                 <!-- update by rentx 20210707 start --> | 
 |  |  | 
 |  |  |                     <td>点检人</td> | 
 |  |  |                 </tr> | 
 |  |  |                 <tr> | 
 |  |  |                     <td width="70%">院方负责人     {!ir.Responsible_Person__c}</td> | 
 |  |  |                     <td width="70%">院方负责人     <span id="Responsible_Person__c">{!ir.Responsible_Person__c}</span></td> | 
 |  |  |                     <td width="15%"><apex:outputField value="{!ir.Inspection_Date__c}" /></td> | 
 |  |  |                     <td width="15%">{!usr.Alias__c}</td> | 
 |  |  |                 </tr> | 
 |  |  | 
 |  |  |                     <td> 本次点检对象数      {!ir.Inspection_asset_number__c}</td> | 
 |  |  |                 </tr> | 
 |  |  |                 <tr> | 
 |  |  |                     <td width="70%"> 院方负责人     {!ir.Responsible_Person__c}</td> | 
 |  |  |                     <td width="70%"> 院方负责人     <span id="Responsible_Person__c">{!ir.Responsible_Person__c}</span></td> | 
 |  |  |                     <td > 本次点检日期      <apex:outputField value="{!ir.Inspection_Date__c}" /></td> | 
 |  |  |                 </tr> | 
 |  |  |                 <tr> | 
 |  |  | 
 |  |  |             </apex:outputText> | 
 |  |  |         </table> | 
 |  |  |         <br/> | 
 |  |  |         <table border="1" style="width:100%;"> | 
 |  |  |         <table class="dianjian" border="0" style="width:100%;border-collapse: collapse;border: 0px;"> | 
 |  |  |             <!-- update by rentx 20210707 start --> | 
 |  |  |             <apex:outputText rendered="{!ir.Contract__c = null}"> | 
 |  |  |                 <tr> | 
 |  |  | 
 |  |  |         <table border="0" width="100%"> | 
 |  |  |             <tr><td style="text-align: right"><apex:image value="{!ir.SignUrl__c}" width="300px" height="150px" rendered="{!NOT(ISBLANK(ir.SignUrl__c))}" /></td></tr> | 
 |  |  |         </table> | 
 |  |  |     </div> | 
 |  |  |     </body> | 
 |  |  |     <!-- 20220221 PI改造 by 徐亮 start  --> | 
 |  |  | <script> | 
 |  |  |     AWSService.sfSessionId = '{!GETSESSIONID()}'; | 
 |  |  |     var staticResources = JSON.parse('{!staticResource}'); | 
 |  |  |     var staticResourceFile = JSON.parse('{!staticResourceFile}'); | 
 |  |  |     function Fun(pdf){ | 
 |  |  |  | 
 |  |  |         // var form = jQuery("<form method='post'></form>"); | 
 |  |  |         // jQuery(document.body).append(form); | 
 |  |  |         // let href = window.location.href | 
 |  |  |         // let arr = href.split('/') | 
 |  |  |         // form.attr({"action":staticResourceFile.viewUnifiedContactUrl+"?from="+encodeURIComponent(href)+"&fileName="+encodeURIComponent(arr[arr.length-1].split('?')[0])}); | 
 |  |  |         // // form.attr({"action":"http://127.0.0.1:8080/a/d?from="+encodeURIComponent(window.location.href)}); | 
 |  |  |         // let input = jQuery("<input type='hidden'/>"); | 
 |  |  |         // input.attr({"name":"base64Str"}); | 
 |  |  |         // input.val(pdf.output('datauristring').substr(28)); | 
 |  |  |         // form.append(input); | 
 |  |  |         // form.submit(); | 
 |  |  |  | 
 |  |  |         jQuery("body > *").each(function(){ | 
 |  |  |             jQuery(this).css('display','none'); | 
 |  |  |         }) | 
 |  |  |         jQuery("body").append('<embed style="position:absolute; left: 0; top: 0;" width="100%" height="100%" src="'+pdf.output('datauristring')+'" type="application/pdf"/>') | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     let id = "pdf-wrapper"; | 
 |  |  |     var target = document.getElementById(id); | 
 |  |  |     function jsPdfDownload(){ | 
 |  |  |         let pdfName = "测试"; | 
 |  |  |         let id = "pdf-wrapper"; | 
 |  |  |         var target = document.getElementById(id); | 
 |  |  |         target.style.background = "#FFFFFF"; | 
 |  |  |         if(pdfName==''||pdfName==undefined) pdfName= getNowFormatDate(); | 
 |  |  |  | 
 |  |  |         html2canvas(target, { | 
 |  |  |             scale: 2, | 
 |  |  |             onrendered:function(canvas) { | 
 |  |  |                 let landscape = true; | 
 |  |  |                 let pw = 595.28; | 
 |  |  |                 let ph = 841.89; | 
 |  |  |                 const marginw = 40; | 
 |  |  |  | 
 |  |  |                 let orientation = ''; | 
 |  |  |                 if (landscape) { | 
 |  |  |                     let temp =ph; | 
 |  |  |                     ph = pw; | 
 |  |  |                     pw = temp; | 
 |  |  |                     orientation = 'l'; | 
 |  |  |                 } | 
 |  |  |                  | 
 |  |  |                  | 
 |  |  |                 var contentWidth = canvas.width; | 
 |  |  |                 var contentHeight = canvas.height; | 
 |  |  |  | 
 |  |  |                 //一页pdf显示html页面生成的canvas高度; | 
 |  |  |                 var pageHeight = contentWidth / pw * ph; | 
 |  |  |                 //未生成pdf的html页面高度 | 
 |  |  |                 var leftHeight = contentHeight; | 
 |  |  |                 //页面偏移 | 
 |  |  |                 var position = 0; | 
 |  |  |                 //a4纸的尺寸[595.28,841.89],html页面生成的canvas在pdf中图片的宽高 | 
 |  |  |                 var imgWidth = pw-2*marginw;//595.28//左右边距20 | 
 |  |  |                 var imgHeight = imgWidth/contentWidth * contentHeight;//左右边距20 | 
 |  |  |  | 
 |  |  |                 var pageData = canvas.toDataURL('image/jpeg', 1.0); | 
 |  |  |  | 
 |  |  |                 var pdf = new jsPDF(orientation, 'pt', 'a4');// 第一个参数填字母l,注意不是数字1,为横向pdf | 
 |  |  |  | 
 |  |  |                 //有两个高度需要区分,一个是html页面的实际高度,和生成pdf的页面高度(841.89) | 
 |  |  |                 //当内容未超过pdf一页显示的范围,无需分页 | 
 |  |  |                 if (leftHeight < pageHeight) { | 
 |  |  |                     pdf.addImage(pageData, 'JPEG', marginw, 0, imgWidth, imgHeight );//左右边距20 | 
 |  |  |                 } else { | 
 |  |  |                     while(leftHeight > 0) { | 
 |  |  |                         pdf.addImage(pageData, 'JPEG', marginw, position, imgWidth, imgHeight)//左右边距20 | 
 |  |  |                         leftHeight -= pageHeight; | 
 |  |  |                         position -= ph; | 
 |  |  |                         //避免添加空白页 | 
 |  |  |                         if(leftHeight > 0) { | 
 |  |  |                             pdf.addPage(); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |                 Fun(pdf); | 
 |  |  |             } | 
 |  |  |         }) | 
 |  |  |     } | 
 |  |  |      | 
 |  |  |     //blockme(); | 
 |  |  |     document.body.onload = function(){ | 
 |  |  |          | 
 |  |  |         AWSService.query(staticResources.queryUrl, '{!ir.AWS_Data_Id__c}', function(data){ | 
 |  |  |             //unblockUI(); | 
 |  |  |             document.getElementById("Responsible_Person__c").innerHTML = data.object.responsiblePerson; | 
 |  |  |              | 
 |  |  |             jsPdfDownload();  | 
 |  |  |         }, staticResources.token); | 
 |  |  |          | 
 |  |  |     } | 
 |  |  | </script> | 
 |  |  | <!-- 20220221 PI改造 by 徐亮 end  --> | 
 |  |  | </html> | 
 |  |  | </apex:page> |