Hello,
I am trying to replace text in PDF files using the following code. The problem is that the text does not wrap if the line becomes too long due to the replacement text. Is there a way to handle this? I have attached sample input and output files to illustrate the problem.
Document pdfDocument = new Document("input.pdf");
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("rinse");
pdfDocument.Pages.Accept(textFragmentAbsorber);
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
foreach (TextFragment textFragment in textFragmentCollection)
{
textFragment.Text = "LONG REPLACEMENT TEXT";
}
pdfDocument.Save("output.pdf");
- Sumit
I am trying to replace text in PDF files using the following code. The problem is that the text does not wrap if the line becomes too long due to the replacement text. Is there a way to handle this? I have attached sample input and output files to illustrate the problem.
Document pdfDocument = new Document("input.pdf");
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("rinse");
pdfDocument.Pages.Accept(textFragmentAbsorber);
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
foreach (TextFragment textFragment in textFragmentCollection)
{
textFragment.Text = "LONG REPLACEMENT TEXT";
}
pdfDocument.Save("output.pdf");
- Sumit