Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Jul 27, 2021 5:26 am

Hey,

When I programmatically modify the pdf textbox field values, some characters don't show.
But when I clicked on that textbox, its shows all of the character.
I need to get those characters without clicking on textbox. Any help?

I'm using the latest spire pdf - v7.7.10 | .Net Framework | C# in my project.

Here I attached pdf input & output files.
Two images of output files: 1) Before click on text field. 2) After click on text field
before-click.PNG

after -click.PNG


code sample:
static void Main(string[] args)
{
var inputlocation = @"C:\Code\ZTestApp\ConsoleApp\spire\input.pdf";
var outputlocation = @"C:\Code\ZTestApp\ConsoleApp\spire\output.pdf";
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(inputlocation);

PdfFormWidget formWidget = doc.Form as PdfFormWidget;

if (formWidget != null)
{
for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++)
{
PdfField field = formWidget.FieldsWidget.List[i] as PdfField;
if (field is PdfTextBoxFieldWidget)
{
PdfTextBoxFieldWidget textBoxField = field as PdfTextBoxFieldWidget;
textBoxField.Text = textBoxField.Text;
}
}
}
doc.SaveToFile(outputlocation);
}

lahmed1982
 
Posts: 1
Joined: Tue Jul 27, 2021 5:02 am

Tue Jul 27, 2021 8:40 am

Hello,

Thank you for your inquiry.
I did not find your PDF input & output files in this post, hence I simulated a PDF file and tested it with the code you provided, but did not reproduce your problem. Please provide your PDF files again for our investigation. You could attach them here or send to us via email (support@e-iceblue.com). Thanks in advance.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Wed Jul 28, 2021 10:03 am

Hello,

Thank you for sharing file via email.
I tested your case, and indeed found that some characters were not displayed. After investigation, I found that this behavior is caused by the font (EuclidCircularA-Regular) embedding failure. I have posted this issue to our development team for investigation. Once it is resolved, I will inform you immediately. Sorry for the inconvenience caused.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Tue Jul 19, 2022 12:02 pm

I am also facing the same issue like Japanese and Thai language text are not showing properly in the form field textbox widget its show like special character in the form field text box, Kindly check it and give the proper solution for that issue.

EswariBaskaran
 
Posts: 3
Joined: Tue Jul 19, 2022 11:29 am

Wed Jul 20, 2022 10:25 am

Hello Eswari B,

Thanks for your message.
Please use our latest Spire.PDF Pack(Hot Fix) Version:8.7.2 and refer to the following code to fill Japanese and Thai language text in text box form field. If there is still any issue, to help us look into it accurately, please provide us with your testing code as well as your input file(if any). Thanks in advance.
Code: Select all
 PdfDocument doc = new PdfDocument();
 doc.LoadFromFile(@"input.pdf");
 PdfFormWidget formWidget = doc.Form as PdfFormWidget;
 if (formWidget != null)
 {
     for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++)
     {
         PdfField field = formWidget.FieldsWidget.List[i] as PdfField;
         if (field is PdfTextBoxFieldWidget)
         {
             PdfTextBoxFieldWidget textBoxField = field as PdfTextBoxFieldWidget;
             PdfTrueTypeFont font = new Spire.Pdf.Graphics.PdfTrueTypeFont(new System.Drawing.Font("Arial", 8, FontStyle.Regular), true);
             textBoxField.Font = font;
             //add  Japanese language text("こんにちは") or Thai language text("สวัสดี")
             textBoxField.Text = "สวัสดี";
         }
     }
 }
 doc.Form.NeedAppearances = true;
 doc.SaveToFile(@"textFillout2.pdf", Spire.Pdf.FileFormat.PDF);

Sincerely,
Simple
E-iceblue support team
User avatar

Simple.Li
 
Posts: 248
Joined: Fri Jul 01, 2022 2:33 am

Mon Jul 25, 2022 11:26 am

Hi Team,

Thai language text are showing properly but Still we are not able to get Japanese text its doesn't return any text its show like blank text, kindly review my below code and share your thoughts.

string txtfieldVal = formFieldMap[Field.Name] ?? "";
PdfTextBoxFieldWidget textBoxField = Field as PdfTextBoxFieldWidget;
if (txtfieldVal == "✔" || txtfieldVal == "✓")
txtfieldVal = ((char)0x221A).ToString();
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Alef-Regular.ttf", 8f, FontStyle.Bold), true);
textBoxField.Font = font;
textBoxField.Text = txtfieldVal;

