Merge Aspose pdf stamp and Pdf contents

Hi,

I’m trying to apply a pdf stamp at the top of the document followed by pdf content. I currently dont see any option for that. Currently when I apply a stamp it writes on top of the content of the pdf.

I dont want the stamp in the front or in the background of the content. I want stamp on top of the document followed by content.

Please help.

Dim textStamp As pdf.TextStamp = New pdf.TextStamp(text)

                textStamp.Background = False
                textStamp.VerticalAlignment = pdf.VerticalAlignment.Top
                textStamp.TextState.Font = FontRepository.FindFont("Arial")
                textStamp.TextState.FontSize = 8
                textStamp.TextState.FontStyle = FontStyles.Regular

                If doc.Pages.Count > 0 Then
                    For i As Integer = 1 To doc.Pages.Count
                        doc.Pages(i).AddStamp(textStamp)
                    Next
                End If

Below is my code.

Regards,
Mahesh

@mahi342,

Kindly send us your source PDF and the complete code. We will investigate your scenario in our environment and share our findings with you.

Any pdf can act as source pdf. I just want to add a stamp in the pdf on the top without overwriting the contents of pdf. May I know how to do it.

@mahi342,

In order to define the rectangular position of the text stamp, you can set XIndent and YIndent properties of the TextStamp class. Please try the following code:

C#

string dataDir = @"C:\Pdf\test719\";
// Open document
Document pdfDocument = new Document(dataDir + "EmptyPdf.pdf");
// Create text stamp
TextStamp textStamp = new TextStamp("Sample Stamp");
// Set whether stamp is background
textStamp.Background = true;
// Set origin
textStamp.XIndent = pdfDocument.Pages[1].Rect.URX * 0.84; // 84 percent of page width
textStamp.YIndent = pdfDocument.Pages[1].Rect.URY * 0.98; // 98 percent of page width
// Set text properties
textStamp.TextState.Font = FontRepository.FindFont("Arial");
textStamp.TextState.FontSize = 14.0F;
textStamp.TextState.FontStyle = FontStyles.Bold;
textStamp.TextState.FontStyle = FontStyles.Italic;
textStamp.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Aqua);
// Add stamp to particular page
pdfDocument.Pages[1].AddStamp(textStamp);
dataDir = dataDir + "AddTextStamp_out.pdf";
// Save output document
pdfDocument.Save(dataDir);

These are the input and output PDF documents: EmptyPdf.pdf (79.4 KB) and AddTextStamp_out.pdf (99.9 KB)