Free Support Forum - aspose.com

Preserve the highlighting of text in output file

How Can I preserve the formatting of my pdf file after filling up the form fields from a datasource?

I am using autoFiller method to fill the form fields. But after using AutoFiller.Save method, all the formatting is gone. In my original pdf file, I have highlighted some text with background of Yellow color. But in the outputfile, there is no higlighting.

Is there any way that I can preserve the highlighting? Please find my original file as attachment.

Regards,

Pareena Bawa

Thanks for considering Aspose.

We will test the file and give u a reply ASAP.

Hi,

I downloaded your file and found that there are two text fields having the same field name, one in Page 1, the other in Page 2.

In my test, all is ok except that the two fields having the same value as what was set latter. I wonder this could be the reason. So please change some other name and try again. Any more question is welcomed.

Best regards.

Hi,

Thanks for the consideration.

I tried after removing the fields with same name but the problem persists. The pages on which there are no merge fields, the formatting do remains but not on the pages with merge fields.

any suggestions?

Thanks.

We've reproduced the problem you said, and it will be solved ASAP.

Best regards.

Hi, I tested your file again and it turned out to be correct again, even without removing the duplicating field! The problem occured yestoday is something wrong about test program. Here is my test code, and you can tell me the result after testing with it yourself:

AutoFiller autoFiller = new AutoFiller();

autoFiller.InputFileName = "B29_1.pdf";
autoFiller.OutputFileName = "B29_1_auto_output.pdf";

//Construct the data table with only 3 columns

DataTable mDataTable = new DataTable();
DataColumnCollection columns = mDataTable.Columns;
columns.Add("CompanyNameHospital",typeof(string));
columns.Add("NameFormatted",typeof(string));
columns.Add("SocialSecurityNumber",typeof(string));


//construct two row of data which should be obtained from DB
DataRow myRow = mDataTable.NewRow();
myRow["CompanyNameHospital"] = "aspose.com";
myRow["NameFormatted"] = "duplicated";
myRow["SocialSecurityNumber"] = "23045-123-1435";
mDataTable.Rows.Add(myRow);

DataRow hisRow = mDataTable.NewRow();
hisRow["CompanyNameHospital"] = "aspose.kit.com";
hisRow["NameFormatted"] = "another one";
hisRow["SocialSecurityNumber"] = "888-8888-8885";
mDataTable.Rows.Add(hisRow);

autoFiller.ImportDataTable(mDataTable);
autoFiller.Save();

I constructed data staticly and only filled three fields, including the duplicated one. The output file consistes of 4 correct Pages, all highlights remains.

I would like to remind that you should pay attention to:
1. The filled field will be flattened if you didn't call the method AutoFiller.IsFlattenField (string fieldName)
2. Please be sure that the data obtained from DB is right for the PDF template
3. Also be sure that you get the latest verion of Aspose.Kit.

Sorry for the inconvinience brings to you and we will help you until it works.

Best regards.