Put html-text in formfield

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v8)  /  Put html-text in formfield

DynamicPDF CoreSuite for .NET (v8) Forum

 Nov 25 2015 9:26 AM
I have a PFD-form with several formfields. I fille this field from my database, and 1 field contains html-tekst. How can I render this html-test to this textfield?

I can get the formatted-text(html) in an area, but how can I fill this formatted tekst in the existing formfield?

FormattedTextAreaStyle style = new FormattedTextAreaStyle(ceTe.DynamicPDF.FontFamily.Helvetica, 10, true);
FormattedTextArea area = new FormattedTextArea(Convert.ToString(sAanvraagOpmerking), 10, 10, 200, 100, style);

The form was made in Acrobat Pro XI, and the field is a textfield.

I fill teh field with the code:
document.Form.Fields[sOms].Value = area.Text;

On the print I see simple tekst with the ttml-codes instead of formatted text. How can I solve this problem?


 Nov 25 2015 11:42 AM
Posted by a ceTe Software moderator
Hello,

The Text property on FormattedTextArea just returns the HTML text you assigned to it and it does not return the rendered text. So if you assign this HTML text directly to the text field, it will display the html text as-is without rendering the tags, because the PDF text field is not capable of rendering HTML tags.  It is not possible to fill the text field with rendered HTML text and let the user edit that text. What you can do is, remove the text field and replace it with the FormattedTextArea that you have created with the HTML text.

Here is the proof of concept code that shows how to replace the text field with a FormattedTextArea: 

           // Create a PDF Document with text field.
            Document document = new Document();
            Page page = new Page(PageSize.Letter);            
            ceTe.DynamicPDF.PageElements.Forms.TextField textField = new ceTe.DynamicPDF.PageElements.Forms.TextField("txtField", 50, 75, 250, 250);                        
            textField.MultiLine = true;            
            page.Elements.Add(textField);            
            document.Pages.Add(page);

            //Save and open the PDF that contains the text field.
            PdfDocument pdf = new PdfDocument(document.Draw());
            MergeDocument mergeDoc = new MergeDocument(pdf);
           
            //remove the text field from the form.
            mergeDoc.Form.Fields["txtField"].Output = FormFieldOutput.Remove;
            PdfFormField txtField = pdf.Form.Fields["txtField"];
            Page txtFieldPage = mergeDoc.Pages[txtField.GetOriginalPageNumber()-1];

            string formattedText = "<p>Formatted text area provide rich formatting support for text that " +
            "appears in the document. You have complete control over 8 paragraph properties: " +
            "spacing before, spacing after, first line indentation, left indentation, right " +
            "indentation, alignment, allowing orphan lines, and white space preservation; 6 " +
            "font properties: <font face='Times'>font face, </font><font " +
            "pointSize='6'>font size, </font><font color='FF0000'>color, " +
            "</font><b>bold, </b><i>italic and </i><u>" +
            "underline</u>; and 2 line properties: leading, and leading type. Text can " +
            "also be rotated.</p>";
           
            //create a FormattedTextArea and add it in place of the removed text field.
            FormattedTextAreaStyle style = new FormattedTextAreaStyle(ceTe.DynamicPDF.FontFamily.Helvetica, 10, true);
            FormattedTextArea area = new FormattedTextArea(formattedText, txtField.GetX(txtFieldPage), txtField.GetY(txtFieldPage), txtField.Width, txtField.Height, style);
            txtFieldPage.Elements.Add(area);

            mergeDoc.Draw("Final.pdf");

Thanks,
ceTe Software Support Team.
 Nov 26 2015 6:05 AM
Thank you for your answer. It is working, but I get a watermark in the new htmltext, telling me 'Evaluating unlicensed DynamicPDF feature. Click here for details. [3:45:d1:v8.0]'.
 
