Skip to content

Commit

Permalink
refactor(pdf-service): remove font size changes in pdf form (#1554)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbrtrfl authored Dec 16, 2024
1 parent 9579df3 commit d64a9ec
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { maritalDescriptionMapping } from "~/domains/shared/services/pdf/marital
import {
type AttachmentEntries,
SEE_IN_ATTACHMENT_DESCRIPTION,
SEE_IN_ATTACHMENT_DESCRIPTION_SHORT,
} from "~/services/pdf/attachment";
import type { PkhPdfFillFunction } from "..";

Expand Down Expand Up @@ -73,7 +74,7 @@ export const fillPerson: PkhPdfFillFunction = ({ userData, pdfValues }) => {
title: "Familienstand",
text: maritalDescription,
});
pdfValues.text3.value = "s.A.";
pdfValues.text3.value = SEE_IN_ATTACHMENT_DESCRIPTION_SHORT;
} else {
pdfValues.text3.value = maritalDescription;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import {
} from "data/pdf/prozesskostenhilfe/prozesskostenhilfe.generated";
import type { ProzesskostenhilfeFormularContext } from "~/domains/prozesskostenhilfe/formular";
import { maritalDescriptionMapping } from "~/domains/shared/services/pdf/maritalDescriptionMapping";
import { SEE_IN_ATTACHMENT_DESCRIPTION } from "~/services/pdf/attachment";
import {
SEE_IN_ATTACHMENT_DESCRIPTION,
SEE_IN_ATTACHMENT_DESCRIPTION_SHORT,
} from "~/services/pdf/attachment";
import {
ANSCHRIFT_FIELD_MAX_CHARS,
BERUF_FIELD_MAX_CHARS,
Expand Down Expand Up @@ -138,7 +141,7 @@ describe("A_person", () => {
pdfValues: pdfParams,
});

expect(pdfValues.text3.value).toBe("s.A.");
expect(pdfValues.text3.value).toBe(SEE_IN_ATTACHMENT_DESCRIPTION_SHORT);
expect(attachment?.at(1)?.title).toBe("Familienstand");
expect(attachment?.at(1)?.text).toBe(maritalDescriptionMapping.yes);
});
Expand Down
24 changes: 0 additions & 24 deletions app/services/pdf/__test__/getFontSizeFieldValue.test.ts

This file was deleted.

1 change: 1 addition & 0 deletions app/services/pdf/attachment/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export type AttachmentEntries = {
}[];

export const SEE_IN_ATTACHMENT_DESCRIPTION = "Siehe Anhang";
export const SEE_IN_ATTACHMENT_DESCRIPTION_SHORT = "s.A.";
34 changes: 0 additions & 34 deletions app/services/pdf/getFontSizeFieldValue.ts

This file was deleted.

10 changes: 5 additions & 5 deletions app/services/pdf/pdf.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { PDFForm } from "pdf-lib";
import type { BooleanField, StringField } from "./fileTypes";
import { getFontSizeFieldValue } from "./getFontSizeFieldValue";

const FONT_SIZE_DEFAULT = 10;

export function changeBooleanField(booleanField: BooleanField, form: PDFForm) {
if (!booleanField.value) return;
Expand All @@ -10,10 +11,9 @@ export function changeBooleanField(booleanField: BooleanField, form: PDFForm) {
export function changeStringField(stringField: StringField, form: PDFForm) {
if (!stringField.value) return;
const formField = form.getTextField(stringField.name);
// We override the restriction of a field where it is set to have max length of 2.
// This is because it impacts letter spacing e.g. in the fourth column of "G_ausgaben".
// maxLength property is overridden, because some fields have a max length of 2 even though the field width is greater
formField.setMaxLength();
formField.setText(stringField.value);
const fontSize = getFontSizeFieldValue(stringField.name);
formField.setFontSize(fontSize);
// fontSize property is set to a default, because some fields have 0 for auto scale which is bad UX/UI
formField.setFontSize(FONT_SIZE_DEFAULT);
}

0 comments on commit d64a9ec

Please sign in to comment.