Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Field property- Font Size/Alignment arent preserve
  FAQ FAQ  Forum Search   Register Register  Login Login

Field property- Font Size/Alignment arent preserve

 Post Reply Post Reply
Author
Message Reverse Sort Order
fletchsod View Drop Down
Beginner
Beginner


Joined: 11 Sep 20
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote fletchsod Quote  Post ReplyReply Direct Link To This Post Topic: Field property- Font Size/Alignment arent preserve
    Posted: 16 Sep 20 at 7:43PM
Why does font size & alignment in fields get altered from original (AcroForm fields)?  There's nothing in the code that modify the field's properties.

For example, this one AcroForm field property have Font Size set at 10 & is Center aligned.  When this PDF get generated, the Font Size end up as 4 & is left aligned.  For some reasons, all of those AcroForm fields' properties setting aren't being preserved.

            for (int p = 0; p < pdfApp.PageCount(); p++)
            {
                // https://developers.foxitsoftware.com/kb/article/programmatically-extract-form-field-data-pdf-files/
                // http://www.quickpdf.org/forum/how-to-use-parent-child-fields_topic3702.html

                pdfApp.SelectPage(p);

                for (int fieldIX = 0; fieldIX < pdfApp.FormFieldCount(); fieldIX++)
                {
                    var fieldName = pdfApp.GetFormFieldTitle(fieldIX);
                    if (!string.IsNullOrEmpty(fieldName))
                    {
                        if (fieldName.EndsWith("."))  // This indicate we have AcroForm field-name duplications.  (FoxIt Quick PDF append the "." to it for unknown reasons).
                        {
                            fieldName = fieldName.Substring(0, (fieldName.Length - 1));
                        }

                        bool isString = true;  // Do we really need this?  (It is unused here & can be moved inside this "SendDpValuesToPdf" method instead).
                        var fieldResult = _formService.SendDpValuesToPdf(fieldName, formWriter, ref isString);
                        if (fieldResult.Value != null)
                        {
                            var fieldValue = fieldResult.Value;

                            pdfApp.SetFormFieldValue(fieldIX, fieldValue);
                            pdfApp.UpdateAppearanceStream(fieldIX);
                            pdfApp.SetFormFieldDefaultValue(fieldIX, fieldValue);
                            for (int childIX = 0; childIX < pdfApp.GetFormFieldKidCount(fieldIX); childIX++)
                            {
                                var tempIX = pdfApp.GetFormFieldKidTempIndex(fieldIX, childIX);
                                pdfApp.SetFormFieldValue(tempIX, fieldValue);
                                pdfApp.UpdateAppearanceStream(tempIX);
                                pdfApp.SetFormFieldDefaultValue(tempIX, fieldValue);
                            }
                        }
                    }
                }
                for (int fieldIX = 0; fieldIX < pdfApp.FormFieldCount(); fieldIX++)
                {
                    pdfApp.FlattenFormField(fieldIX);

                    // https://www.debenu.com/docs/pdf_library_reference/SetFormFieldReadOnly.php
                    pdfApp.SetFormFieldReadOnly(fieldIX, 1);
                }
            }




Edited by fletchsod - 16 Sep 20 at 9:31PM
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store