Some TextBoxFields settings not applied


The SpellCheck, BorderStyle, BorderColor, ForeColor, BackColor  properties have no effect on PdfTextBoxField, only Font property works in 18.1.46: 

   var label = "First Name";
   var font = new PdfStandardFont(PdfFontFamily.Helvetica, 20);
   page.Graphics.DrawString(label, font, PdfBrushes.Black, new PointF(0, 4 / 2));
   var lbs = font.MeasureString(label);
   var tb = new PdfTextBoxField(page, "FirstName")
   {
    Font = font,
    SpellCheck = false,
    BorderStyle = PdfBorderStyle.Beveled,
    BorderColor = new PdfColor(Color.Gray),
    ForeColor = new PdfColor(Color.Green),
    BackColor = new PdfColor(Color.Blue)
   };
   var tbs = tb.Font.MeasureString(new string('C', 10));
   tb.Bounds = new RectangleF(lbs.Width + 6, 0, tbs.Width + 6, tbs.Height + 4);
   tb.ToolTip = label;
   doc.Form.Fields.Add(tb);



17 Replies

GK Gowthamraj Kumar Syncfusion Team May 4, 2020 11:21 AM UTC

Hi Andrey, 
 
Thank you for using Syncfusion products.    

We have tried to reproduce the reported issue, but it is working properly. We have created a sample with a provided code snippet, it is generating the PDF document properly. The reported issue is not reproduced in our end. We have attached the sample for your reference. Kindly try the below sample in your end and let us know the result.    
  
Please find the sample in the below link:  
  
If still, you are facing the same issue, kindly please provide the sample to reproduce the issue in our end. So, that it will be helpful for us to analyze and assist you further on this.   

Regards, 
Gowthamraj K 



MA Mr Andrey Voronov May 4, 2020 01:01 PM UTC

Your sample is built on WinForms, but I am using Syncfusion.Pdf.Net.Core library.


GK Gowthamraj Kumar Syncfusion Team May 5, 2020 11:34 AM UTC

  
Hi Andrey,  
Thank you for your update. 
We have tried to reproduce the reported issue in Net core, but it is working properly. We have created a core sample with a provided code snippet, it is generating the PDF document properly. The reported issue is not reproduced in our end. We have attached the sample and output document for your reference. Kindly try the below sample in your end and let us know the result.     
Please find the sample and output document in the below link:   
If still, you are facing the same issue, kindly please provide the output document and sample to reproduce the issue in our end. So, that it will be helpful for us to analyze and assist you further on this.    

Regards,  
Gowthamraj K 



MA Mr Andrey Voronov May 6, 2020 12:43 PM UTC

Syncfusion library generates pdf correctly, its Chrome that caused some confusion.

I added second field and found out that Google Chrome highlights focused field by changing its foreground and background colours:

Is it somehow possible not to change focused fields appearance ?



  private static void CreateTestPdfForm(PdfDocument doc, PdfPage page)
  {
   float x = 0f;
   float y = 0f;
   y += CreateTextBox(doc, page, "FirstName", "First Name", x, y);
   y += 6f;
   y += CreateTextBox(doc, page, "LastName", "Last Name", x, y);
  }
  private static float CreateTextBox(PdfDocument doc, PdfPage page, string name, string label, float x, float y)
  {
   var font = new PdfStandardFont(PdfFontFamily.Helvetica, 20);
   page.Graphics.DrawString(label, font, PdfBrushes.Black, new PointF(x, y + 4 / 2));
   var lbs = font.MeasureString(label);
   var tb = new PdfTextBoxField(page, name)
   {
    Font = font,
    SpellCheck = false,
    BorderStyle = PdfBorderStyle.Dashed,
    BorderColor = new PdfColor(Color.Green),
    ForeColor = new PdfColor(Color.Red),
    BackColor = new PdfColor(Color.Yellow)
   };
   var tbs = tb.Font.MeasureString(new string('C', 10));
   tb.Bounds = new RectangleF(lbs.Width + 6, y, tbs.Width + 6, tbs.Height + 4);
   tb.ToolTip = label;
   doc.Form.Fields.Add(tb);
   return tb.Bounds.Height;
  }


MA Mr Andrey Voronov May 6, 2020 02:14 PM UTC


That's how the same two text boxes pdf document looks like when rendered in Blazor (textbox dashed border style and red foreground color not applied): 

Apparently this is bug in SfPdfViewerServer component. This topic should be moved back to blazor forums.





SL Sowmiya Loganathan Syncfusion Team May 7, 2020 01:57 PM UTC

Hi Andrey,    
   
Syncfusion library generates pdf correctly, its Chrome that caused some confusion.   
   
I added the second field and found out that Google Chrome highlights focused field by changing its foreground and background colors:   
   
Is it somehow possible not to change focused field appearance?   
    
We have analyzed the reported issue “focused form field color changed in Google Chrome” and this is the behavior of the Chrome browser. We also ensured the same in creating the form fields in PDF document (with the background color) using Adobe Acrobat.    
That's how the same two text boxes pdf document looks like when rendered in Blazor (textbox dashed border style and red foreground color not applied):    
   
