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

Free Support Forum - aspose.com

PDF- Add 2 textstamps to center-bottom of page without them going on top of each other

Hello
I am trying to have two text stamps at the bottom of the page I want it look like this

Date: Today’s date
Confidential

I want the date at the bottom and I want ‘Confidential’ underneath. At the moment they both appear on top of each other. I have tinkered with margin properties etc but to no avail and I cant find a line break property.

    private static void SetupPages(Document pdfDocument)
    {
        pdfDocument.ProcessParagraphs();  

        SetPageDimensions(pdfDocument);
        foreach (var page in pdfDocument.Pages)
        {
            page.AddStamp(SetDateStamp());
            page.AddStamp(SetConfidentialStamp());
        }
    }

    private static TextStamp SetDateStamp()
    {
        var dateTextStamp = 
            new TextStamp($"Date: {SystemTime.UtcNow.ToString()}")
        {
            HorizontalAlignment = HorizontalAlignment.Center,
            VerticalAlignment = VerticalAlignment.Bottom
        };
        SetTextStampMarginAndColor(dateTextStamp);
        return dateTextStamp;
    }

    private static TextStamp SetConfidentialStamp()
    {
        var userTextStamp = new TextStamp("Confidential")
        {
            HorizontalAlignment = HorizontalAlignment.Center,
            VerticalAlignment = VerticalAlignment.Bottom,
            BottomMargin = 200
        };
        SetTextStampMarginAndColor(userTextStamp);
        return userTextStamp;
    }

@jegglestone

Thank you for contacting support.

You may try to set XIndent property instead of HorizontalAlignment property and set suitable BottomMargin in order to fix indentation difference. Below code snippet generates attached PDF document. TwoStamps.pdf

private static TextStamp SetDateStamp(Page page)
{
    var dateTextStamp =
        new TextStamp($"Date: {DateTime.UtcNow.ToString()}")
        {
            //HorizontalAlignment = HorizontalAlignment.Center,
            VerticalAlignment = VerticalAlignment.Bottom,
            XIndent = page.PageInfo.Width/2 - 50,
            BottomMargin = 10
        };
    //SetTextStampMarginAndColor(dateTextStamp);
    return dateTextStamp;
}

private static TextStamp SetConfidentialStamp(Page page)
{
    var userTextStamp = new TextStamp("Confidential")
    {
        //HorizontalAlignment = HorizontalAlignment.Center,
        VerticalAlignment = VerticalAlignment.Bottom,
        XIndent = page.PageInfo.Width / 2 - 50,
    };
    //SetTextStampMarginAndColor(userTextStamp);
    return userTextStamp;
}

We hope this will be helpful. Please feel free to contact us if you need any further assistance.

Thank you - this has solved my problem