ststeiger / PdfSharpCore

Port of the PdfSharp library to .NET Core - largely removed GDI+ (only missing GetFontData - which can be replaced with freetype2)
Other
1.06k stars 235 forks source link

Unicode problem when filling forms #331

Open hheexx opened 1 year ago

hheexx commented 1 year ago

Hi, I am trying to use PdfSharpCore for very basic task of filling forms. Unfortunately I have Unicode problem.

using PdfDocument document = PdfReader.Open(@"C:\Users\user\Downloads\cxPdfTest.pdf");
PdfTextField f = (PdfTextField)document.AcroForm.Fields["txtName"];
f.Text = "Lorem Ipsumović";
document.Save(@"C:\Users\user\Downloads\cxPdfOut.pdf");

image

Any hints?

hheexx commented 1 year ago

Ok, I fixed it like this.

f.Value = new PdfString("Lorem Ipsumović", PdfStringEncoding.Unicode);

Text property should probably be changed to Unicode, it's 2023.