-1
itext와 함께 일하는 pdf API, jpanel에는 27 행의 텍스트가 들어 있지만 pdf로 변환 할 때마다 24 행만 가져옵니다. 어떻게 모든 행이 추가되는지 확인하십시오. PDF 페이지. 아래에있는 내 코드itext는 모든 행을 표시하지 않습니다
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("C:\\Users\\CHRISGEEK\\Documents\\test.pdf"));
Rectangle two = new Rectangle(1000,500);
document.setPageSize(two);
document.setMargins(0, 0, 0, 0);
document.open();
PdfContentByte contentByte = writer.getDirectContent();
PdfTemplate template = contentByte.createTemplate(500, 500);
Graphics2D g2 = new PdfGraphics2D(contentByte, 500, 500);
answer_panel.print(g2);
g2.dispose();
contentByte.addTemplate(template, 30, 300);
writer.setPageEmpty(false);
document.newPage();
} catch (Exception e) {
e.printStackTrace();
}
finally{
if(document.isOpen()){
document.close();
}
괜찮 았지만 어떻게 호출하기 전에 정확히 분할합니까? 내용은 실제로 약 2500 행입니다. @Paulo – chrisgeeq
@chrisgeeq 충분히 큰 템플리트를 작성하고 모든 템플리트에 모든 JPanel 내용을 그릴 수 있습니다. 그런 다음이 단일 템플리트를 다른 오프셋을 사용하여 다른 pdf 페이지에 추가하므로 결과적으로 개별 페이지에 템플리트의 다른 섹션을 표시합니다. 자세한 내용은 cf. [이 답변] (http://stackoverflow.com/a/20851964/1729265). – mkl