Search code examples
c#headerfooterabcpdf

abcpdf content front of header and footer


I am trying to create an structure using abcpdf that suppose to be like this:

header content footer

P.S: content needs to be "front of" header and footer

In other words, I need to have my content starting from y = 0 to y = 100%; My header starting from y = 0 to y = 200; My footer starting from y = 700 to y = 100%. (Values here are just samples)

I hope I am being clear.

At the moment I have those methods:

private void CreateDocHeader(Doc theDoc, int theCount, string content)
    {
        theDoc.Rect.String = "0 660 600 825";
        theDoc.MediaBox.String = theDoc.Rect.String;
        for (int i = 1; i <= theCount; i++)
        {
            theDoc.PageNumber = i;
            theDoc.AddImageHtml(content);
        }
    }

    private void CreateDocFooter(Doc theDoc, int theCount, string content)
    {
        theDoc.Rect.String = "0 200 600 10";
        theDoc.MediaBox.String = theDoc.Rect.String;
        for (int i = 1; i <= theCount; i++)
        {
            theDoc.PageNumber = i;
            theDoc.AddImageHtml(content);
        }
    }

    private void CreateDocContent(Doc theDoc, int theID, string theContent, ref int theCount)
    {
        theDoc.Rect.String = "0 800 600 10";
        theDoc.MediaBox.String = theDoc.Rect.String;
        theID = theDoc.AddImageHtml(theContent);
        while (theDoc.Chainable(theID))
        {
            theDoc.Page = theDoc.AddPage();
            theID = theDoc.AddImageToChain(theID);
        }
        theCount = theDoc.PageCount;
    }

Anyone?


Solution

  • Use Hpos and Vpos properties to do that :-

    For header, do this:

    theDoc.HPos = 0.5;
    theDoc.VPos = 1.0;
    

    this will keep your header in left alignment.

    For footer, do this:

    theDoc.HPos = 1.0;
    theDoc.VPos = 0.5;
    

    this will keep your footer in right alignment.

    Hope this helps.

    Addition:

    For having the Z position, that is have the different tiers for the header/footer and content, use the Layer property. This property alongwith the LayerCount property, you can have the solution.

    For more reference go through this documentation:-

    http://www.websupergoo.com/helppdfnet/source/5-abcpdf/doc/2-properties/layer.htm http://www.websupergoo.com/helppdfnet/source/5-abcpdf/doc/2-properties/layercount.htm