I would like to report a performance issue that I’ve found on the “Page.AddStamp” method. Currently, we have a requirement to add rotated text to a PDF. The font of this text comes from an external file on the server (.TTF) and it is required that this full font set be embedded in the final PDF. Currently, we define the text stamp logic outside a loop and then add the stamp to a list of PDFs in a given directory.
The code I have is as follows to define the TextStamp object:
textStampTest = new TextStamp("");
textStampTest.TextState.FontSize = (float)appendToFontSize;
textStampTest.TextState.ForegroundColor = Color.FromCmyk(0, 0, 0, 1);
textStampTest.TextState.Font = Aspose.Pdf.Text.FontRepository.OpenFont(appendToFontFile);
textStampTest.TextState.Font.IsSubset = false;
textStampTest.TextState.Font.IsEmbedded = true;
textStampTest.Rotate = rotationAngle;
And the code that I have (in a loop) to stamp the page is simply:
pdfPage = (Aspose.Pdf.Page)pdfDocument.Pages[pageNumber];
textStampTest.YIndent = appendToPageYLocation;
if(pageNumber % 2 == 0)
textStampTest.XIndent = appendToPageXLocation_even;
textStampTest.XIndent = appendToPageXLocation_odd;
I have found that if we have “textStampTest.TextState.Font.IsSubset = false;”, the line of code “pdfPage.AddStamp(textStampTest);” takes about 2000ms (2 seconds) to complete.
If “textStampTest.TextState.Font.IsSubset = true;”, the same line of code (pdfPage.AddStamp(textStampTest) takes 10ms average to complete.
Our current version of Aspose.PDF (.NET) is 10.3.0.0 Any recommendations to help speed this up are GREATLY appreciated