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

Free Support Forum - aspose.com

Text search&replace and auto line break => possible?

Hi Aspose team,

imagine scenario where you need to make search & replace of string(s) in PDF document.
If you have for example text that will fill complete row:

"you dramatically reduce the load on your server while leveraging JavaScript's" and you need to make replacement where "dramatically reduce" will be replaced with something very long like "Concurrent connections impact on memory allocation in Apache versus Nginx".

By doing this line will be
""you Concurrent connections impact on memory allocation in Apache versus Nginx the load on your server while leveraging JavaScript's". My problem is that complete text will be in one line so it will go out of document page.

Is there anyway to instruct that Aspose.PDF automatically makes line break if text is longer then line?

Thanks,
Oliver

Hi Oliver,


Thanks for contacting support.

When replacing text inside PDF document, if the contents reach right page margin, the line break automatically occurs. However for above stated scenario, please share your source PDF file and code snippet, so that we can test the scenario in our environment. We are sorry for your inconvenience.
Hi Nayyer,

please find attached test project. After placing license file in debug folder just run PDF.EXE and in output document on the second page you will see that no line break is done.

I was searching for "Information and views" and making replacement with

"ASPOSE ASPOSE ASPOSE ASPOSE ASPOSE ASPOSE ASPOSE ASPOSE ASPOSE ASPOSE ASPOSE ASPOSE ASPOSE ASPOSE ASPOSE ASPOSE ASPOSE ASPOSE ASPOSE ASPOSE ASPOSE ASPOSE ASPOSE ASPOSE "

Thanks for check,
Oliver

Hi Oliver,


Thanks for sharing the details.

In order to auto line break when replacing text, you may consider using textFragmentAbsorber.TextReplaceOptions.ReplaceAdjustmentAction = TextReplaceOptions.ReplaceAdjustment.WholeWordsHyphenation; code line. However during my testing, I have observed that line break is not being honored even when using above specified code line. For the sake of correction, I have logged this problem
as
PDFNEWNET-39994 in our issue tracking system. We will
further look into the details of this problem and will keep you updated on the
status of correction. Please be patient and spare us little time. We are sorry
for this inconvenience.

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