It must be a fuinction in underlaying code, i think in the add(area) function.
I have a licence for enterprise
<LicenseType>Developer Enterprise Subscription</LicenseType>
<LicenseNote>Limited to 1 developer.</LicenseNote>
<LicenseVersion>2.2</LicenseVersion>

ceTe.DynamicPDF.Merger.Forms.PdfFormField txtField = pdfdoc.Form.Fields[sOms];
Page txtFieldPage = document.Pages[txtField.GetOriginalPageNumber() - 1];

//create a FormattedTextArea and add it in place of the removed text field.
FormattedTextAreaStyle style = new FormattedTextAreaStyle(ceTe.DynamicPDF.FontFamily.Helvetica, 10, true);
FormattedTextArea area = new FormattedTextArea(Convert.ToString(sAanvraagOpmerking), txtField.GetX(txtFieldPage), txtField.GetY(txtFieldPage), txtField.Width, txtField.Height, style);
txtFieldPage.Elements.Add(area);
 Nov 27 2015 3:46 AM
Sorry, the licence info is of another product.Can I mail you my CeTE.DeveloperLicenceKey.
DynamicPDF Core Suite v8.0 for .NET
I want to know why I get this evaluation message, only on the new htmp-text box that is inserted in my form.
 Nov 27 2015 4:00 AM
Posted by a ceTe Software moderator
Hello,

The watermark numbers [3:45:d1:v8.0] indicates that you might be using Enterprise Edition features in your application and you have license for Professional Edition. Please make sure to use only the Professional Edition features in your application and this should work for you. You can refer to the feature chart for DynamicPDF Core Suite for .NET product here.

Please try setting the Tag property of the MergeDocument object to null just before you draw the PDF and see if it works for you. Below is code sample for it.

     mergeDoc.Tag=null;
     mergeDoc.Draw("Final.pdf");

If you continue getting watermark on the generated PDF then please send over the following details to support@cete.com so we can look into it further.

1.Input PDF used for merging and filling.
2.Output PDF having watermark on it.
3.DynamicPDF license key added to the application.

Thanks,
ceTe software Support Team.
 Nov 27 2015 4:09 AM
Thank ypou for your reply.
adding mergeDoc.Tag=null; before draw is the solution. Now it works fine.

 Dec 16 2015 3:38 AM
I get html code in an other format, than in your example.
My html-code is
<span style="font-weight: bold">aaaaaaaaaaaaaaaaaaa123456789 </span>123456789 123456789 123456789 <span style="font-size: 12pt">123456789 123456789 123456789 </span>
 123456789  123456789 123456789 123456789 <span style="text-decoration: underline">123456789 123456789 123456789 </span>
 123456789 123456789 123456789 <span style="font-family: times new roman,times,serif; background-color: #ffff00">123456789 123456789 123456789 </span>
 123456789 123456789 123456789 123456789 123456789 <span style="font-style: italic; font-weight: bold; text-decoration: underline">123456789 </span>
 123456789 123456789 123456789 123456789 <span style="font-size: 12pt; font-weight: bold">123456789 123456789 123456789 1234567123456789 123456789  123456789 123456789 123456789
 123456789 </span>1

instead of

<p>Formatted text area provide rich formatting support for text that appears in the document. You have complete control over 8 paragraph properties: spacing before, spacing after,
 first line indentation, left indentation, right indentation, alignment, allowing orphan lines, and white space preservation; 6 font properties: <font face='Times'>font face,
 </font><font pointSize='6'>font size, </font><font color='FF0000'>color, </font><b>bold, </b><i>italic and </i><u>underline</u>; and 2 line properties: leading, and leading type.
 Text can also be rotated.</p>
format
Can dynamicpdf also work with this style?
 Dec 16 2015 9:13 AM
Posted by a ceTe Software moderator
Hello,

The FormattedTextArea of DynamicPDF API does not support ‘span’ HTML tag. You will need to use the color attribute of font tag to set the color and ‘b’ tag to add the text with bold style. Please refer to the documentation on supported HTML tags here.

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 12:42 AM.