Skip to content

Commit

Permalink
pdf renderer added
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Mautsch committed Nov 13, 2024
1 parent a26d326 commit d7a9a3b
Showing 1 changed file with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,9 @@ private static void addConditionHeader(Document document, InvoiceData invoiceDat

document.add(new Paragraph("\n\n\n\n"));

// Paragraph for the condition (Bold)
var diagnosisParagraph = new Paragraph("Diagnosis:\n", fontBold);
diagnosisParagraph.add(new Phrase(invoiceData.condition, fontNormal));

// Add the condition to the document
document.add(diagnosisParagraph);
document.add(new Paragraph("\n"));
}
Expand Down Expand Up @@ -140,7 +138,6 @@ private static void addChargeItems(Document document, java.util.List<ChargeItem>
private static void addHeaderRow(PdfPTable table) {
var fontBold = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12);

// Create cells with bold text for each column title
table.addCell(createCell(new Phrase("Date", fontBold)));
table.addCell(createCell(new Phrase("Quantity", fontBold)));
table.addCell(createCell(new Phrase("Code", fontBold)));
Expand All @@ -160,15 +157,14 @@ private static void addDataRow(PdfPTable table, ChargeItem item) {
table.addCell(createCell(new Phrase(String.format("%.2f", item.amount()), fontNormal)));
}

private static PdfPCell createCell(Phrase fontBold) {
var cell = new PdfPCell(fontBold);
private static PdfPCell createCell(Phrase font) {
var cell = new PdfPCell(font);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBorder(Rectangle.NO_BORDER);
return cell;
}

private static void addTotalAmount(Document document, PdfPTable table, double totalAmount) {
// Add the total amount row
var fontBold = FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12);
PdfPCell totalCell = new PdfPCell(new Phrase("Total", fontBold));
totalCell.setColspan(5); // Span across 5 columns
Expand All @@ -178,10 +174,8 @@ private static void addTotalAmount(Document document, PdfPTable table, double to

PdfPCell amountCell = new PdfPCell(new Phrase(String.format("%.2f €", totalAmount), fontBold));
amountCell.setHorizontalAlignment(Element.ALIGN_CENTER);
totalCell.setBorder(Rectangle.NO_BORDER);
amountCell.setBorder(Rectangle.NO_BORDER);
table.addCell(amountCell);
}



}

0 comments on commit d7a9a3b

Please sign in to comment.