Posted by a ceTe Software moderator
Hello,
When using the CreateLabel method to do the form flattening you do not need to specify the coordinates of the form field. The CreateLabel method creates a Label object and adds it to the page at the coordinates of that particular form field. 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-1" ).CreateLabel( MyPage, "Acme Corp.", ceTe.DynamicPDF.Font.Courier, 12 )
MyPdfDocument.Form.Fields( "c1-2" ).CreateLabel( MyPage, 2.5f, -2.5f, "3", ceTe.DynamicPDF.Font.ZapfDingbats, 12 )
MyPdfDocument.Form.Fields( "f1-4" ).CreateLabel( MyPage, "123 Main Street", ceTe.DynamicPDF.Font.Courier, 12 )
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-1"].CreateLabel( page, "Acme Corp.", ceTe.DynamicPDF.Font.Courier, 12 );
pdfDocument.Form.Fields["c1-2"].CreateLabel( page, 2.5f, -2.5f, "3", ceTe.DynamicPDF.Font.ZapfDingbats, 12 );
pdfDocument.Form.Fields["f1-4"].CreateLabel( page, "123 Main Street", ceTe.DynamicPDF.Font.Courier, 12 );
pdfDocument.Form.Fields["f1-5"].CreateLabel( page, "Anytown, DC 12345", ceTe.DynamicPDF.Font.Courier, 12 );
document.Draw( @"C:\MyDoc.pdf" );
Please refer to the "Form Flattening" topic in the Help documentation,
http://www.DynamicPDF.com/Support/NET_Help_Library_10_03/Form%20Flattening.html and refer section labeled "Replace Acro Form Fields with Text".
In v6.0, you can also get the font being used by the form field and use that font in the CreateLabel method instead of specifying your own font.
Thanks,
ceTe Software Support Team