Apparently, this is a bug in SfPdfViewerServer component. This topic should be moved back to blazor forums   
    
We were able to reproduce the reported behavior with the provided details in our PDF Viewer. We will analyze further on it and update you with more details on 11th  May 2020.   
   
  
Regards, 
Sowmiya Loganathan 



AA Akshaya Arivoli Syncfusion Team May 12, 2020 12:00 AM UTC

Hi Andrey, 

We have confirmed that the reported issue is a defect and logged the defect report for the same. The fix for the issue will be included in our weekly Nuget release on 27th May 2020. You can track the status using the below link,  


Regards, 
Akshaya 




NC NKOUAMBIA CHIMENE May 21, 2020 04:32 PM UTC

Hello Team!

//Opens an existing document from stream 
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(ms);
//Load the existing PDF form.
PdfLoadedFormFieldCollection fields = loadedDocument.Form.Fields;
//How to get all the formFields name as a list of string?
list FormFieldsNameList = ???

Thanks,
Chimène NK.


AA Akshaya Arivoli Syncfusion Team May 22, 2020 10:51 AM UTC

Hi Chimène, 
 
//Opens an existing document from stream   
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(ms);  
//Load the existing PDF form.  
PdfLoadedFormFieldCollection fields = loadedDocument.Form.Fields;  
//How to get all the formFields name as a list of string?  
list FormFieldsNameList = ???  
  
We do not have a direct property to get the form fields name. However, as a workaround we can get it and please refer the below code snippet for more details,   
  
//Load PDF document   
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(ms);  
  
//Get form fields collection   
PdfLoadedForm loadedForm = loadedDocument.Form;  
PdfLoadedFormFieldCollection fields = loadedForm.Fields;  
  
List<string> FormFieldsNameList = new List<string>();  
  
string name = String.Empty;  
  
foreach (var field in fields)  
{  
    //load fild as PdfLoadedField   
    PdfLoadedField loadedField = field as PdfLoadedField;  
    name = loadedField.Name;  
  
    //Add the name to form fields name list   
    FormFieldsNameList.Add(name);  
}  
  
  
 
Please revert us with more details if you need any further assistance. 
 
Regards, 
Akshaya  



MA Mr Andrey Voronov May 26, 2020 01:27 PM UTC

ImportFormFields does not work as expected.

Here is a valid json:

{
  "FirstName": "'",
  "LastName": "\""
}

Single quote displayed correctly, but \ displayed instead of double quote




AA Akshaya Arivoli Syncfusion Team May 27, 2020 12:21 PM UTC

Hi Andrey , 
 
Thank you for contacting Syncfusion support. 
 
Can you please provide more details about your issue, use case scenario, simple sample, PDF document and confirm us whether you want to display the doubt quotes (“) in the imported form field value. These details will be helpful for us to investigate further and provide you more details. 
 
Note: We have tried with the provided JSON data and we are getting the same result as you shown in the screenshot. 
  
 
Regards, 
Akshaya 



MA Mr Andrey Voronov May 27, 2020 12:33 PM UTC

I am displaying a double quote " in PDF textbox form field by passing the following json to ImportFormFields:

{
  "LastName": "\""
}

Double quote " must be escaped in order for JSON to be valid  : " -> \"

But PDF text box displays \ instead of "
 


AA Akshaya Arivoli Syncfusion Team May 29, 2020 06:41 AM UTC

Hi Andrey, 

Thank you for your update. 

We can reproduce the reported behavior with the provided JSON data. We will analyze further on it and update you with more details on June 2 ,2020 

Regards, 
Akshaya  




AA Akshaya Arivoli Syncfusion Team June 2, 2020 03:10 PM UTC

Hi Andrey, 

Sorry for the inconvenience caused. 

We are still validating the reported issue with high priority and we will update you with more details on June 4,2020  

Regards, 
Akshaya 



AA Akshaya Arivoli Syncfusion Team June 5, 2020 03:55 AM UTC

Hi Andrey, 
 
Thank you for your patience. 
 
As per our behaviour, we encode the field key and value while exporting and decode the field key and values while importing the Form Fields for handling the JSON Delimiters (()<>[]{}/%,\":). Please find the below  json value to import the  value 
 
{ 
  "FirstName": " _x0027_", 
  "LastName": " _x0022_" 
} 
 
 
Regards, 
Akshaya 



MA Mr Andrey Voronov June 5, 2020 12:25 PM UTC

Do you expect users will be converting a valid JSON to _x_  JSON themselves ?

At least can you provide code how to convert C# string to _x_ string ?


SM Selvakumar Murugan Syncfusion Team June 8, 2020 12:33 PM UTC

Hi  Andrey,

Please find the below  code snippet to achieve your requirement.

Code Snippet: 
using System.Xml; 
string text = XmlConvert.EncodeName(Convert.ToString("\")); 

Regards,
Selvakumar 


Loader.
Up arrow icon