Hi Sirs,
When we processed the 34 pdf files, we got the Regex matching time out exception for the only two sample files.
For every page of the documents, we used Aspose pdf function to add 3 stamps and set color to empty in freetext annotation.
But we can’t reproduce the issue now, could you please help to check how to prevent the timeout exception from happening again?
Code area:
ContentsResizeParameters parameters = new ContentsResizeParameters(units(8.5), null, units(8.5), units(11), null, units(11));
try (Document pdfDocument = pdfDoc) {
PdfFileEditor editor = new PdfFileEditor();
editor.resizeContents(pdfDocument, parameters);
for (Page pdfPage : pdfDocument.getPages()) {
for (TextStamp textStamp : stampsToAdd) {
pdfPage.addStamp(textStamp);
}
// ASPOSE PDFJAVA-42528 recommendation: However, it is important to notice that the FreeText Annotation has incorrect properties,
// so any changes to its position or inside value cause changing it in black. You can try to make changes in Adobe Acrobat.
// So we also recommend setting an empty color to that annotation after resizing, to avoid a black rectangle on a page.
for (Annotation an : pdfPage.getAnnotations()) {
if (an instanceof FreeTextAnnotation freeText) {
freeText.setColor(com.aspose.pdf.Color.Empty);
}
}
}
pdfDocument.save();
} catch (Exception e) {
throw new Exception(e.getMessage(), e);
}
Three stamps are,
1. File name
2. Document: XX.XX.00000099
3. Bates Number: XX00012345
3stamps.png (2.9 KB)
Sample.zip (6.4 MB)