2015-02-04 4 views
2

저는 fop을 사용하여 파일을 pdf로 변환합니다. 참조 예외 : 나는 antennahouse에서 XSL 스타일 파일을 FO하는 XHTML로 변환 XHTML과의 Xalan을 변환 jTidy를 사용 Apache Fop 예외

org.apache.fop.fo.ValidationException: Invalid property encountered on "fo:block-container": display (See position 44:73) 

.

그것은 FO 파일의 라인 (44)이다 :이 문제를 해결하는 방법

<fo:block-container role="html:div" display="inline-block" width="30px"><fo:block start-indent="0pt" end-indent="0pt">Prov:</fo:block></fo:block-container> 

. 감사.

UPDATE : XHTML 코드 여기

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
    <title>Untitled Document</title> 
    <style type="text/css"> 
     * { 
     margin: 0; 
     padding: 0; 
     font-family: Arial, Helvetica, sans-serif; 
     font-size: 12px; 
     color: #333; 
     } 

     table.iss-account-aging-page { 
     border-collapse: collapse; 
     margin: 0 auto; 
     width: 100%; 
     font-size: 12px; 
     padding: 0; 
     color: #000; 
     border: 1px solid #666; 
     } 

     table.iss-account-aging-page tr { 
     page-break-inside: avoid; 
     } 

     table.iss-account-aging-page tr th { 
     text-align: center; 
     padding: 3px; 
     font-weight: bold; 
     color: #165ba8; 
     font-size: 12px; 
     border-bottom: 1px solid #666; 
     } 

     table.iss-account-aging-page tr th span { 
     color: #165ba8; 
     } 

     table.iss-account-aging-page tr td { 
     padding: 3px; 
     font-size: 12px; 
     color: #000; 
     border-bottom: 1px solid #666; 
     } 

     .iss-page-print-report-patient-left-info { 
     margin: 0 0 6px 0; 
     } 

     label.iss-page-print-report-patient-left-info { 
     width: 60px; 
     float: left; 
     text-align: right; 
     margin: 0 4px 0 0; 
     display: block; 
     clear: both; 
     font-weight: bold; 
     color: #444; 
     font-size: 11px; 
     } 

     .iss-account-aging-page-practice-name { 
     color: #2288FD; 
     font-family: Georgia, "Times New Roman", Times, serif; 
     font-size: 18px; 
     font-weight: bold; 
     text-align: center; 
     width: 100%; 
     } 

     table.iss-account-aging-page-footer-tbl { 
     float: right; 
     border-collapse: collapse; 
     margin-top: 10px; 
     width: 60%; 
     font-size: 12px; 
     } 

     table.iss-account-aging-page-footer-tbl tr td { 
     border: 1px solid #666; 
     padding: 3px 0; 
     color: #045e98; 
     text-align: center; 
     } 

     table.iss-account-aging-page-footer-tbl tr th { 
     text-align: center; 
     text-transform: uppercase; 
     font-weight: bold; 
     color: #03628b; 
     border: 1px solid #666; 
     padding: 3px 0; 
     } 

    </style> 
</head> 

