[feat:] language property with iText
This commit is contained in:
@@ -589,6 +589,7 @@ namespace PLG_Exam
|
|||||||
|
|
||||||
|
|
||||||
document.Save(filePath);
|
document.Save(filePath);
|
||||||
|
SetPdfLanguage(filePath);
|
||||||
await MessageBox.Show(this, "PDF erfolgreich gespeichert!", "Erfolg", MessageBoxButton.Ok);
|
await MessageBox.Show(this, "PDF erfolgreich gespeichert!", "Erfolg", MessageBoxButton.Ok);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -690,9 +691,22 @@ namespace PLG_Exam
|
|||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetPdfLanguage(string filePath, string language = "de-DE")
|
||||||
|
{
|
||||||
|
var pdfDocument = new PdfDocument(new PdfReader(filePath), new PdfWriter(filePath + "_temp"));
|
||||||
|
|
||||||
|
// Setze die Sprache im Root-Tag
|
||||||
|
pdfDocument.GetCatalog().SetLang(new iText.Kernel.Pdf.PdfString(language));
|
||||||
|
pdfDocument.Close();
|
||||||
|
|
||||||
|
// Ersetze das Original mit der aktualisierten Datei
|
||||||
|
File.Delete(filePath);
|
||||||
|
File.Move(filePath + "_temp", filePath);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user