PDF without fields definitions

PDF without fields definitions

Forum member · Oct 28, 2005
Hello everybody, I need to use a MergeDocument object in order to fill in form fields. At the end of the process I need to produce a PDF file that contains only the data and not the fields definitions, in order to reduce the file size. Many thanks in advance. Carla Covizzi

Re:PDF without fields definitions

Support · Oct 28, 2005
Carla, The best way to accomplish this is by using our CreateLabel method on the PdfDocument's 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" ); 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/html/DynamicPDFMergerNETProgrammingWithMergerNetWorkingWithAcroFormsFormFlattening.htm under the section labeled "Replace Acro Form Fields with Text". Thanks, ceTe Software Support Team

Re:PDF without fields definitions

Forum member · Oct 31, 2005
Hello everybody, I read the reply to my question but I can't use the CreateLabel method because I have to use the form-fields' properties (ex. Font and FontSIze). That is, I have a form field that has Arial as Font: if I use the Value property of the form I insert text using Arial as the default Font (without any effort). If I use the CreateLabel method I have to specify the font and the fontsize in order to recreate the form fields' ones. But I haven't found a way to get this infos from the form field and, overall, I don't want to load Fonts at runtime to improve performance. Is there a way to solve my problem? Many thanks in advance. Best Regards. Carla Covizzi

Re:PDF without fields definitions

Support · Oct 31, 2005
Carla, well using the CreateLabel method is the only way to strip the form fields out of the PDF and yet still place the required text at their locations. While this will decrease the size of your file significantly there is still the limitation of needing to specify the font and font size inside the CreateLabel method call. You mentioned that you were worried about overall performance. Specifying the font and font size at runtime using our CreateLabel object is actually a more efficient way of building the PDF. The Arial Font is practically identical to Helvetica (Helvetica is one of our 14 built-in core fonts and is very efficient to use). In fact on Windows machines Helvetica is used whenever Arial is specified. The best way to achieve the results that are as close to your needs as possible would be to use the Helvetica font with our CreateLabel method. Thanks, ceTe Software Support Team