这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.nio.file.Paths;
import java.util.stream.Stream;

import com.itextpdf.text.DocumentException;
import com.itextpdf.text.BadElementException;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Document;
Expand Down Expand Up @@ -55,19 +56,19 @@ private static void addTableHeader(PdfPTable table) {
});
}

private static void setAbsoluteColumnWidths(PdfPTable table) {
private static void setAbsoluteColumnWidths(PdfPTable table) throws DocumentException {
table.setTotalWidth(500); // Sets total table width to 500 points
table.setLockedWidth(true);
float[] columnWidths = {100f, 200f, 200f}; // Defines three columns with absolute widths
table.setWidths(columnWidths);
}

private static void setAbsoluteColumnWidthsInTableWidth(PdfPTable table) {
private static void setAbsoluteColumnWidthsInTableWidth(PdfPTable table) throws DocumentException {
table.setTotalWidth(new float[] {72f, 144f, 216f}); // First column 1 inch, second 2 inches, third 3 inches
table.setLockedWidth(true);
}

private static void setRelativeColumnWidths(PdfPTable table) {
private static void setRelativeColumnWidths(PdfPTable table) throws DocumentException {
// Set column widths (relative)
table.setWidths(new float[] {1, 2, 1});
table.setWidthPercentage(80); // Table width as 80% of page width
Expand Down