2013-04-17 1 views
2

나는 pdf로 xhtml을 변환하기 위해 비행 접시 라이브러리를 사용하고 있습니다. 두 페이지의 PDF 경계 사이에 서식 문제가 있습니다. 첨부 된 스크린 샷에서 볼 수 있듯이, pdf에 페이지가 변경 될 때마다 다른 범례를 나타내는 색 구분 상자가 분할됩니다. 이것은 좋지 않습니다. pdf가 생성되는 코드 샘플을 포함하는 샘플 xhtml이 첨부됩니다. 서식 문제없이 xhtml이 올바르게 표시됩니다. 다른 사람이 비슷한 문제를 겪었습니까? 이것에 대한 가능한 해결책은 무엇입니까?flying-saucer 라이브러리를 사용하여 생성 된 pdf에서 서식 문제

XHTML 입력 파일

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 

<style> 


table.diff { 
    font-family: Arial, Helvetica, sans-serif; 
    color: #000000; 
    font-size: 11px; 
    border-collapse:collapse; 
} 
table.diff tbody { 
    font-family: Arial, Helvetica, sans-serif; 
    font-size: 11px; 
} 
table.diff tbody th { 
    font-family: Arial, Helvetica, sans-serif; 
    background:#F5F5F5; 
    font-size:11px; 
    font-weight:normal; 
    color:#999999; 
    padding:.3em .5em .1em 2em; 
    text-align:right; 
    vertical-align:top; 
} 
table.diff thead { 
    border-bottom:1px solid #BBC; 
    background:#EFEFEF; 
    font-family:Verdana; 
} 
table.diff thead th.texttitle { 
    text-align:left; 
    font-family: Arial, Helvetica, sans-serif; 
    font-size: 11px; 
} 

table.diff td { 
    font-family: Arial, Helvetica, sans-serif; 
    font-size:11px; 
    padding: 2px 2px; 
} 

table.diff .empty { 
    background-color:#D7F0FC; 
    font-family: Arial, Helvetica, sans-serif; 
    font-size: 11px; 
} 
table.diff .replace { 
    font-family: Arial, Helvetica, sans-serif; 
    font-size: 11px; 
    background-color:#FFD899; 
} 
table.diff .delete { 
    background-color:#FF9900; 
    font-family: Arial, Helvetica, sans-serif; 
    font-size: 11px; 
} 
table.diff .skip { 
    background-color:#EFEFEF; 
} 
table.diff .insert { 
    background-color:#ADCC70; 
    font-family: Arial, Helvetica, sans-serif; 
    font-size: 11px; 
} 
table.diff th.author { 
    text-align:right; 
    border-top:1px solid #BBC; 
    background:#EFEFEF; 
} 


.top-border { 
    font-family: Arial, Helvetica, sans-serif; 
    font-size: 11px; 
    border-top: 1px solid #67BBE5; 
} 

table.diff .left-border { 
    font-family: Arial, Helvetica, sans-serif; 
    font-size: 11px; 
    border-left: 1px solid #CCCCCC; 
} 

.bottom-border { 
    font-family: Arial, Helvetica, sans-serif; 
    font-size: 11px; 
    border-left: 1px solid #67BBE5; 
} 

table.diff .left-bottom-border { 
    font-family: Arial, Helvetica, sans-serif; 
    font-size: 11px; 
    border-left: 1px solid #CCCCCC; 
    border-bottom: 1px solid #CCCCCC; 
} 

table.diff .bottom-border-grey { 
    font-family: Arial, Helvetica, sans-serif; 
    font-size: 11px; 
    border-bottom: 1px solid #CCCCCC; 
} 
table .top-border-line { 
    font-family: Arial, Helvetica, sans-serif; 
    font-size: 0px; 
    border-top: 1px solid #CCCCCC; 
} 
table .bottom-border-line { 
    font-family: Arial, Helvetica, sans-serif; 
    font-size: 0px; 
    border-bottom: 1px solid #CCCCCC; 
} 
table.diff .legend-border { 
    font-family: Arial, Helvetica, sans-serif; 
    font-size: 11px; 
    border: 1px solid #CCCCCC; 
} 

</style> 

</head> 


<body> 

<div id='legends' class='legends' style='width:100%;float:left'> 
     <table width="100%" class="diff" style="background-color: rgb(235, 235, 235); "> 
      <tbody> 
       <tr> 
        <td width="50%"> 
        </td> 
        <td width="100%" style=""> 
         <table cellspacing="0" cellpadding="1" width="100%" class="diff"> 
          <tbody> 
           <tr> 
           <td style="width: 20%;"><b>Legend : </b></td> 
           <td style="text-align: center; width: 20%; border:1px solid;" class="empty">Empty</td> 
           <td style="text-align: center; width: 20%; border:1px solid;" class="delete">Deleted</td> 
           <td style="text-align: center; width: 20%; border:1px solid;" class="replace">Modified</td> 
           <td style="text-align: center; width: 20%; border:1px solid;" class="insert">Inserted</td> 
           </tr> 
          </tbody> 
         </table> 
        </td> 
       </tr> 
      </tbody> 
     </table> 
    </div> 

    </body> 

</html> 

Image showing formatting issue in PDF

+0

을 사용하여 필요한 페이지 나누기를 강제하는 것입니다 전체 페이지에 대해 한 번이 아닌 클래스? – Scott

답변

1

당신은 page-break-inside CSS 속성을 사용하여 페이지 나누기를 제어하기 위해 시도 할 수 있습니다.

이 속성은 비행 접시에서 지원되지만 모든 경우에 특히 구석을 피하기가 어려울 수 있습니다.

내 템플릿에서

, 나는 보통이 사용

tr{page-break-inside:avoid;} 

또 다른 옵션은 각에`글꼴 family` 선언을 반복 할 왜 page-break-before: always