Hi,
I am evaluating DynamicPDF Merger for a work project, and I have a question about setting form field properties. Is it possible to set the visual properties of the form fields in code, such as font, font color, font size, etc.? I see how to fill the fields using the Value property, however I also would like to set the font, color, etc. at the same time for each field in the form.
Please let me know if that's possible and how this could be done. Thanks
Setting font properties for Form Fields
Re: Setting font properties for Form Fields
Support · May 24, 2006Hello,
You can set the font, font color, etc. for the form fields using the CreateLabel method of the PdfFormField class. Using the CreateLabel method the form fields will be flattened.
Some sample code for using the CreateLabel is below:
[Visual Basic]
Dim MyPdfDocument as PdfDocument = New PdfDocument( filePath )
Dim MyDocument As MergeDocument = New MergeDocument( MyPdfDocument )
Dim MyPage as Page = MyDocument.Pages( 0 );
MyPdfDocument.Form.Fields( "f1-4" ).CreateLabel( MyPage, "123 Main Street", ceTe.DynamicPDF.Font.Courier, 12, TextAlign.Center, RgbColor.Red )
MyPdfDocument.Form.Fields( "f1-5" ).CreateLabel( MyPage, "Anytown, DC 12345", ceTe.DynamicPDF.Font.Courier, 12 )
MyDocument.Draw( "C:\MyDocument.pdf" )
[C#]
PdfDocument pdfDocument = new PdfDocument( filePath);
MergeDocument document = new MergeDocument( pdfDocument );
Page page = document.Pages[0];
pdfDocument.Form.Fields["f1-4"].CreateLabel( page, "123 Main Street", ceTe.DynamicPDF.Font.Courier, 12, TextAlign.Center, RgbColor.Red );
pdfDocument.Form.Fields["f1-5"].CreateLabel( page, "Anytown, DC 12345", ceTe.DynamicPDF.Font.Courier, 12 );
document.Draw( @"C:\MyDoc.pdf" );
This is actually discussed in more detail in one of our help topics. Take a look at the "Form Flattening" page of our documentation, http://www.DynamicPDF.com/Support/NET_Help_Library_06_03/Form%20Flattening.html
under the section labeled "Replace Acro Form Fields with Text".
Thanks,
ceTe Software Support Team
Re: Setting font properties for Form Fields
Forum member · May 24, 2006Excellent. I'll give that a try. Thanks for the quick reply.