java itext pdf library |为什么itext表在设置totalwidth后没有占用100%的空间?

ovfsdjhp  于 2021-07-08  发布在  Java
关注(0)|答案(0)|浏览(334)

为什么即使设置totalwidth,itext表也不能占用100%的空间?

代码:

PdfPTable items = new PdfPTable(6);
      items.setTotalWidth(100);
      items.setWidths(new int[] { 10, 10,10,50, 10, 10 });
      items.addCell(new Paragraph("Item", PdfWriterUtils.createFont(12, BOLD)));
      items.addCell(new Paragraph("Qty. Due", PdfWriterUtils.createFont(12, BOLD)));
      items.addCell(new Paragraph("Qty. Shipped", PdfWriterUtils.createFont(12, BOLD)));
      items.addCell(new Paragraph("Description", PdfWriterUtils.createFont(12, BOLD)));
      items.addCell(new Paragraph("Unit Price", PdfWriterUtils.createFont(12, BOLD)));
      items.addCell(new Paragraph("Amount", PdfWriterUtils.createFont(12, BOLD)));
      items.completeRow();
      items.addCell(new Paragraph("", PdfWriterUtils.createFont(12, NORMAL)));
      items.addCell(new Paragraph("", PdfWriterUtils.createFont(12, NORMAL)));
      items.addCell(new Paragraph("", PdfWriterUtils.createFont(12, NORMAL)));
      items.addCell(new Paragraph("158453-1", PdfWriterUtils.createFont(12, NORMAL)));
      items.addCell(new Paragraph("4725.00", PdfWriterUtils.createFont(12, NORMAL)));
      items.addCell(new Paragraph("4725.00", PdfWriterUtils.createFont(12, NORMAL)));
      items.completeRow();
      items.addCell(new Paragraph("1", PdfWriterUtils.createFont(12, NORMAL)));
      items.addCell(new Paragraph("1", PdfWriterUtils.createFont(12, NORMAL)));
      items.addCell(new Paragraph("1", PdfWriterUtils.createFont(12, NORMAL)));
      items.addCell(new Paragraph("Expedite Charge", PdfWriterUtils.createFont(12, NORMAL)));
      items.addCell(new Paragraph("4725.00", PdfWriterUtils.createFont(12, NORMAL)));
      items.addCell(new Paragraph("4725.00", PdfWriterUtils.createFont(12, NORMAL)));
      items.completeRow();
      items.addCell(new Paragraph("1", PdfWriterUtils.createFont(12, NORMAL)));
      items.addCell(new Paragraph("1", PdfWriterUtils.createFont(12, NORMAL)));
      items.addCell(new Paragraph("1", PdfWriterUtils.createFont(12, NORMAL)));
      items.addCell(new Paragraph("Unit Charge", PdfWriterUtils.createFont(12, NORMAL)));
      items.addCell(new Paragraph("4725.00", PdfWriterUtils.createFont(12, NORMAL)));
      items.addCell(new Paragraph("4725.00", PdfWriterUtils.createFont(12, NORMAL)));
      items.completeRow();
      items.addCell(new Paragraph("", PdfWriterUtils.createFont(12, NORMAL)));
      items.addCell(new Paragraph("", PdfWriterUtils.createFont(12, NORMAL)));
      items.addCell(new Paragraph("", PdfWriterUtils.createFont(12, NORMAL)));
      items.addCell(new Paragraph("", PdfWriterUtils.createFont(12, NORMAL)));
      items.addCell(new Paragraph("Total", PdfWriterUtils.createFont(12, BOLD)));
      items.addCell(new Paragraph("14175.00", PdfWriterUtils.createFont(12, BOLD)));
      items.completeRow();

这是创建代码:

final Document doc = new Document();
    //final PdfAWriter writer = PdfAWriter.getInstance(doc, outputStream, PdfAConformanceLevel.PDF_A_1A);
    final PdfWriter writer = PdfWriter.getInstance(doc, outputStream);
    writer.createXmpMetadata();
    doc.open();

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题