这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions text-processing-libraries-modules/pdf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@
</build>

<properties>
<pdfbox-tools.version>3.0.0</pdfbox-tools.version>
<pdfbox-tools.version>3.0.5</pdfbox-tools.version>
<pdf2dom.version>2.0.1</pdf2dom.version>
<itextpdf.version>5.5.13.3</itextpdf.version>
<itextpdf.version>5.5.13.4</itextpdf.version>
<xmlworker.version>5.5.10</xmlworker.version>
<poi-scratchpad.version>3.15</poi-scratchpad.version>
<batik-transcoder.version>1.8</batik-transcoder.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public static void main(String[] args) {

PdfPTable table = new PdfPTable(3);
addTableHeader(table);
setAbsoluteColumnWidths(table);
//setAbsoluteColumnWidthsInTableWidth(table);
//setRelativeColumnWidths(table);
addRows(table);
addCustomRows(table);

Expand All @@ -52,6 +55,24 @@ private static void addTableHeader(PdfPTable table) {
});
}

private static void setAbsoluteColumnWidths(PdfPTable table) {
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) {
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) {
// Set column widths (relative)
table.setWidths(new float[] {1, 2, 1});
table.setWidthPercentage(80); // Table width as 80% of page width
}

private static void addRows(PdfPTable table) {
table.addCell("row 1, col 1");
table.addCell("row 1, col 2");
Expand Down