CreateLabel

CreateLabel

Forum member · Mar 23, 2007
I'm using Merger to merge multiple PDFs into one. I need to create a flat PDF (no acro form fields). I saw on here that there is supposed to be a CreateLabel function for the FormField object, but it doesn't appear to be in my version of the library. I am fairly certain it is up to date. Are there any versions (that support acro form fields) that do not support creating labels on top of the existing form fields? Greg

Re: CreateLabel

Support · Mar 23, 2007
Hello Greg, You can use the CreateLabel method without any problem to flatten the form fields. Following is the link to the Help Documentation on our web site that shows use of CreateLabel . Refer to "Replace Acro Form Fields with Text" section on the page. Thanks, ceTe Software Support Team

Re: CreateLabel

Forum member · Mar 23, 2007
Thanks, but it doesn't appear that the CreateLabel exists. I am checking with our network admin to see if we have the latest and greatest version. From what I can tell, we have 4.0.1 of Merger.

Re: CreateLabel

Support · Mar 23, 2007
Hello, The CreateLabel method is off the PdfDocument object. Are you creating instance of the PdfDocument object. Also make sure that you are having the using or Imports statement at the top of your code to include the namespace to which PdfDocument class belongs to. The CreateLabel method is definitely available in the version of the product you have. VB.Net Code: Imports ceTe.DynamicPDF.Merger C#Code: using ceTe.DynamicPDF.Merger Thanks, ceTe Software Support Team

Re: CreateLabel

Forum member · Mar 23, 2007
I am assuming this is not available as a method in the MergeDocument object? That is what I am attempting to do. I create a base MergeDocument, and then append the PdfDocuments, with MergeOptions(true, "somePrefix") after they have all been added, I loop through and populate the fields.

Re: CreateLabel

Support · Mar 23, 2007
That is correct. The CreateLabel method is off of the PdfDocument not off of the MergeDocument object. Thanks, ceTe Software Support Team

Re: CreateLabel

Forum member · Mar 24, 2007
What do I do if the same name is used for two different textboxes in the same document, or on the same page of the same document? How does CreateLabel differentiate between the two?

Re: CreateLabel

Forum member · Mar 24, 2007
I'm still having issues with this. I posted some sample code below: This function takes a generic list of field objects (my own class design) and attempts to populate a PDF with the data. The function has two parameters, the first the collection of fields, the second a PdfDocument that is to be merged into the main document (this.applicationPDF) which is a MergeDocument. However, when I render the mergedocument (to disk) the pages are there, but nothing was filled in. What should I look for? Greg private void populatePDFFields(List<IPDFField> fields, PdfDocument document) { MergeDocument mergeDocument = new MergeDocument(document); // Loop through each page in the document foreach (Page currentPage in mergeDocument.Pages) { // Loop through the collection of fields foreach (IPDFField field in fields) { // Set the value of the textbox // If the field does not exist, quietly continue try { document.Form.Fields[((PDFField<String>)field).Fieldname].CreateLabel(currentPage, ((PDFField<String>)field).FieldValue, Font.ZapfDingbats, 10, TextAlign.Center, RgbColor.Blue); } catch (NullReferenceException) { } } } this.applicationPDF.Append(document); }

Re: CreateLabel

Support · Mar 26, 2007
Hello, You are getting the PDF with blank form field values is because you are not merging the correct filled document. You are appending the PdfDocument object but you will have to append the MergeDocument object. Also you do not have to loop through the pages of the document as the FormField list will contain all the form fields in the document. The code you will have to use should like like the following. PdfDocument pdfDocument = new PdfDocument(@"C:\Temp\DocA.pdf"); MergeDocument merDocument = new MergeDocument(pdfDocument, new MergeOptions(false)); for(int i=0; i<pdfDocument.Form.Fields.Count; i++) { PdfFormField field = pdfDocument.Form.Fields[i]; if(field is PdfTextField) field.CreateLabel(merDocument.Pages[(field.GetOriginalPageNumber()-1)],"ceTe Software", Font.TimesItalic, 15); } merDocument.Draw(@"C:\Temp\output.pdf"); Thanks, ceTe Software Support Team.

Re: CreateLabel

Forum member · Mar 26, 2007
I'll look into that. How do I deal with multiple text fields having the same name? Also, how do I deal with checkbox and radio button fields? I have two checkboxes, both named "Option1". One has a checked value of "Yes" and the other has a checked value of "No" Does this automatically take that into consideration? Greg

Re: CreateLabel

Support · Mar 26, 2007
Hello Greg, If the two text fields has the same name then it will fill both the text fields with the same value when filling one field also. document.Form.Fields["text"].Value = "ceTe Software"; It will fill both the text fields with "ceTe Software". For check box and Radio buttons you will have to fill using their name and the Export value. document.Form.Fields["Option1"].Value = "Yes"; checks the check box with export value "Yes". Thanks, ceTe Software Support Team.

Re: CreateLabel

Forum member · Mar 26, 2007
Thanks. I'll give this a try. Greg