0
제 질문은 다음과 같은 작업을 수행하는 것입니다. 내 pdf를 세 개의 열로 나누고 싶습니다.iText PDF 문서에는 3 개의 열이 포함되어야합니다.
그래서 단락을 추가하면 첫 번째 열로 이동하고 첫 번째 열이 이미 완료되었거나 완료되면 두 번째 열로 계속 이동합니다. 내 질문을 이해하길 바래. 나는 영어로 좋지 않다.
저는 iText PDF를 사용하고 있습니다. 해당 테이블은 1000 열을 사용할 경우에
9:00AM Meal 1
Chicken
지금, 나는 그것이 첫 번째 페이지의 다음 열에서 계속 하시겠습니까 :
예를 들어 나는이처럼 보이는 테이블이 있습니다. Heres 테이블에 대한 내 코드와 제발 나를 안내하는 방법을 그냥 초보자가 원인.
try {
Document document = new Document(PageSize.A4, 25, 25, 25, 25);
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("D:\\PURCHASEORDER\\" + one + ".pdf"));
document.open();
Rectangle rect0 = writer.getPageSize();
PdfPTable table0 = new PdfPTable(new float[]{6, 4});
table0.setTotalWidth(527);
table0.getDefaultCell().setBorder(Rectangle.NO_BORDER);
table0.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
table0.addCell(new Paragraph("****************D", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, BaseColor.BLACK)));
table0.addCell(new Paragraph(" ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 14, BaseColor.BLACK)));
table0.addCell(new Paragraph("**********************************", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, BaseColor.BLACK)));
table0.addCell(new Paragraph(" ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 14, BaseColor.BLACK)));
table0.addCell(new Paragraph("**************************", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, BaseColor.BLACK)));
table0.addCell(new Paragraph(" ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 14, BaseColor.BLACK)));
table0.setWidthPercentage(100);
document.add(table0);
try {
Document document = new Document(PageSize.A4, 50, 25, 25, 25);
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("D:\\PURCHASEORDER\\" + one + ".pdf"));
document.open();
Rectangle rect0 = writer.getPageSize();
PdfPTable table0 = new PdfPTable(new float[]{6, 4});
table0.setTotalWidth(527);
table0.getDefaultCell().setBorder(Rectangle.NO_BORDER);
table0.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
table0.addCell(new Paragraph("FABLUES PAZFOOD", FontFactory.getFont(FontFactory.TIMES_BOLD, 18, BaseColor.BLACK)));
table0.addCell(new Paragraph(" ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 14, BaseColor.BLACK)));
table0.addCell(new Paragraph("#15 13th-15th Street, Nazareth, Cagayan de Oro", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, BaseColor.BLACK)));
table0.addCell(new Paragraph(" ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 14, BaseColor.BLACK)));
table0.addCell(new Paragraph("Tel No: (088) 8571296/728-901", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, BaseColor.BLACK)));
table0.addCell(new Paragraph(" ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 14, BaseColor.BLACK)));
table0.setWidthPercentage(100);
document.add(table0);
try {
Class.forName(driver);
conn = DriverManager.getConnection(url + db, user, pass);
Statement st = conn.createStatement();
String zero = dates.getSelectedItem().toString();
String sql = "select count(*) as hehe from purchaseorder where servedate = '" + zero + "' and time = 'AM'";
pst = conn.prepareStatement(sql);
rs = pst.executeQuery();
Rectangle react = writer.getPageSize();
PdfPTable table2 = new PdfPTable(new float[]{7, 3});
table2.setTotalWidth(527);
table2.getDefaultCell().setBorder(Rectangle.NO_BORDER);
PdfPCell cell = new PdfPCell(new Paragraph(""));
cell.setColspan(8);
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
cell.setBackgroundColor(BaseColor.GRAY);
table2.addCell(cell);
table2.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
if (rs.next()) {
String v1 = rs.getString("hehe");
table2.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
table2.addCell(new Paragraph("KITCHEN AM- " + one + "", FontFactory.getFont(FontFactory.TIMES_ROMAN, 14, BaseColor.BLACK)));
table2.addCell(new Paragraph("TOTAL Number: " + v1 + "", FontFactory.getFont(FontFactory.TIMES_ROMAN, 14, BaseColor.BLACK)));
}
table2.addCell(new Paragraph(" ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, BaseColor.BLACK)));
table2.addCell(new Paragraph(" ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, BaseColor.BLACK)));
table2.setWidthPercentage(100);
document.add(table2);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
try {
Class.forName(driver);
conn = DriverManager.getConnection(url + db, user, pass);
Statement st = conn.createStatement();
String zero = dates.getSelectedItem().toString();
String sql = " Select purchaseorder.po_id,concat(purchaseorder.servetime,' ',purchaseorder.time) as times, customer.customer from purchaseorder join customer on customer.customer_id = purchaseorder.customer_id where servedate = '" + zero + "' and purchaseorder.time = 'AM' order by servetime DESC";
pst = conn.prepareStatement(sql);
rs = pst.executeQuery();
Rectangle react = writer.getPageSize();
PdfPTable table2 = new PdfPTable(new float[]{2, 4, 2, 4, 4});
table2.setTotalWidth(527);
PdfPCell cell = new PdfPCell(new Paragraph(""));
cell.setColspan(8);
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
cell.setBackgroundColor(BaseColor.GRAY);
table2.addCell(cell);
table2.getDefaultCell().setBorder(NO_BORDER);
table2.addCell(new Paragraph(" ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, BaseColor.BLACK)));
table2.addCell(new Paragraph(" ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, BaseColor.BLACK)));
table2.addCell(new Paragraph(" ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, BaseColor.BLACK)));
table2.addCell(new Paragraph(" ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, BaseColor.BLACK)));
table2.addCell(new Paragraph(" ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, BaseColor.BLACK)));
while (rs.next()) {
String v0 = rs.getString("po_id");
String v1 = rs.getString("times");
String v2 = rs.getString("customer");
table2.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
table2.addCell(new Paragraph("" + v1 + "", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, BaseColor.BLACK)));
table2.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
table2.addCell(new Paragraph("" + v2 + "", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, BaseColor.BLACK)));
table2.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
table2.addCell(new Paragraph(" ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, BaseColor.BLACK)));
table2.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
table2.addCell(new Paragraph(" ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, BaseColor.BLACK)));
table2.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
table2.addCell(new Paragraph(" ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, BaseColor.BLACK)));
String ttt = "select type,code, quantity, stockname from orderlistview where po_id = '" + v0 + "'";
pst1 = conn.prepareStatement(ttt);
rs2 = pst1.executeQuery();
while (rs2.next()) {
String a1 = rs2.getString("code");
String a2 = rs2.getString("type");
String b00 = rs2.getString("quantity");
String b11 = rs2.getString("stockname");
table2.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
table2.addCell(new Paragraph("", FontFactory.getFont(FontFactory.TIMES_BOLD, 8, BaseColor.BLACK)));
table2.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
table2.addCell(new Paragraph("" + b00 + " " + b11 + "", FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, BaseColor.BLACK)));
table2.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
table2.addCell(new Paragraph(" ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, BaseColor.BLACK)));
table2.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
table2.addCell(new Paragraph(" ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, BaseColor.BLACK)));
table2.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
table2.addCell(new Paragraph(" ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, BaseColor.BLACK)));
}
}
table2.addCell(new Paragraph(" ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, BaseColor.BLACK)));
table2.addCell(new Paragraph(" ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, BaseColor.BLACK)));
table2.addCell(new Paragraph(" ", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, BaseColor.BLACK)));
table2.setWidthPercentage(100);
document.add(table2);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
document.close();
String pdfFile = "D:\\PURCHASEORDER\\" + one + ".pdf";
File f = new File(pdfFile);
if (pdfFile.toString().endsWith(".pdf")) {
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + pdfFile);
} else {
//For cross platform use
Desktop desktop = Desktop.getDesktop();
desktop.open(f);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
괜찮아요. 이걸 시도해 봅니다. –
나는 그것을 얻지 못하고 있습니다. t_T –
당신은 무엇을 얻지 못합니까? – mkl