Form fields in tables

Last post 07-07-2009, 10:20 AM by Emil.Hu. 6 replies.
Sort Posts: Previous Next
  •  06-30-2009, 12:52 PM 186196

    Form fields in tables .NET

    I am creating a PDF document that uses Table.ImportTable to insert a table in the document.  This seems to work great.  Once I loop through each row to insert a Form Field in each row, I get this error , "Non-unique field name: text14."  Any ideas on how to get around this?  I've included the code.

    protected void Page_Load(object sender, EventArgs e)
            {
                Aspose.Pdf.License license = new Aspose.Pdf.License();
                license.SetLicense("Aspose.Pdf.lic");

                dataTable = this.GetTypesOfInsurance();
                Pdf pdf1 = new Pdf();
     
                section1 = pdf1.Sections.Add();

                Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();
                section1.Paragraphs.Add(tab1);
                tab1.ColumnWidths = "200 100 100";
                tab1.DefaultCellBorder = new BorderInfo((int)BorderSide.All, 0.1F);

                tab1.ImportDataTable(this.CreateTable(), true, 0, 0);

                int index = 0;
                foreach (Row currentRow in tab1.Rows)
                {
                    foreach (Cell curCell in currentRow.Cells)
                    {
                        if (curCell == currentRow.Cells[2])
                        {
                            //Add Form Field to last column
                            FormField text = new FormField();
                            text.FormFieldType = FormFieldType.Text;
                            text.TextIsMultiLine = true;
                            text.TextFontSize = 12;
                            text.TextFontName = "Helvetica";
                            text.FormHeight = 35;
                            text.BackgroundColor = System.Drawing.Color.LemonChiffon;
                            text.FieldName = "text" + index;

                            curCell.Paragraphs.Add(text);
                            index++;
                        }
                    }
                }
               

                //Save the Pdf
                pdf1.Save("Test.pdf", SaveType.OpenInBrowser, Response);
            }

    protected DataTable CreateTable()
            {
                DataTable table = new DataTable("CompanyInfo");
                table.Columns.Add("Value1", typeof(string));
                table.Columns.Add("Value2", typeof(string));
                table.Columns.Add("Value3", typeof(string));

                for (int i = 0; i <= 60; i++ )
                {
                    DataRow dr = table.NewRow();
                    dr[0] = "Record " + i.ToString();
                    dr[1] = DateTime.Now.Millisecond;
                    dr[2] = "";
                    table.Rows.Add(dr);
                }
                return table;
            }
     
  •  06-30-2009, 2:44 PM 186214 in reply to 186196

    Re: Form fields in tables

    Attachment: Present (inaccessible)

     

    Hello Huy,

     

    Thanks for considering Aspose.

     

    I've tested the scenario using Aspose.Pdf 4.0.0.0 and the code snippet that you have shared and I am unable to reproduce the problem. The resultant PDF that I've generated is in attachment, please take a look.


    Nayyer Shahbaz
    Support Developer, Aspose Sialkot Team
    About Us
    Contact Us

    Keep in touch! We're on Twitter and Facebook
     
  •  06-30-2009, 4:17 PM 186234 in reply to 186214

    Re: Form fields in tables

    I ran a couple more tests and found out that if my table has less than 13 rows, then I DO NOT get this error.  I've published this project to see if others get this error too, and they do.  I'm running Acrobat 8 with all the updates.  Does Aspose.Pdf 4.0.0.0 work for a specific version of Reader?
     
  •  06-30-2009, 11:24 PM 186254 in reply to 186234

    Re: Form fields in tables

    Hi,

         I am the developer of Aspose.Pdf responsible for this issue. I have reproduced this problem and logged it as PDFNET-9522 in our defect database. I think the reason lies on the table-break function when the table with formfield crossing pages. We will resovle it ASAP.

    BRs


    Emil Hu
    Product Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  07-01-2009, 8:50 AM 186394 in reply to 186254

    Re: Form fields in tables

    Attachment: Present (inaccessible)

    Hi,

           This issue has been resolved in the fixed version, please try the attachment. Sorry for invenience.

    BRs


    Emil Hu
    Product Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  07-06-2009, 10:32 AM 187089 in reply to 186394

    Re: Form fields in tables

    Thanks for responding so quickly and offering a solution.  I tried the new dll that you sent me, but I found another bug.  If the table that I import contains long text, making the text wrap in the column, my pdf crashes.  I think this bug is also related to the height of the form field that I set.  If I decrease the height of the form field, the text can be longer in the other columns.  Below is the method I used to create the table to import.  The second column is the one with the long text.

    protected DataTable CreateTable()
            {
                DataTable table = new DataTable("CompanyInfo");
                table.Columns.Add("Value1", typeof(string));
                table.Columns.Add("Value2", typeof(string));
                table.Columns.Add("Value3", typeof(string));

                for (int i = 0; i <= 100; i++ )
                {
                    DataRow dr = table.NewRow();
                    dr[0] = "Record " + i.ToString();
                    dr[1] = "The red fox has orangish-red fur on its back, sides and head. It has white fur under its neck and on its chest. It has a long bushy tail tipped in white, pointed black ears and black legs and feet.";
                    dr[2] = "";
                    table.Rows.Add(dr);
                }
                return table;
            }
     
  •  07-07-2009, 10:20 AM 187313 in reply to 187089

    Re: Form fields in tables

    Attachment: Present (inaccessible)

    Hi,

         This problem is another case of the formfield acrossing pages. We have fixed it in the attachment, please try it. Sorry for inconvenience.

    BRs


    Emil Hu
    Product Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
View as RSS news feed in XML