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

Free Support Forum - aspose.com

AddStamp to pdf file issue

When I run the following code, I got IndexOutOfRangeException. I have attached the PDF file and image file, thanks.


PdfFileStamp fileStamp = new PdfFileStamp();
fileStamp.BindPdf(“R0920_Am10_Protocol_pv012516.pdf”);
//create stamp
Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
stamp.BindImage(“hawk.jpg”);
stamp.SetOrigin(200, 200);
stamp.Rotation = 90.0F;
stamp.IsBackground = true;

//add stamp to PDF file
fileStamp.AddStamp(stamp);
fileStamp.Save(“output.pdf”);

//save updated PDF file
fileStamp.Close();

Hi Caifang,


Thanks for using our API’s.

I have tested the scenario using latest release of Aspose.Pdf for .NET 12.0.0 and I am unable to notice any issue. For your reference, I have also attached the output generated over my end. Can you please try using the latest release and in case the issue still persists, please share some details regarding your working environment i.e. Operating System, .NET Framework version, Visual Studio version etc.

We are sorry for your inconvenience.
Thank you for looking into the issue.

I have ran it on 3 systems and all of them ended with an exception. Yes, the output file was stamped, exception was thrown out when fileStamp.Close(); was executed.

Here are 3 systems:
1. Windows 7, visual studio 2012 with .NET framework 4.5
2. Windows server 2012, visual studio 2012 with .NET framework 4.5
3. Windows server 2012, visual studio 2015 with .NET framework 4.5

I have attached the exception image so you may have a better understanding what went wrong.

Thanks,
Caifang

Hi Caifang,

Thanks for your inquiry. It seems you are using Aspose.Pdf without applying license file. Please note Aspose.Pdf evaluation version has two limitations, evaluation watermark and at most four elements of any collection can be viewed. If you already have a valid license file then please apply it otherwise please make a request for 30 days temporary license, it will resolve the issue.

Please feel free to contact us for any further assistance.

<span style=“font-size:10.0pt;line-height:115%;font-family:“Arial”,“sans-serif”;
mso-fareast-font-family:Calibri;color:#333333;mso-ansi-language:EN-US;
mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>Best Regards,

Thank you for your quick response.


After I applied the license, with the following code, NullReferenceException was thrown out when fileStamp.Close() was called.

PdfFileStamp fileStamp = new PdfFileStamp();
fileStamp.BindPdf(“R0920_Am10_Protocol_pv012516.pdf”);
//create stamp
Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
stamp.BindImage(“hawk.jpg”);
stamp.SetOrigin(200, 200);
stamp.Rotation = 90.0F;
stamp.IsBackground = true;
stamp.Pages = new[] { 1 };
//add stamp to PDF file
fileStamp.AddStamp(stamp);
fileStamp.Save(“output.pdf”);

//save updated PDF file
fileStamp.Close();

Hi Caifang,


Thanks for sharing the details.

I have tested the scenario using Aspose.Pdf for .NET 12.0.0 in VisualStudio 2015 project using .NET Framework 4.5, running over Windows 10 and as per my observations, the memory utilization is hiked by 14 GB till all available memory is consumed and system is brought to knees but I am unable to notice any exception. For the sake of correction, I have logged it as PDFNET-41557 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.

Thanks for your investigating this issue.


Our cutomer is wondering whether there is update regarding this issue.

Thanks again,
Caifang

Hi Caifang,


Thanks for your patience.

I am afraid the earlier reported issue is not yet resolved. However I have intimated the product team to try accommodating this issue in 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. We are sorry for this delay and inconvenience.

Hi,
I’m facing the same issue with Aspose.PDF for .NET 17.9.0.0 Trial.
I’ve requested the 30 days trial license. Everything works great except the PDFFileStamp.
It seems that it doesn’t works well on files bigger than 2-3MB, the Close() method returns always a NullReferenceException. Is it a 30Days Trial limitation?

I’m following the examples found in your documentation.

Thanks for support,
Mario

@mario.ferrante,
Kindly send us your source PDF and code. We will investigate and share our findings with you.

Hi Imran,
thank you for your response.
The code is taken from your examples:

PdfFileStamp fileStamp = new PdfFileStamp();
fileStamp.BindPdf(inputPDFFile);
Aspose.Pdf.Facades.Stamp stamp = new Aspose.Pdf.Facades.Stamp();
stamp.BindImage(stampImageFile);
stamp.SetOrigin(x, y);
// Add stamp to PDF file
fileStamp.AddStamp(stamp);
// Save updated PDF file
fileStamp.Save(outputPDFFile);
// Close fileStamp
fileStamp.Close(); <-- Here I obtain a NullReferenceException

You can try to use any PDF file bigger than 3MB.

Should I use an ImageStamp instance instead of PDFFileStamp?

Regards,
Mario

@mario.ferrante

Thanks for sharing sample code snippet.

Please note that, in order to test the scenario and try to observe the same issue, we need a sample PDF document, with which you are experiencing it. We will really appreciate if you can please share a sample PDF document, so that we can test the scenario in our environment and address it accordingly.

We always recommend to use new Aspose.Pdf DOM approach in order to implement API features. Please check “Adding Image Stamp” article in our API documentation and try it on your side. In case your still face any issue please let us know.