Click here to Skip to main content
15,867,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to add Cyrillic text into pdf field, but I failed. I found solutions on google but that doesn't work in my case.
using (FileStream outFile = new FileStream("result.pdf", FileMode.Create))
{
    PdfReader pdfReader = new PdfReader("zapisnik-fillable.pdf");
    PdfStamper pdfStamper = new PdfStamper(pdfReader, outFile);
    AcroFields fields = pdfStamper.AcroFields;

    fields.SetField("team_a_name", "mzt");
    pdfStamper.FormFlattening = true;

    pdfStamper.Close();
    pdfReader.Close();
}

Now I want to setField from mzt into МЗТ, I tried it with creating a paragraph with Cyrillic font, but got an error, because SetField() second argument is string not IText item.team_a_name is field in my pdf document. When I write a Cyrillic using Adobe Acrobat everything is okay, but using ITextSharp getting empty line.

What I have tried:

I have answers from Stackoverflow but they add new Paragraph, in this case I just want to add a string into existing field (fields.SetField("fieldname","value");
Posted
v2
Comments
What is the error?
Filip Gorgievski 26-Oct-22 15:14pm    
I get empty field

1 solution

Have a look at this - https://stackoverflow.com/questions/10329863/display-unicode-characters-in-converting-html-to-pdf[^].

Basically it is to make sure you handle the Unicodes properly while converting to PDF.
 
Share this answer
 
Comments
Filip Gorgievski 26-Oct-22 15:16pm    
Yes, I read this reference link, but I didn't find anything helpful in it. Can you show me an example with my code, what should look like?
Filip Gorgievski 26-Oct-22 16:05pm    
Also I don't need to parse it from html to pdf, I just want to edit value of the field!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900