2016-09-28 2 views
-5
public static final String[] HTML="D:/testing.htm","D:/testing.htm","D:/testing.htm","D:/testing.htm"}; 
public static final String DEST = ""D:/multiple_html_pages2.pdf"; 

      public static void main(String[] args) throws IOException, DocumentException { 
       File file = new File(DEST); 
       file.getParentFile().mkdirs(); 
       new ParseMultipleHtmlFiles2().createPdf(DEST); 
      } 


      public void createPdf(String file) throws IOException, DocumentException { 
       Document document = new Document(); 
       PdfWriter.getInstance(document, new FileOutputStream(file)); 
       document.open(); 

       for (String htmlfile : HTML) { 
        String html = Utilities.readFileToString(htmlfile); 
// parsing error are showing there : 

        ElementList list = XMLWorkerHelper.parseToElementList(htmlfile); 



        for (com.itextpdf.text.Element e : list) { 
         document.add(e); 
        } 
        document.newPage(); 
       } 
       document.close(); 
      } 
+2

어떤 오류 메시지가 표시 될까요? – Jens

+0

XMLWorkerHelper – user3442032

+0

유형에 대해 parseToElementList (String) 메소드가 정의되지 않았습니다. 패키지를 가져올 때 클래스를 가져 오시겠습니까? – Jens

답변

0

작동하지 않습니다, 당신이 쓰는 :

나는 그 조합이 작동하지 않을 수 iText를 2.1.5 버전 및 xmlworker 5.4.2

을 사용했다. XML Worker는 iText 2.1.5보다 훨씬 많이 소개되었습니다. iText 2.1.5는 2009 년 3 월에 출시되었지만 XML Worker 5.4.2는 2013 년 5 월에 출시 될 예정입니다.

숫자가 XML Worker 버전 번호와 일치하는 iText 버전을 사용해야합니다.

관련 문제