Spire.PDFViewer is a powerful PDF Viewer component for .NET. It allows developers to load PDF document from stream, file and byte array.

Thu Jan 30, 2020 3:21 pm

Hi,

Please, do you know why The position given to a stamp in a scanned document is not respected ?

Best regard

mba91000
 
Posts: 18
Joined: Thu Jul 12, 2018 3:48 pm

Fri Jan 31, 2020 1:50 am

Hello,

Thanks for your inquiry.
Sorry I’m not very clear what you are referring to. To help us better understand and further look into your issue, please share us with your input testing file, your full testing code, your testing result file as well as your desired output for our reference. You also could send them to us via email(support@e-iceblue.com).

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1271
Joined: Wed Apr 25, 2018 3:20 am

Thu Feb 06, 2020 5:34 am

Hello,

Greetings from E-iceblue.
Could you please let us know how is your issue going? Thanks in advance for your feedback and time.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1271
Joined: Wed Apr 25, 2018 3:20 am

Fri Feb 28, 2020 3:36 pm

Hello,
I sent you a sample file for which the buffer position of the stamp is not respected.

Best regards

mba91000
 
Posts: 18
Joined: Thu Jul 12, 2018 3:48 pm

Mon Mar 02, 2020 7:33 am

Hello,

Thank you for sharing the sample file.
After analyzing, I found that your file is rotated 270 degrees, when you add the stamp, you need to rotate the page back firstly. Thus, please refer to the following sample code to add a stamp on the top left. If there is any other question, just feel free to contact us.
Code: Select all
 //load original pdf
 PdfDocument doc = new PdfDocument();
 doc.LoadFromFile(@"Test.pdf");
 //create a new pdf
 PdfDocument newPdf = new PdfDocument();
 //load the image to fill stamp
 PdfImage image = PdfImage.FromFile(@"logo.png");
 foreach (PdfPageBase page in doc.Pages)
 {
     PdfPageBase newPage;
     //judge if the page rotated and rotate it back
     if (page.Rotation == PdfPageRotateAngle.RotateAngle90)
         newPage = newPdf.Pages.Add(new SizeF(page.Size.Height, page.Size.Width), new PdfMargins(0));
     else if (page.Rotation == PdfPageRotateAngle.RotateAngle270)
         newPage = newPdf.Pages.Add(new SizeF(page.Size.Height, page.Size.Width), new PdfMargins(0));
     else
         newPage = newPdf.Pages.Add(page.Size, new PdfMargins(0));
     page.CreateTemplate().Draw(newPage, new PointF(0, 0));
     //add an image stamp on the top left
     PdfRubberStampAnnotation loStamp = new PdfRubberStampAnnotation(new RectangleF(new PointF(10, 10), new SizeF(20, 20)));
     PdfAppearance loApprearance = new PdfAppearance(loStamp);
     PdfTemplate template = new PdfTemplate(30, 30);
     template.Graphics.DrawImage(image, 0, 0);
     loApprearance.Normal = template;
     loStamp.Appearance = loApprearance;
     newPage.AnnotationsWidget.Add(loStamp);
 }
 newPdf.SaveToFile(@"result.pdf", Spire.Pdf.FileFormat.PDF);

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1271
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.PDFViewer