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.

Mon Apr 01, 2019 2:59 pm

The attached file is generated in Windows with embedded Calibri but when it's filled using the Spire, the filled fields font render incorrectly/weird in Macintosh/iOS. It shows up better in Chrome because chrome has it's own alternative font to calibri. Is there an alternative to this other than using a different font?

everettmccoy
 
Posts: 4
Joined: Mon May 07, 2018 5:10 pm

Tue Apr 02, 2019 11:25 am

Hello,

Thanks for your inquiry.
I opened your PDF file in MAC, and found that some text indeed displayed incorrectly such as "Test Reason1...". They were the field values you filled, right? Actually, after checking with the Foxit PDF Editor, I found that their font is non-embedded Calibri, if you didn't install the font (Calibri) in your MAC. The non-embedded font can't find the corresponding font to display the text. Thus, the texts rendered incorrectly. I suggest you try to embed the font when filling fields like the following code snippet. If there is still any question or any misunderstanding, to help us further investigate it, please share us with your original PDF file (didn't fill), your testing code as well as some screenshots of showing your errors in the MAC. You could send them to us via email ([email protected]).
Code: Select all
PdfTextBoxFieldWidget textBoxField = field as PdfTextBoxFieldWidget;
textBoxField.Font = new PdfTrueTypeFont("C:\\Calibri.ttf", 12.0f);
textBoxField.Text = "Test Reason1";

Sincerely,
Lisa,
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1536
Joined: Wed Apr 25, 2018 3:20 am

Tue Apr 02, 2019 4:40 pm

Hi Lisa,

Thank you for your response. The list and the fields are all generated in spire. I was able to change set the font but it's showing as NOT embedded. Is this a limitation of a Free version or do I need to set it somewhere?

everettmccoy
 
Posts: 4
Joined: Mon May 07, 2018 5:10 pm

Wed Apr 03, 2019 3:39 am

Hello,

This isn't a limitation of a Free version. I simulated a PDF and filled the textBoxField and listBoxField. The font (Calibri) can be embedded successfully when filling fields. Below is my testing code. To help us further look into your issue, please provide your original PDF file (didn't fill the fields) as well as your testing code (If your code is different from mine). You could send them to email ([email protected]). Thanks in advance.
Code: Select all
 PdfDocument doc = new PdfDocument();
 //a PDF with textBoxField and listBoxField
 doc.LoadFromFile(@"test.pdf");
 PdfFormWidget formWidget = doc.Form as PdfFormWidget;
 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;
         switch (textBoxField.Name)
         {
             case "Text1":
                 textBoxField.Font = new PdfTrueTypeFont(@"C:\\Calibri.ttf", 12.0f);
                 textBoxField.Text = "support";
                 break;
         }
     }
     if (field is PdfListBoxWidgetFieldWidget)
     {
         PdfListBoxWidgetFieldWidget listBoxField = field as PdfListBoxWidgetFieldWidget;
         switch (listBoxField.Name)
         {
             case "ListBox1":
                 int[] index = { 2 };
                 listBoxField.Font = new PdfTrueTypeFont(@"C:\\Calibri.ttf", 12.0f);
                 listBoxField.SelectedIndex = index;
                 break;
         }
     }
 }
 doc.SaveToFile(@"filled.pdf",Spire.Pdf.FileFormat.PDF);

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1536
Joined: Wed Apr 25, 2018 3:20 am

Wed Apr 03, 2019 6:50 pm

Hi,

I followed your instruction and it seems to work with font file being supplied. However, I'm having issues with the font size of the field being set differently than when I iterate through them.

See my code

Code: Select all
 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;
                    if (parmdata[textBoxField.Name] != null)
                    {
                        textBoxField.Text = parmdata[textBoxField.Name].ToString();
                        textBoxField.Font = !string.IsNullOrEmpty(sFont) ? new PdfTrueTypeFont(sFont, textBoxField.Font.Size) : textBoxField.Font;
                    }

                }

               
                field.Flatten = true;
                field.ReadOnly = true;

            }


So if you look at the attachment for form not filled, the fields have varying sizes but you'll see after the it's filled. It's set to 9. I step thru the code and It didn't set the sizes differently than the original. I suspect that it's set the size from whatever the size the last field's size is.

everettmccoy
 
Posts: 4
Joined: Mon May 07, 2018 5:10 pm

Thu Apr 04, 2019 9:44 am

Hello,

After testing with the latest version Spire.PDF Pack(Hot Fix) Version:5.4.1, I didn't reproduce the font size issue. Here is my testing application. Please check and run it on your side. Look forward to your testing result.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1536
Joined: Wed Apr 25, 2018 3:20 am

Tue Apr 09, 2019 8:45 am

Hello,

Greetings from E-iceblue.
Could you please let us know your testing result? Thanks in advance for your feedback and time.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1536
Joined: Wed Apr 25, 2018 3:20 am

Tue Apr 09, 2019 2:32 pm

Hi,

after I downloaded the hotfix pack, the evaluation warning is now visible. Is there a hotfix of the free version?

everettmccoy
 
Posts: 4
Joined: Mon May 07, 2018 5:10 pm

Wed Apr 10, 2019 2:20 am

Hello,

Thanks for your feedback.
Sorry there is no hotfix of free version, we only update the free version irregularly. Do you mean that your issue just exists in Free Spire.PDF Version:5.1? I tested your case with both Free Spire.PDF Version:5.1 and Spire.PDF Pack(Hot Fix) Version:5.4.1, both of them work well and didn't reproduce the font size issue. Could you please let us know your testing result about running my previous testing application?
Besides, without applying a valid license, the commercial version will generate the evaluation warning. But we are willing to provide a temporary license (one month free) to help you remove the warning warning and evaluate our commercial version better. If interested, please contact our sales them ([email protected]) to get it.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1536
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.PDF

cron