From 4d338604ba603678d0402262d5414b06855416ae Mon Sep 17 00:00:00 2001 From: Alex August Schlote Date: Fri, 22 Nov 2024 14:37:08 +0100 Subject: [PATCH] Fix pdf space table (#1465) * refactor(createPdfKitDocument): create variable to define pdf width size * refactor(addTable): reset the doc.y after print table * refactor(addTableInfo): print table info data with the current doc.y * refactor: print other details and distance info data with the current doc.y * refactor(addNewPageInCaseMissingVerticalSpace): decrease minimal space to jump to a new page * test: update tests * refactor(getStartYPosition): delete unneeded file --- .../addNewPageInCaseMissingVerticalSpace.ts | 2 +- .../__test__/addCompensationAmount.test.ts | 14 +++---- .../__test__/addDistanceInfo.test.ts | 8 ++-- .../__test__/addOtherDetailsItinerary.test.ts | 6 +-- .../addCompensationAmount.ts | 9 +---- .../compensationAmount/addDistanceInfo.ts | 37 ++++++------------- .../addOtherDetailsItinerary.ts | 28 +++++++++----- .../compensationAmount/getStartYPosition.ts | 7 ---- .../reason/factsOfCases/createFactsOfCases.ts | 16 +------- .../table/__test__/addTableInfo.test.ts | 17 +-------- .../reason/factsOfCases/table/addTable.ts | 6 +-- .../reason/factsOfCases/table/addTableInfo.ts | 24 ++++++------ app/services/pdf/createPdfKitDocument.ts | 1 + 13 files changed, 64 insertions(+), 111 deletions(-) delete mode 100644 app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/getStartYPosition.ts diff --git a/app/domains/fluggastrechte/services/pdf/sections/reason/addNewPageInCaseMissingVerticalSpace.ts b/app/domains/fluggastrechte/services/pdf/sections/reason/addNewPageInCaseMissingVerticalSpace.ts index 60bdeb7bc..004c2f615 100644 --- a/app/domains/fluggastrechte/services/pdf/sections/reason/addNewPageInCaseMissingVerticalSpace.ts +++ b/app/domains/fluggastrechte/services/pdf/sections/reason/addNewPageInCaseMissingVerticalSpace.ts @@ -1,7 +1,7 @@ import type PDFDocument from "pdfkit"; import { PDF_HEIGHT_SEIZE } from "~/services/pdf/createPdfKitDocument"; -const MAX_VERTICAL_SPACE = PDF_HEIGHT_SEIZE - 90; +export const MAX_VERTICAL_SPACE = PDF_HEIGHT_SEIZE - 50; export const addNewPageInCaseMissingVerticalSpace = ( doc: typeof PDFDocument, diff --git a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/__test__/addCompensationAmount.test.ts b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/__test__/addCompensationAmount.test.ts index cef4560c7..68be7d486 100644 --- a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/__test__/addCompensationAmount.test.ts +++ b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/__test__/addCompensationAmount.test.ts @@ -41,7 +41,7 @@ describe("addCompensationAmount", () => { const mockStruct = mockPdfKitDocumentStructure(); const mockDoc = mockPdfKitDocument(mockStruct); - addCompensationAmount(mockDoc, mockStruct, userDataMock, 0); + addCompensationAmount(mockDoc, mockStruct, userDataMock); expect(addOtherDetailsItinerary).toBeCalledTimes(1); }); @@ -50,7 +50,7 @@ describe("addCompensationAmount", () => { const mockStruct = mockPdfKitDocumentStructure(); const mockDoc = mockPdfKitDocument(mockStruct); - addCompensationAmount(mockDoc, mockStruct, userDataMock, 0); + addCompensationAmount(mockDoc, mockStruct, userDataMock); expect(addDistanceInfo).toBeCalledTimes(1); }); @@ -59,7 +59,7 @@ describe("addCompensationAmount", () => { const mockStruct = mockPdfKitDocumentStructure(); const mockDoc = mockPdfKitDocument(mockStruct); - addCompensationAmount(mockDoc, mockStruct, userDataMock, 0); + addCompensationAmount(mockDoc, mockStruct, userDataMock); expect(mockDoc.text).toHaveBeenCalledWith( DEMANDED_COMPENSATION_PAYMENT_TEXT, @@ -75,7 +75,7 @@ describe("addCompensationAmount", () => { isWeiterePersonen: YesNoAnswer.Enum.yes, }; - addCompensationAmount(mockDoc, mockStruct, userDataWeiterePersonenMock, 0); + addCompensationAmount(mockDoc, mockStruct, userDataWeiterePersonenMock); expect(mockDoc.text).toHaveBeenCalledWith( OTHER_PASSENGERS_DEMANDED_COMPENSATION_PAYMENT_TEXT, @@ -86,7 +86,7 @@ describe("addCompensationAmount", () => { const mockStruct = mockPdfKitDocumentStructure(); const mockDoc = mockPdfKitDocument(mockStruct); - addCompensationAmount(mockDoc, mockStruct, userDataMock, 0); + addCompensationAmount(mockDoc, mockStruct, userDataMock); expect(addNewPageInCaseMissingVerticalSpace).toBeCalledTimes(1); }); @@ -95,7 +95,7 @@ describe("addCompensationAmount", () => { const mockStruct = mockPdfKitDocumentStructure(); const mockDoc = mockPdfKitDocument(mockStruct); - addCompensationAmount(mockDoc, mockStruct, userDataMock, 0); + addCompensationAmount(mockDoc, mockStruct, userDataMock); expect(addMultiplePersonsInfo).toBeCalledTimes(1); }); @@ -104,7 +104,7 @@ describe("addCompensationAmount", () => { const mockStruct = mockPdfKitDocumentStructure(); const mockDoc = mockPdfKitDocument(mockStruct); - addCompensationAmount(mockDoc, mockStruct, userDataMock, 0); + addCompensationAmount(mockDoc, mockStruct, userDataMock); expect(addWitnessesInfo).toBeCalledTimes(1); }); diff --git a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/__test__/addDistanceInfo.test.ts b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/__test__/addDistanceInfo.test.ts index 0ab9b1301..cd1345078 100644 --- a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/__test__/addDistanceInfo.test.ts +++ b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/__test__/addDistanceInfo.test.ts @@ -63,12 +63,11 @@ describe("addDistanceInfo", () => { isWeiterePersonen: YesNoAnswer.Enum.no, }; - addDistanceInfo(mockDoc, userDataWeiterePersonenMock, 0); + addDistanceInfo(mockDoc, userDataWeiterePersonenMock); expect(mockDoc.text).toHaveBeenCalledWith( `Die Distanz zwischen ${startAirportMock} und ${endAirportMock} beträgt nach Großkreismethode ca. ${distanceValueMock} km. ${ARTICLE_AIR_PASSENGER_REGULATION_TEXT} ${compensationValueMock} €.`, PDF_MARGIN_HORIZONTAL, - undefined, ); }); @@ -81,12 +80,11 @@ describe("addDistanceInfo", () => { isWeiterePersonen: YesNoAnswer.Enum.yes, }; - addDistanceInfo(mockDoc, userDataWeiterePersonenMock, 0); + addDistanceInfo(mockDoc, userDataWeiterePersonenMock); expect(mockDoc.text).toHaveBeenCalledWith( `Die Distanz zwischen ${startAirportMock} und ${endAirportMock} beträgt nach Großkreismethode ca. ${distanceValueMock} km. ${ARTICLE_AIR_PASSENGER_REGULATION_TEXT} ${compensationValueMock} € pro Person, insgesamt aus eigenem und abgetretenem Recht damit eine Gesamtsumme von ${compensationValueMock} €.`, PDF_MARGIN_HORIZONTAL, - undefined, ); }); @@ -94,7 +92,7 @@ describe("addDistanceInfo", () => { const mockStruct = mockPdfKitDocumentStructure(); const mockDoc = mockPdfKitDocument(mockStruct); - addDistanceInfo(mockDoc, userDataMock, 0); + addDistanceInfo(mockDoc, userDataMock); expect(addNewPageInCaseMissingVerticalSpace).toBeCalled(); }); diff --git a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/__test__/addOtherDetailsItinerary.test.ts b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/__test__/addOtherDetailsItinerary.test.ts index fa67885a9..38c0d7974 100644 --- a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/__test__/addOtherDetailsItinerary.test.ts +++ b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/__test__/addOtherDetailsItinerary.test.ts @@ -13,12 +13,11 @@ describe("addOtherDetailsItinerary", () => { const mockStruct = mockPdfKitDocumentStructure(); const mockDoc = mockPdfKitDocument(mockStruct); - addOtherDetailsItinerary(mockDoc, 0, userDataMock.zusaetzlicheAngaben); + addOtherDetailsItinerary(mockDoc, userDataMock.zusaetzlicheAngaben); expect(mockDoc.text).toHaveBeenCalledWith( OTHER_DETAILS_ITINERARY, expect.anything(), - expect.anything(), ); expect(mockDoc.text).toHaveBeenCalledWith(userDataMock.zusaetzlicheAngaben); @@ -28,12 +27,11 @@ describe("addOtherDetailsItinerary", () => { const mockStruct = mockPdfKitDocumentStructure(); const mockDoc = mockPdfKitDocument(mockStruct); - addOtherDetailsItinerary(mockDoc, 0); + addOtherDetailsItinerary(mockDoc); expect(mockDoc.text).not.toHaveBeenCalledWith( OTHER_DETAILS_ITINERARY, expect.anything(), - expect.anything(), ); }); }); diff --git a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/addCompensationAmount.ts b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/addCompensationAmount.ts index 2102d6ce9..87245cf9d 100644 --- a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/addCompensationAmount.ts +++ b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/addCompensationAmount.ts @@ -17,20 +17,15 @@ export const addCompensationAmount = ( doc: typeof PDFDocument, documentStruct: PDFKit.PDFStructureElement, userData: FluggastrechtContext, - compensationStartYPosition: number, ) => { const compensationSect = doc.struct("Sect"); compensationSect.add( doc.struct("P", {}, () => { doc.font(FONTS_BUNDESSANS_REGULAR).fontSize(10); - addOtherDetailsItinerary( - doc, - compensationStartYPosition, - userData.zusaetzlicheAngaben, - ); + addOtherDetailsItinerary(doc, userData.zusaetzlicheAngaben); - addDistanceInfo(doc, userData, compensationStartYPosition); + addDistanceInfo(doc, userData); addNewPageInCaseMissingVerticalSpace(doc); diff --git a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/addDistanceInfo.ts b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/addDistanceInfo.ts index 194b11673..d1bf36f6c 100644 --- a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/addDistanceInfo.ts +++ b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/addDistanceInfo.ts @@ -5,8 +5,10 @@ import { calculateDistanceBetweenAirportsInKilometers } from "~/domains/fluggast import { getAirportNameByIataCode } from "~/domains/fluggastrechte/services/airports/getAirportNameByIataCode"; import { getCompensationPayment } from "~/domains/fluggastrechte/services/airports/getCompensationPayment"; import { MARGIN_BETWEEN_SECTIONS } from "~/domains/fluggastrechte/services/pdf/configurations"; -import { PDF_MARGIN_HORIZONTAL } from "~/services/pdf/createPdfKitDocument"; -import { getStartYPosition } from "./getStartYPosition"; +import { + PDF_MARGIN_HORIZONTAL, + PDF_WIDTH_SEIZE, +} from "~/services/pdf/createPdfKitDocument"; import { addNewPageInCaseMissingVerticalSpace } from "../../addNewPageInCaseMissingVerticalSpace"; export const ARTICLE_AIR_PASSENGER_REGULATION_TEXT = @@ -40,34 +42,19 @@ const getDistanceText = (userData: FluggastrechtContext): string => { return `${distanceText} pro Person, insgesamt aus eigenem und abgetretenem Recht damit eine Gesamtsumme von ${compensationTotalAmountValue} €.`; }; -const getYPositionDistanceText = ( - doc: typeof PDFDocument, - compensationStartYPosition: number, - zusaetzlicheAngaben?: string, -): number => { - // in case exist the zusaetzlicheAngaben should start to print from the last y position of the document, otherwise from the value compensationStartYPosition - return typeof zusaetzlicheAngaben !== "undefined" && - zusaetzlicheAngaben.length > 0 - ? doc.y - : getStartYPosition(compensationStartYPosition, doc.y); -}; - export const addDistanceInfo = ( doc: typeof PDFDocument, userData: FluggastrechtContext, - compensationStartYPosition: number, ) => { - addNewPageInCaseMissingVerticalSpace(doc); + const distanceText = getDistanceText(userData); + + const distanceTextHeight = doc.heightOfString(distanceText, { + width: PDF_WIDTH_SEIZE, + }); + + addNewPageInCaseMissingVerticalSpace(doc, distanceTextHeight); doc - .text( - getDistanceText(userData), - PDF_MARGIN_HORIZONTAL, - getYPositionDistanceText( - doc, - compensationStartYPosition, - userData.zusaetzlicheAngaben, - ), - ) + .text(distanceText, PDF_MARGIN_HORIZONTAL) .moveDown(MARGIN_BETWEEN_SECTIONS); }; diff --git a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/addOtherDetailsItinerary.ts b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/addOtherDetailsItinerary.ts index 079e8c888..4bda380ed 100644 --- a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/addOtherDetailsItinerary.ts +++ b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/addOtherDetailsItinerary.ts @@ -1,31 +1,39 @@ import type PDFDocument from "pdfkit"; import { MARGIN_BETWEEN_SECTIONS } from "~/domains/fluggastrechte/services/pdf/configurations"; -import { PDF_MARGIN_HORIZONTAL } from "~/services/pdf/createPdfKitDocument"; -import { getStartYPosition } from "./getStartYPosition"; +import { + PDF_MARGIN_HORIZONTAL, + PDF_WIDTH_SEIZE, +} from "~/services/pdf/createPdfKitDocument"; import { addNewPageInCaseMissingVerticalSpace } from "../../addNewPageInCaseMissingVerticalSpace"; export const OTHER_DETAILS_ITINERARY = "Weitere Angaben zum Reiseverlauf:"; export const addOtherDetailsItinerary = ( doc: typeof PDFDocument, - compensationStartYPosition: number, zusaetzlicheAngaben?: string, ) => { if ( typeof zusaetzlicheAngaben !== "undefined" && zusaetzlicheAngaben.length > 0 ) { + const otherDetailsItineraryHeight = doc.heightOfString( + OTHER_DETAILS_ITINERARY, + { + width: PDF_WIDTH_SEIZE, + }, + ); + const zusaetzlicheAngabenHeight = doc.heightOfString(zusaetzlicheAngaben, { - width: doc.widthOfString(zusaetzlicheAngaben), + width: PDF_WIDTH_SEIZE, }); - addNewPageInCaseMissingVerticalSpace(doc, zusaetzlicheAngabenHeight); + + addNewPageInCaseMissingVerticalSpace( + doc, + zusaetzlicheAngabenHeight + otherDetailsItineraryHeight, + ); doc - .text( - OTHER_DETAILS_ITINERARY, - PDF_MARGIN_HORIZONTAL, - getStartYPosition(compensationStartYPosition, doc.y), // start to print this text from this line - ) + .text(OTHER_DETAILS_ITINERARY, PDF_MARGIN_HORIZONTAL) .text(zusaetzlicheAngaben) .moveDown(MARGIN_BETWEEN_SECTIONS); } diff --git a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/getStartYPosition.ts b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/getStartYPosition.ts deleted file mode 100644 index b2658348e..000000000 --- a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/compensationAmount/getStartYPosition.ts +++ /dev/null @@ -1,7 +0,0 @@ -// check if should use the current Y position before to use the compensation start y position -export const getStartYPosition = ( - compensationStartYPosition: number, - currentYPosition: number, -) => { - return currentYPosition < 200 ? currentYPosition : compensationStartYPosition; -}; diff --git a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/createFactsOfCases.ts b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/createFactsOfCases.ts index e4fd71803..8b414992b 100644 --- a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/createFactsOfCases.ts +++ b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/createFactsOfCases.ts @@ -35,19 +35,5 @@ export const createFactsOfCases = ( addNewPageInCaseMissingVerticalSpace(doc, COLUMN_HEIGHT * 4 + MARGIN_BOTTOM); const startTableY = doc.y; addTable(doc, documentStruct, startTableY, userData); - // Set tableEndYPosition based on the existence of `andereErsatzverbindungBeschreibung` - const tableEndYPosition = startTableY + COLUMN_HEIGHT * 4 + MARGIN_BOTTOM; - doc.moveDown(MARGIN_BETWEEN_SECTIONS); - const startCompensationYPosition = - typeof userData.andereErsatzverbindungBeschreibung !== "undefined" && - userData.andereErsatzverbindungBeschreibung.length >= 0 - ? doc.y - : tableEndYPosition; - - addCompensationAmount( - doc, - documentStruct, - userData, - startCompensationYPosition, - ); + addCompensationAmount(doc, documentStruct, userData); }; diff --git a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/table/__test__/addTableInfo.test.ts b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/table/__test__/addTableInfo.test.ts index 17a828e40..fa472c6c9 100644 --- a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/table/__test__/addTableInfo.test.ts +++ b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/table/__test__/addTableInfo.test.ts @@ -29,14 +29,8 @@ describe("addTableInfo", () => { const mockDoc = mockPdfKitDocument(mockStruct); const andereErsatzverbindungBeschreibung = "Sample description"; - const tableEndYPosition = 100; - addTableInfo( - mockDoc, - mockStruct, - andereErsatzverbindungBeschreibung, - tableEndYPosition, - ); + addTableInfo(mockDoc, mockStruct, andereErsatzverbindungBeschreibung); expect(mockDoc.struct).toHaveBeenCalledWith("Sect"); @@ -47,7 +41,6 @@ describe("addTableInfo", () => { expect(mockDoc.text).toHaveBeenCalledWith( andereErsatzverbindungBeschreibung, PDF_MARGIN_HORIZONTAL, - 100, ); }); @@ -56,14 +49,8 @@ describe("addTableInfo", () => { const mockDoc = mockPdfKitDocument(mockStruct); const andereErsatzverbindungBeschreibung = "Sample description"; - const tableEndYPosition = 100; - addTableInfo( - mockDoc, - mockStruct, - andereErsatzverbindungBeschreibung, - tableEndYPosition, - ); + addTableInfo(mockDoc, mockStruct, andereErsatzverbindungBeschreibung); expect(addNewPageInCaseMissingVerticalSpace).toBeCalledTimes(1); }); diff --git a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/table/addTable.ts b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/table/addTable.ts index 1a672cf93..f643e3a60 100644 --- a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/table/addTable.ts +++ b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/table/addTable.ts @@ -21,13 +21,13 @@ export function addTable( tableSect.add(table); // Add the table to the section documentStruct.add(tableSect); // Add the section to the parent structure doc.fill("black"); // Fill black due next pages of the table - - // Set tableEndYPosition based on the existence of `andereErsatzverbindungBeschreibung` + // Get end position of the table generated const tableEndYPosition = startTableY + COLUMN_HEIGHT * 4 + MARGIN_BOTTOM; + // reset the position of the table + doc.y = tableEndYPosition; addTableInfo( doc, documentStruct, userData.andereErsatzverbindungBeschreibung ?? "", - tableEndYPosition, ); } diff --git a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/table/addTableInfo.ts b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/table/addTableInfo.ts index d938e6709..8a958bc19 100644 --- a/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/table/addTableInfo.ts +++ b/app/domains/fluggastrechte/services/pdf/sections/reason/factsOfCases/table/addTableInfo.ts @@ -1,25 +1,28 @@ +import { MARGIN_BETWEEN_SECTIONS } from "~/domains/fluggastrechte/services/pdf/configurations"; import { FONTS_BUNDESSANS_REGULAR, PDF_MARGIN_HORIZONTAL, - PDF_MARGIN_VERTICAL, + PDF_WIDTH_SEIZE, } from "~/services/pdf/createPdfKitDocument"; -import { COLUMN_HEIGHT } from "./tableConfigurations"; import { addNewPageInCaseMissingVerticalSpace } from "../../addNewPageInCaseMissingVerticalSpace"; export function addTableInfo( doc: PDFKit.PDFDocument, documentStruct: PDFKit.PDFStructureElement, andereErsatzverbindungBeschreibung: string, - tableEndYPosition: number, ) { + if (andereErsatzverbindungBeschreibung.length === 0) { + return; + } + const tableInfoHeight = doc.heightOfString( - andereErsatzverbindungBeschreibung ?? "", + andereErsatzverbindungBeschreibung, { - width: doc.widthOfString(andereErsatzverbindungBeschreibung ?? ""), + width: PDF_WIDTH_SEIZE, }, ); - addNewPageInCaseMissingVerticalSpace(doc, tableInfoHeight + COLUMN_HEIGHT); + addNewPageInCaseMissingVerticalSpace(doc, tableInfoHeight); const reasonSect = doc.struct("Sect"); reasonSect.add( @@ -27,13 +30,10 @@ export function addTableInfo( doc .fontSize(10) .font(FONTS_BUNDESSANS_REGULAR) - .text( - andereErsatzverbindungBeschreibung ?? "", - PDF_MARGIN_HORIZONTAL, - // in case the current doc.y position is same the vertical margin, the document jump to a new page, so it should start the current doc.y position - doc.y === PDF_MARGIN_VERTICAL ? doc.y : tableEndYPosition, - ); + .text(andereErsatzverbindungBeschreibung, PDF_MARGIN_HORIZONTAL) + .moveDown(MARGIN_BETWEEN_SECTIONS); }), ); + documentStruct.add(reasonSect); } diff --git a/app/services/pdf/createPdfKitDocument.ts b/app/services/pdf/createPdfKitDocument.ts index 8e84c01c0..a943a0b3c 100644 --- a/app/services/pdf/createPdfKitDocument.ts +++ b/app/services/pdf/createPdfKitDocument.ts @@ -9,6 +9,7 @@ export const FONTS_BUNDESSANS_BOLD = "BundesSansWebBold"; export const PDF_MARGIN_VERTICAL = 50; export const PDF_MARGIN_HORIZONTAL = 70; export const PDF_HEIGHT_SEIZE = 780; +export const PDF_WIDTH_SEIZE = 460; export const LINE_GAP_GLOBAL = 2; const bundesSansWebRegular = await readRelativeFileToBuffer(