Thanks and Regards,
Eswari B

EswariBaskaran
 
Posts: 3
Joined: Tue Jul 19, 2022 11:29 am

Tue Jul 26, 2022 5:54 am

Hello Eswari B,

Thanks for your reply.
Since your code snippet only filled the ((char)0x221A).ToString(), I simulated a PDF file and tested your case to fill the ((char)0x221A).ToString() and Japanese text, and then to get the filled text. But I didn't reproduce the problem you mentioned. Here I uploaded my test project, you can download and run it directly. If only your testing PDF file has the issue, to help us further investigate, please share your file with us for reference. You can attach it here or send it to us via email(support@e-iceblue.com).

Sincerely,
Simple
E-iceblue support team
User avatar

Simple.Li
 
Posts: 248
Joined: Fri Jul 01, 2022 2:33 am

Tue Jul 26, 2022 2:24 pm

Hi Team,

I have attached the Input form PDF to support@e-iceblue.com, Kindly check it and give the feedback

Thanks and Regards,
Eswari B

EswariBaskaran
 
Posts: 3
Joined: Tue Jul 19, 2022 11:29 am

Wed Jul 27, 2022 2:28 am

Hello Eswari B,

Thanks for your sharing.
I have tested the PDF you provided and found that the resulting document can correctly display ((char)0x221A).tostring () and Japanese text, as shown in attached screenshot (sample.png). To help further investigate your project issue, could you help to share your whole runnable project as well as your filled PDF file for reference? Thanks in advance.

Sincerely,
Simple
E-iceblue support team
User avatar

Simple.Li
 
Posts: 248
Joined: Fri Jul 01, 2022 2:33 am

Wed Aug 03, 2022 9:00 am

Hello Eswari B,

Could you please let us know how is your issue going? Thanks in advance for your feedback and time.

Sincerely,
Simple
E-iceblue support team
User avatar

Simple.Li
 
Posts: 248
Joined: Fri Jul 01, 2022 2:33 am

Thu Aug 04, 2022 7:36 am

Hi Team,
If i use field.Flatten=true; , then Japanese text is not showing in Textbox, if i remove field.Flatten=true , then thai text is not showing. Please check and suggest me a solution for both working

PdfDocument doc = new PdfDocument();
doc.LoadFromFile(@"input.pdf");
[quote][/quote] PdfFormWidget formWidget = doc.Form as PdfFormWidget;
if (formWidget != null)
{
for (int i = 0; i < formWidget.FieldsWidget.List.Count; i++)
{
PdfField field = formWidget.FieldsWidget.List[i] as PdfField;
if (field is PdfTextBoxFieldWidget)
{
PdfTextBoxFieldWidget textBoxField = field as PdfTextBoxFieldWidget;
String txtfieldVal = ((char)0x221A).ToString() + "こんにちは TEST สวัสดี";
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Alef-Regular.ttf", 8f, FontStyle.Bold), true);
textBoxField.Font = font;
textBoxField.Text = txtfieldVal;
String filledText = textBoxField.Text;
}
field.Flatten=true;
//field.ReadOnly = true;
}
}
doc.Form.NeedAppearances = true;
doc.SaveToFile(@"textFillout.pdf", Spire.Pdf.FileFormat.PDF);
System.Diagnostics.Process.Start(@"textFillout.pdf");

satheeshkumark
 
Posts: 1
Joined: Thu Aug 04, 2022 7:31 am

Thu Aug 04, 2022 9:51 am

Hi,

Thank you for your inquiry.
I simulated a PDF document and did an initial test using our latest version(Spire.PDF Pack(Hot Fix) Version:8.7.9), but did not reproduce your problem. If you are not using the latest version, I suggest you give it a try. If the problem still exists, please provide information for further investigation. You can attach your document here or send it to us via email (support@e-iceblue.com). Thank you in advance.
1) Your PDF document.
2) Test environment, such as Win10, 64bit
3) Application type, such as Console App, .NET Framework 4.8

Sincerely,
Kylie
E-iceblue support team
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Wed Oct 19, 2022 3:55 am

Hi,

Hope you doing well.
How is the issue you posted on our forum now? If it still exists, could you please provide the information that mentioned in my forum reply to us for further investigation?

Sincerely,
Kylie
E-iceblue support team
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Return to Spire.PDF

cron