We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Find and replace text

I bought a license for aspose.pdf and aspose.words

In pdf, i have a text, say “Address”

I need to replace it with actual address which is very long

the text is not breaking into next line, rather, beyond the layout, i m losing the text

can you help me in this? i need to replace the address with actual value, which is typically 100 chars long

I follow this link http://www.aspose.com/docs/display/pdfnet/Replace+Text+in+all+pages+of+a+PDF+Document

lets say my address is "1212, New Street, ABC Village, West Coast Town, Phantom City, ABC State, United Stated of America, Zip Code:154252"

this cant fit in a single line. it should automatically go to next line, I cant see it in output pdf at all


This message was posted using Email2Forum by Tahir Manzoor.
The code is as below:

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

docLicense.SetLicense(@"C:\Aspose.Pdf.lic");

Document pdfDocument = new Document(@"C:\Temp\Address.pdf");
//create TextAbsorber object to find all instances of the input search phrase
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("Address");
//accept the absorber for all the pages
pdfDocument.Pages.Accept(textFragmentAbsorber);
//get the extracted text fragments
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
//loop through the fragments
foreach (TextFragment textFragment in textFragmentCollection)
{
//update text and other properties
textFragment.Text = "#1111,New Number 1112, 1A Cross, 2nd Block, 5th Main, 3rd Phase, Empire Building, Castle Street,Brookfield Village, Cox Town, Atlanta Suburb, East Coast, Manhattan Island, United States of America, Zip Code-1012010 ";
textFragment.TextState.Font = FontRepository.FindFont("Verdana");
textFragment.TextState.FontSize = 12;
}

pdfDocument.Save(@"C:\Temp\output.pdf");

Attached are the Input and Output Files

Hi there,

We are sorry for the inconvenience caused. While testing the scenario with the latest version of Aspose.Pdf for .NET 9.5.0, we have managed to reproduce the reported issue and logged it in our bug tracking system as PDFNEWNET-37394 for further investigation and resolution. We will notify you via this thread as soon as it is resolved.

Please feel free to contact us for any further assistance.

Best Regards,

The issues you have found earlier (filed as PDFNET-37394) have been fixed in Aspose.PDF for .NET 18.7.