Increasing the margin between the Header and the Document body

Hello,

I am trying to increase the margin between a header and a document body.

I have included an image of the issue in the file “pic1.png”.
As you see there is the header with two strings (multiline). Is there any way to increase the distance between the body the header?

issue.zip (444.2 KB)

 var document = new Document("original.pdf");

        var imageStamp = new ImageStamp("barcode.png");
        // Set properties of the stamp
        imageStamp.TopMargin = 10;
        imageStamp.HorizontalAlignment = HorizontalAlignment.Right;
        imageStamp.VerticalAlignment = VerticalAlignment.Top;
        imageStamp.TopMargin = 55;
        imageStamp.RightMargin = 20;
        imageStamp.Width = 15;
        imageStamp.Height = 200;


        var formatterText = new FormattedText("string1", new FontColor(0, 0, 0), FontStyle.HelveticaBold, EncodingType.Cp1250, true, 7);
        formatterText.AddNewLineText("string2");

        var textStamp2 = new TextStamp(formatterText);
        textStamp2.RightMargin = 55;
        textStamp2.TopMargin = 20;
        var font = FontRepository.FindFont("Georgia");
        textStamp2.TextState.Font = font;
        textStamp2.HorizontalAlignment = HorizontalAlignment.Right;
        textStamp2.VerticalAlignment = VerticalAlignment.Top;
        textStamp2.TextAlignment = HorizontalAlignment.Right;

        var isFirst = true;

        //Add the distance to alle pages except the first one
        foreach (var page in document.Pages)
        {
            if (isFirst)
            {
                // Add the image only
                isFirst = false;
                page.AddStamp(imageStamp);
            }
            else
            {
                // add both image and header
                imageStamp.TopMargin = 22;
                page.AddStamp(imageStamp);

                textStamp2.BottomMargin = 100;
                page.AddStamp(textStamp2);
            }
        }
        document.Save("result.pdf");

As you see, I am setting the bootmargin for textStamp2 on 100 for testing. Yet it doesn’t matter what value do I pick. Nothing changes.

Thank you

@mhabibal

Thank you for contacting support.

You are adding image and text stamps on an existing PDF which will not change position of existing text. However, you may Resize Page Contents first and then add the stamps as per your requirements.

1 Like