From 168371b327ef9fa94af48ccb710f3ffc2089b0f1 Mon Sep 17 00:00:00 2001 From: Alexander Kastler Date: Sat, 24 Apr 2021 18:36:05 +0200 Subject: [PATCH] #180 Shift bottom margin by powered by line height --- .../Printing/PageFooterHandler.cs | 13 +++++++++---- .../Printing/PdfPrintService.cs | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/BraunauMobil.VeloBasar/Printing/PageFooterHandler.cs b/src/BraunauMobil.VeloBasar/Printing/PageFooterHandler.cs index 2cb9719f..fa7fcb0a 100644 --- a/src/BraunauMobil.VeloBasar/Printing/PageFooterHandler.cs +++ b/src/BraunauMobil.VeloBasar/Printing/PageFooterHandler.cs @@ -1,4 +1,5 @@ -using BraunauMobil.VeloBasar.Resources; +using BraunauMobil.VeloBasar.Models; +using BraunauMobil.VeloBasar.Resources; using iText.IO.Font.Constants; using iText.Kernel.Events; using iText.Kernel.Font; @@ -10,11 +11,15 @@ namespace BraunauMobil.VeloBasar.Printing { public class PageFooterHandler : IEventHandler { + public const float Height = 6; + + private readonly Margins _pageMargins; private readonly Document _doc; private readonly IStringLocalizer _localizer; - public PageFooterHandler(Document doc, IStringLocalizer localizer) + public PageFooterHandler(Margins pageMargins, Document doc, IStringLocalizer localizer) { + _pageMargins = pageMargins; _doc = doc; _localizer = localizer; } @@ -27,8 +32,8 @@ public void HandleEvent(Event ev) var pageNumber = docEvent.GetDocument().GetPageNumber(page); var canvas = new PdfCanvas(page); canvas.BeginText(); - canvas.SetFontAndSize(PdfFontFactory.CreateFont(StandardFonts.HELVETICA), 6); - canvas.MoveText(_doc.GetLeftMargin(), 10); + canvas.SetFontAndSize(PdfFontFactory.CreateFont(StandardFonts.HELVETICA), Height); + canvas.MoveText(_doc.GetLeftMargin(), _pageMargins.Bottom); canvas.ShowText(_localizer["Seite {0} von {1}", pageNumber, docEvent.GetDocument().GetNumberOfPages()]); canvas.ShowText(" - powered by https://github.com/braunau-mobil/velo-basar"); canvas.EndText().Release(); diff --git a/src/BraunauMobil.VeloBasar/Printing/PdfPrintService.cs b/src/BraunauMobil.VeloBasar/Printing/PdfPrintService.cs index 37a2de98..e7531ef5 100644 --- a/src/BraunauMobil.VeloBasar/Printing/PdfPrintService.cs +++ b/src/BraunauMobil.VeloBasar/Printing/PdfPrintService.cs @@ -254,8 +254,8 @@ private byte[] CreateTransactionPdf(PrintSettings settings, Action