Pdf generation 使用Abc PDF在设置页面上打印页眉

Pdf generation 使用Abc PDF在设置页面上打印页眉,pdf-generation,abcpdf,Pdf Generation,Abcpdf,我已经用Abc pdf从HTML页面创建了pdf,现在我的问题是我想在下一页打印一个表格标题,但只有当表格数据显示在另一页中时,如果不在另一页上显示标题,任何人都知道如何使用Abc pdf来实现这一点。您需要做的是在顶部创建一个有一定空间的页面,然后,在abc PDF中构建文档后,循环浏览页面并添加页眉 var theDoc = new Doc(); /// Your document creation stuff!!! theDoc = AddHeader(theDoc, propertyD

我已经用Abc pdf从HTML页面创建了pdf,现在我的问题是我想在下一页打印一个表格标题,但只有当表格数据显示在另一页中时,如果不在另一页上显示标题,任何人都知道如何使用Abc pdf来实现这一点。

您需要做的是在顶部创建一个有一定空间的页面,然后,在abc PDF中构建文档后,循环浏览页面并添加页眉

var theDoc = new Doc();

/// Your document creation stuff!!!
theDoc = AddHeader(theDoc, propertyDetails);
下面的代码是我用来添加标题的代码,在本例中,标题有三位,顶部有一个图像,两个文本框

var theDoc = new Doc();

/// Your document creation stuff!!!
theDoc = AddHeader(theDoc, propertyDetails);
请记住,abc pdf中的跳线是从右下角开始的,而不是从左上角开始的

private static Doc AddHeader(Doc theDoc, Core.Property propertyDetails)
{
    int theCount = theDoc.PageCount;
    int i = 0;

    //Image header 
    for (i = 1; i <= theCount; i++)
    {
        theDoc.Rect.Width = 590;
        theDoc.Rect.Height = 140;

        theDoc.Rect.Position(0, 712);

        theDoc.PageNumber = i;

        //Check Which office to use. 
        string imagefilePath = HttpContext.Current.Server.MapPath("/images/pdf/pdf-header.png");


        Bitmap myBmp = (Bitmap)Bitmap.FromFile(imagefilePath);

        theDoc.AddImage(myBmp);
    }

    //page header boxes. 
    //Grey header box 
    theDoc.Rect.String = "20 15 590 50";
    theDoc.Rect.Position(13, 672);
    System.Drawing.Color colour = System.Drawing.ColorTranslator.FromHtml("#CCCCCC");
    theDoc.Color.Color = colour;
    theDoc.PageNumber = 1;
    theDoc.FillRect();

    theDoc.Rect.String = "20 15 586 50";
    theDoc.Rect.Position(30, 660);
    System.Drawing.Color pageoneText = System.Drawing.ColorTranslator.FromHtml("#50474A");
    theDoc.Color.Color = pageoneText;
    string thePageFont = "Century Gothic";
    theDoc.Font = theDoc.AddFont(thePageFont);
    theDoc.FontSize = 16;
    theDoc.PageNumber = 1;
    theDoc.AddText("My Text!!!!!");


    theDoc.Rect.String = "20 15 590 50";
    theDoc.Rect.Position(13, 630);
    System.Drawing.Color greyBox = System.Drawing.ColorTranslator.FromHtml("#468DCB");
    theDoc.Color.Color = greyBox;
    theDoc.PageNumber = 1;
    theDoc.FillRect();

    theDoc.Rect.String = "20 15 586 50";
    theDoc.Rect.Position(30, 620);
    System.Drawing.Color greyText = System.Drawing.ColorTranslator.FromHtml("#ffffff");
    theDoc.Color.Color = greyText;
    string thePageFontTwo = "Century Gothic";
    theDoc.Font = theDoc.AddFont(thePageFontTwo);
    theDoc.FontSize = 14;
    theDoc.PageNumber = 1;
    theDoc.AddText("This is more text");

    return theDoc;
}
var theDoc = new Doc();

/// Your document creation stuff!!!
theDoc = AddHeader(theDoc, propertyDetails);