«
Předchozí
|
Další
»
Revize 6af5c07d
Přidáno uživatelem Vojtěch Danišík před téměř 4 roky(ů)
- ID 6af5c07d670cc4d262f088fd7255c1bdf89fdbe4
- Rodič ea163a4c
src/main/java/vldc/aswi/utils/ExporterPDF.java | ||
---|---|---|
1 | 1 |
package vldc.aswi.utils; |
2 | 2 |
|
3 |
import be.quodlibet.boxable.BaseTable; |
|
4 | 3 |
import com.lowagie.text.*; |
5 | 4 |
import com.lowagie.text.Font; |
6 | 5 |
import com.lowagie.text.alignment.HorizontalAlignment; |
7 | 6 |
import com.lowagie.text.alignment.VerticalAlignment; |
8 | 7 |
import com.lowagie.text.pdf.PdfWriter; |
9 |
import org.apache.pdfbox.pdmodel.PDPage; |
|
10 |
import org.apache.pdfbox.pdmodel.font.PDType1Font; |
|
11 | 8 |
import vldc.aswi.model.table.contingencyTable.ContingencyTableRow; |
12 | 9 |
import vldc.aswi.model.table.contingencyTable.ContingencyTableRowCell; |
13 | 10 |
|
14 |
import java.awt.*; |
|
15 | 11 |
import java.io.File; |
16 | 12 |
import java.io.FileOutputStream; |
17 | 13 |
import java.util.List; |
... | ... | |
69 | 65 |
doc.close(); |
70 | 66 |
} catch (Exception e) { |
71 | 67 |
|
68 |
System.out.println("PDF export failed."); |
|
72 | 69 |
} |
73 | 70 |
} |
74 | 71 |
|
... | ... | |
159 | 156 |
|
160 | 157 |
return columnCount; |
161 | 158 |
} |
162 |
|
|
163 |
|
|
164 |
public static void exportt(File tmpFile, List<ContingencyTableRow> contingencyTableRows) { |
|
165 |
/* |
|
166 |
//Dummy Table |
|
167 |
float margin = 50; |
|
168 |
|
|
169 |
// starting y position is whole page height subtracted by top and bottom margin |
|
170 |
float yStartNewPage = myPage.getMediaBox().getHeight() - (2 * margin); |
|
171 |
|
|
172 |
// we want table across whole page width (subtracted by left and right margin ofcourse) |
|
173 |
float tableWidth = myPage.getMediaBox().getWidth() - (2 * margin); |
|
174 |
|
|
175 |
boolean drawContent = true; |
|
176 |
float yStart = yStartNewPage; |
|
177 |
float bottomMargin = 70; |
|
178 |
// y position is your coordinate of top left corner of the table |
|
179 |
float yPosition = 550; |
|
180 |
|
|
181 |
BaseTable table = new BaseTable(yPosition, yStartNewPage, bottomMargin, tableWidth, margin, mainDocument, myPage, true, drawContent); |
|
182 |
|
|
183 |
|
|
184 |
Row<PDPage> headerRow = table.createRow(15f); |
|
185 |
Cell<PDPage> cell = headerRow.createCell(100, "Header"); |
|
186 |
table.addHeaderRow(headerRow); |
|
187 |
|
|
188 |
|
|
189 |
Row<PDPage> row = table.createRow(12); |
|
190 |
cell = row.createCell(30, "Data 1"); |
|
191 |
cell = row.createCell(70, "Some value"); |
|
192 |
|
|
193 |
table.draw(); |
|
194 |
|
|
195 |
|
|
196 |
contentStream.close(); |
|
197 |
mainDocument.addPage(myPage); |
|
198 |
mainDocument.save("testfile.pdf"); |
|
199 |
mainDocument.close(); |
|
200 |
*/ |
|
201 |
} |
|
202 | 159 |
} |
Také k dispozici: Unified diff
final commit