<body> 
<div style="width:795px; margin:5px auto; overflow:hidden; padding:0;"> 
    <div class="iss-account-aging-page-practice-name"> 
     Sonas DDS    
    </div> 
    <div style="float:left; margin-left:10px; padding-bottom:5px;"> 
     <p>ADdress </p> 

     <p>Montclair, CA 91763</p> 

     <p>Phone:&nbsp;<span>111-111-1111</span></p> 

     <p>Fax:&nbsp;<span></span></p> 
    </div> 
    <div style="clear:both; margin: 5px 0 5px 0; border-top: 1px solid #ccc;"></div> 
    <div style="padding-left: 10px;"><span style="font-weight:bold;">Date:&nbsp;</span>11/07/2014</div> 
    <div style="clear:both; text-align:center; margin-bottom: 10px;"> 
     <p style="font-family: Georgia, Times New Roman,Times,serif; font-size: 16px; font-weight: bold; text-transform: uppercase"> 
     Reports 
     </p> 
    </div> 
    <table class="iss-account-aging-page-footer-tbl"> 
     <tr> 
     <th>0 - 30 DAYS</th> 
     <th>31 - 60 DAYS</th> 
     <th>61 - 90 DAYS</th> 
     <th>91+ DAYS</th> 
     </tr> 
     <tr> 
     <td>$0.00</td> 
     <td>$0.00</td> 
     <td>$0.00</td> 
     <td>$3,748,199.10</td> 
     </tr> 
    </table> 
    <div style="clear:both;">&nbsp;</div> 

    <table class="iss-account-aging-page"> 
     <tr> 
     <th colspan="2">PATIENT INFORMATION</th> 
     <th style="text-align:right;">0-30</th> 
     <th style="text-align:right;">31-60</th> 
     <th style="text-align:right;">61-90</th> 
     <th style="text-align:right;">91+</th> 
     </tr> 
        <tr> 
      <td style="width:174px; vertical-align:top; padding-left:4px; padding-right:26px;"> 
       <p style="font-family: Georgia, Times New Roman,Times,serif; font-size: 13px; font-weight: bold;">A Patient</p> 

           <p>ADdress2</p> 

           <p style="padding-bottom: 6px;">LA</p> 

       <p style="padding-bottom: 6px;">E-Mail: &nbsp;</p> 

       <div style="float:left; padding-bottom: 6px;"> 
        <div style="display: inline-block; width: 30px;">Item:</div> 
        <div style="display: inline-block;">item info</div> 
       </div> 
       <div style="clear: both;"></div> 
       <p style="padding-bottom: 6px;">item 2: item info</p> 

       <p style="padding-bottom: 6px;">item 3: item info</p> 
      </td> 
      <td style="width:166px; vertical-align:top;"> 
       <p class="iss-page-print-report-patient-left-info"> 
        <label class="iss-page-print-report-patient-left-info">Phone:</label>(H) 111-111-1111 
       </p> 
       <p class="iss-page-print-report-patient-left-info"> 
        <label class="iss-page-print-report-patient-left-info">&nbsp;</label>(M) &nbsp; 
       </p> 

       <p class="iss-page-print-report-patient-left-info"> 
        <label class="iss-page-print-report-patient-left-info">&nbsp;</label>(O) &nbsp; 
       </p> 

       <p class="iss-page-print-report-patient-left-info" style="text-transform: capitalize"> 
        <label class="iss-page-print-report-patient-left-info">Status:</label>Single 
       </p> 

       <p class="iss-page-print-report-patient-left-info"> 
        <label class="iss-page-print-report-patient-left-info">ID:</label>123456 
       </p> 

       <p class="iss-page-print-report-patient-left-info" style="text-transform: capitalize"> 
        <label class="iss-page-print-report-patient-left-info">Gender:</label>Male 
       </p> 

       <p class="iss-page-print-report-patient-left-info"> 
        <label class="iss-page-print-report-patient-left-info">Birth Date:</label>&nbsp; 
       </p> 
      </td> 
      <td style="vertical-align:top; width:70px;"> 
       <div style="text-align:right;">$0.00</div> 
      </td> 
      <td style="vertical-align:top; width:70px;"> 
       <div style="text-align:right;">$0.00</div> 
      </td> 
      <td style="vertical-align:top; width:70px;"> 
       <div style="text-align:right;">$0.00</div> 
      </td> 
      <td style="vertical-align:top; width:70px;"> 
       <div style="text-align:right;">$2,950.00</div> 
      </td> 
     </tr> 
    </table> 
</div> 
</body> 
</html> 

그래서 enter image description here

+0

