Print Page | Close Window

Field property- Font Size/Alignment arent preserve

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3844
Printed Date: 22 Oct 20 at 1:48PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Field property- Font Size/Alignment arent preserve
Posted By: fletchsod
Subject: Field property- Font Size/Alignment arent preserve
Date 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);
                }
            }





Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk