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

Free Support Forum - aspose.com

Enlarged file after replacement

Hi,
When I replace text in a pdf file as result I get enlarged file. I noticed it happens in case replacement value contains symbols which are not presented in the original file.

Java version: 11
Aspose pdf version: 21.8

Code sample:

Document pdfDocument = new Document("test.pdf");
TextFragmentAbsorber absorber = new TextFragmentAbsorber("document");
absorber.visit(pdfDocument);
TextFragmentCollection collection = absorber.getTextFragments();
AtomicInteger i = new AtomicInteger(0);
collection.forEach(fragment -> {
	fragment.setText(String.valueOf(i.incrementAndGet()));
});
pdfDocument.save("result.pdf");

test.pdf (35.7 KB)

@pshchasny

A ticket with ID PDFJAVA-41000 has been created in our issue tracking system to further investigate the issue on our end. This thread has been linked with the issue so that you may be notified once the issue will be fixed.