FOP는 "display"속성이 유효한 [xsl-fo] (http://www.w3.org/TR/xsl/) 속성이 아니므로 제거해야한다고 알려줍니다. – lfurini

+0

감사합니다. xhtml 파일에서 스타일로 표시 속성을 제거하고 walkthrough이 오류가 있지만 CSS 스타일을 유지하지 않습니다. –

+1

"css 스타일을 유지하지 마세요"보다 좀 더 구체적이어야합니다. 정확히 출력에 문제가 있습니까? 또한 질문에 원래 XHTML 입력, XSLT 코드 (또는 XSL-FO 코드)가 부족하며 예상되는 결과가 어떻게 표시 될지 모릅니다. –

답변

2

, 당신은 xhtml to fo을 변환 AntennaHouse에서 XSLT 스타일 시트를 사용하여 내 자바 코드

FileInputStream FIS= null; 
     try { 
     //tidy 
     FIS = new FileInputStream("D:\\Test.xhtml"); 
     FileOutputStream FOS = new FileOutputStream("D:\\testXHTML.xHtml"); 
     Tidy T=new Tidy(); 
     T.setXHTML(true); 
     Document D = T.parseDOM(FIS,FOS); 

     //xalan 
     DOMSource xmlDomSource = new DOMSource(D); 
     DOMResult domResult = new DOMResult(); 
     Transformer transformerXalan = getTransformer("D:\\Test\\xhtml2fo-xsl-read-only\\xhtml2fo.xsl"); 
     transformerXalan.transform(xmlDomSource, new StreamResult(new FileOutputStream("D:\\result.fo"))); 

     //fop 
     FopFactory fopFactory = FopFactory.newInstance(); 
     OutputStream out = new BufferedOutputStream(new FileOutputStream(new File("D:/myfile.pdf"))); 
     org.apache.fop.apps.Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out); 
     TransformerFactory factory = TransformerFactory.newInstance(); 
     Transformer transformer = factory.newTransformer(); // identity transformer 
     Source src = new StreamSource(new File("D:\\result.fo")); 
     Result res = new SAXResult(fop.getDefaultHandler()); 
     transformer.transform(src, res); 
     out.close(); 
     } catch (Exception e) { 
     e.printStackTrace(); 
     } 

그리고 내 출력 , 그리고 나서 Apache FOP를 사용하여 pdf 출력을 생성합니다.

그 스타일 시트의 시작 부분에 주석 (강조 추가)한다고 :이 스타일은 원래가 서로 호환되지 않을 수 있습니다 XSL Formatter를 사용 , 가 될 안테나 하우스에 의해 개발되고있다

때문에 XSL-FO 프로세서.

따라서 다른 포맷터가 출력에 문제가있는 것은 놀랄 일이 아닙니다. 특히 XSL Formatter supports CSS properties (및 그 중 display) FOP는 그렇지 않습니다.

그러나, 원하는 출력 (고정 폭 인라인 쌓인 영역) 특정 inline-container S에서 요소와 속성 FO 표준을 이용하여 달성 될 수 :

<fo:block> 
    <!-- first "inline block" --> 
    <fo:inline-container role="html:div" width="40px"> 
     <fo:block start-indent="0pt" end-indent="0pt" background-color="#AAFFFF">Alpha</fo:block> 
    </fo:inline-container> 
    <!-- second "inline block" --> 
    <fo:inline-container role="html:div" width="40px"> 
     <fo:block start-indent="0pt" end-indent="0pt" background-color="#FFAAFF">Beta</fo:block> 
    </fo:inline-container> 
    <!-- third "inline block" --> 
    <fo:inline-container role="html:div" width="40px"> 
     <fo:block start-indent="0pt" end-indent="0pt" background-color="#FFFFAA">A a a a a a a</fo:block> 
    </fo:inline-container> 
    ... 
</fo:block> 

편집 : 깜빡 제안 솔루션 the trunk version of FOP과 작동하며, fo:inline-container의 구현은 FOP 1.1 출시 이후 완료되었습니다.

+0

고마워, 나는 fop으로 새롭다. 나는 비행 접시를 사용하고 도서관이 pdf로 HTML을 변환하고 css3을 지원할 수 있지만 상업적 목적으로는 거의 무료가 아님을 알고 싶습니다. –