PDF edit problem

Hi,


I have a pdf file having 10(no of variables change pdf to pdf ) dynamic variables like <>, <> ect.

My requirement is to supply values(take values from database) for all dynamic variable and after replace, it generate a new pdf file.

Here problem is when I supply all 10 values to replace then it working fine, but if I supply less than 10 values then it generate a corrupted pdf file.

Below is the code I am using for edit pdf file.

using Aspose.Pdf;
using Aspose.Pdf.Text;

Aspose.Pdf.License license = new Aspose.Pdf.License();

license.SetLicense(“Aspose.Pdf.lic”);

PDFVariablesBAL myPDFVariablesBAL = new PDFVariablesBAL();
Dictionary<string, string> pdfVariableList = (Dictionary<string,string>)myPDFVariablesBAL.SelectAll(tempArrary[0], tempArrary[1]);

Document pdfDocument = new Document(pdfFilePath);
foreach (KeyValuePair<string, string> item in pdfVariableList)
{
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(item.Key);
pdfDocument.Pages.Accept(textFragmentAbsorber);
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
foreach (TextFragment textFragment in textFragmentCollection)
{
textFragment.Text = item.Value;
}
}

Please give a solution.

Thank you.

Hi Kali Charan,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for sharing the sample code.

I checked your issue with the latest version of Aspose.Pdf for .NET v7.0 but I am unable to reproduce the issue. Please share your template file, details of the dynamic variables and there values to help us reproduce the issue at our end. This will help us identify the cause of the issue soon and rectify it.

Sorry for the inconvenience,