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

Free Support Forum - aspose.com

Page.AddStamp slow performance

Good day,

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)
//Even page.
textStampTest.XIndent = appendToPageXLocation_even;
//Odd page.
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):wink: takes 10ms average to complete.

Our current version of Aspose.PDF (.NET) is Any recommendations to help speed this up are GREATLY appreciated

Thank you!

Hi Dave,

Thanks for contacting support.

When using IsSubset = true, the complete font is not embedded and therefore API takes less time to add stamp object. However when IsEmbedded is set to true, the API takes time embed complete font inside PDF document. However please share some sample project, along with resource TIFF file, so that we can test the scenario in our environment. We are sorry for your inconvenience.

Hi Nayyer,

Below is a little code that shows my problem.

static void Main(string[] args)
//Add Stamps to PDFs (Subset)
for(int i = 1; i < 100; i++)
AddStamp(i, true);

//Add Stamps to PDFs (Not subset)
for(int i = 1; i < 100; i++)
AddStamp(i, false);


private static void AddStamp(int ocrCode, bool isSubset)
Document pdfDocument = new Document("./SamplePDF.pdf");
TextStamp textStampTest = new TextStamp((100000 + ocrCode).ToString(“000000000”));
textStampTest.TextState.FontSize = 8.0f;
textStampTest.TextState.ForegroundColor = Color.FromCmyk(0, 0, 0, 1);

textStampTest.TextState.Font = Aspose.Pdf.Text.FontRepository.OpenFont("./ocrb10n.TTF");
textStampTest.TextState.Font.IsSubset = isSubset;
textStampTest.TextState.Font.IsEmbedded = true;

textStampTest.Rotate = Rotation.None;

Page pdfPage = (Aspose.Pdf.Page)pdfDocument.Pages[1];

textStampTest.YIndent = 200;
textStampTest.XIndent = 75;


pdfDocument.Save("./Stamp-"+ (isSubset ? “SubSet” : “FullSet”) + “/Output” + ocrCode.ToString(“000”) + “.pdf”);


The sample PDF and font file are attached as well. This code will write out 99 PDFs. When subset is TRUE, the PDFs get updated and saved VERY quickly. When it’s set to FALSE, the PDFs get updated and saved quite slowly. Again, it’s the “AddStamp” line that takes the time.

Thank you for your help.

Hi Dave,

Thanks for sharing the source code ad files. I have tested the scenario and noticed the performance issue, so logged a ticket PDFNEWNET-40133 in our issue tracking system for further investigation and resolution. We will keep you updated about the issue resolution progress.

We are sorry for the inconvenience caused.

Best Regards,

Good Day,

It’s been almost 5 months, Has there been any movement on this issue?

Thank you,


Hi Dave,

Thanks for your patience.

I am afraid the issue reported earlier is still pending for review and is not yet resolved, as the team has been busy fixing other previously reported high priority issues. However the product team will surely start investigating this problem as per their development schedule and as soon as we have some definite updates regarding its resolution, we will let you know.

Please be patient and spare us little time.


Here we are, one full year after the initial report. Has there been any movement on issue PDFNEWNET-40133?

Thank you.

Hi Dave,

Thanks for your patience and sorry for the delayed response.

The product team started investigating earlier reported issue but I am afraid its not yet resolved. However I have intimated the product team to share the possible updates regarding its resolution and as soon as we have some further updates regarding its resolution, we will let you know.

We are sorry for this inconvenience.