2014-03-06 4 views
1

flying-saucer에 대한 경험이있는 사람이 있습니까? xhtml 페이지를 png으로 렌더링하고 있지만 최종 결과는 항상 16 픽셀입니다. 나머지는 잘립니다.플라잉 받침 - html에서 png로 항상 높이 16 픽셀 렌더링

Java2DRenderer renderer = new Java2DRenderer(xHtmlFile, width); // Image height should be set automatically 
BufferedImage buffImg = renderer.getImage(); // buffImg.getHeight always 16 

물론 xhtml 문서는 더 커야합니다.

그것은 다음은이

<body> 
    <div id="divThing"> 
     <span>text</span> 
     <span>more text</span> 
    </div> 
<body> 

처럼, 그것은 몇 span 요소를 기본적으로 하나 div있어 CSS를있다 :

html 
{ 
    color: #222; 
    font-size: 1em; 
    line-height: 1.4; 
    font-size:20px; 
} 

body 
{ 
    width:600px; 
} 

#divThing 
{ 
    position: absolute; 
    font-size:20px; 
    word-wrap:break-word; 
    word-wrap:break-all; 
    width:600px; 
} 

답변

0

대신 Graphics2DRenderer 클래스로 전환까지 종료, 방법 renderToImageAutoSize했다. 이것은 this thread.

에서 제안 된대로 new File(File_To_Convert).toURI().toURL().toString() 인수를 사용하여 더 잘 작동합니다.