1
0
forked from Yara724/api

PDF generation

This commit is contained in:
SepehrYahyaee
2026-06-23 15:56:19 +03:30
parent cca3ed01a4
commit 2fc6015213
13 changed files with 1287 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
/** Strip invisible bidi / ZWNJ chars that render as tofu in embedded Arabic fonts. */
export function normalizePersianPdfText(text: string): string {
return text
.replace(/\u200c/g, " ")
.replace(/[\u200e\u200f\u202a-\u202e\u2066-\u2069\ufeff]/g, "")
.replace(/\u2014/g, "-")
.replace(/\s+/g, " ")
.trim();
}
export function pdfKitRtlKeyValue(
label: string,
value: string,
): { label: string; value: string } {
return {
label: normalizePersianPdfText(label),
value: normalizePersianPdfText(value),
};
}
export function pdfKitRtlParagraph(text: string): string {
return normalizePersianPdfText(text);
}
export function isMostlyAscii(text: string): boolean {
return text.length > 0 && !/[\u0600-\u06FF]/.test(text);
}