minor api enhancements
This commit is contained in:
@ -17,7 +17,7 @@ import org.apache.pdfbox.pdmodel.font.PDType1Font;
|
||||
public class PDFDocument {
|
||||
|
||||
@Expose
|
||||
private PDFPaperSize paperSize;
|
||||
private final PDFPaperSize paperSize;
|
||||
|
||||
@Expose
|
||||
protected PDFFont standardFont;
|
||||
@ -30,7 +30,8 @@ public class PDFDocument {
|
||||
|
||||
private PDDocument pdDocument;
|
||||
|
||||
public PDFDocument() {
|
||||
public PDFDocument(PDFPaperSize ps) {
|
||||
this.paperSize = ps;
|
||||
this.contentList = new ArrayList<>();
|
||||
this.standardFont = new PDFFont("Helvetica", 11);
|
||||
this.fontMap = null;
|
||||
@ -79,7 +80,6 @@ public class PDFDocument {
|
||||
currentStartOfSubelement = posCloseBracket + 1;
|
||||
|
||||
String jsonSubString = templateString.substring(posOpenBracket, posCloseBracket + 1);
|
||||
System.out.println(jsonSubString);
|
||||
|
||||
// insert the list values into the gson string
|
||||
TableRow element = GsonUtil.getGsonInstance().fromJson(jsonSubString, TableRow.class);
|
||||
@ -102,7 +102,6 @@ public class PDFDocument {
|
||||
templateString = newString;
|
||||
currentPosInTemplate += listStartString.length();
|
||||
currentPosInTemplate += listEndString.length();
|
||||
System.out.println(templateString.substring(posOpenBracket-10, posCloseBracket + listStartString.length() + listEndString.length()+10));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -150,10 +149,6 @@ public class PDFDocument {
|
||||
return paperSize;
|
||||
}
|
||||
|
||||
public void setPaperSize(PDFPaperSize paperSize) {
|
||||
this.paperSize = paperSize;
|
||||
}
|
||||
|
||||
public PDFFont getStandardFont() {
|
||||
return standardFont;
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ public class PDFTableContent extends Content {
|
||||
|
||||
}
|
||||
|
||||
public PDFTableContent(PDFDocument doc, PDFFont hf, int x, int y) {
|
||||
public PDFTableContent(PDFDocument doc, PDFFont hf, float x, float y) {
|
||||
super(doc, x, y);
|
||||
this.columSizes = new ArrayList<>();
|
||||
this.data = new ArrayList<>();
|
||||
|
||||
@ -62,7 +62,7 @@ public class PDFTemplate {
|
||||
pdfDoc.getPdDocument().addPage(page);
|
||||
|
||||
PDPageContentStream cos = new PDPageContentStream(pdfDoc.getPdDocument(), page, AppendMode.APPEND, false);
|
||||
Coordinate coord = null;
|
||||
Coordinate coord = new Coordinate(page.getMediaBox().getLowerLeftX(), page.getMediaBox().getUpperRightY());
|
||||
for (Content content : pdfDoc.getContentList()) {
|
||||
content.setDocument(pdfDoc); // FIXME move to serialization
|
||||
content.setRect(page.getMediaBox());
|
||||
|
||||
@ -38,11 +38,10 @@ public class PDFDocumentTest {
|
||||
@Test
|
||||
public void testToJson() throws FileNotFoundException, IOException, ConfigurationException, TemplateException {
|
||||
System.out.println("testToJson");
|
||||
PDFDocument doc = new PDFDocument();
|
||||
PDFDocument doc = new PDFDocument(PDFPaperSize.A4);
|
||||
doc.addFont("bold", new PDFFont("Helvetica-Bold", 12, 2));
|
||||
doc.addFont("helv12", new PDFFont("Helvetica", 12, 2));
|
||||
|
||||
doc.setPaperSize(PDFPaperSize.A4);
|
||||
PDFTextContent addressContent = new PDFTextContent(doc, 40F, 692F, "Max Mustermann")
|
||||
.addLine("Musterstraße 123")
|
||||
.addLine("12345 Musterhausen");
|
||||
|
||||
Reference in New Issue
Block a user