1

Abc PDFを使用してHTMLページからPDFを作成しましたが、問題は次のページにテーブルヘッダーを印刷したいのですが、テーブルデータが別のページに表示されている場合にのみ、別のページにヘッダーを表示しない場合は、誰もが考えていますAbcpdfを使用してこれを行う方法について。

4

1 に答える 1

2

あなたがする必要があるのは、上部にいくらかのスペースがあるページを作成することです。次に、ドキュメントがページを介して abc PDF ループに組み込まれたら、ヘッダーを追加します。

以下のコードは、ヘッダーを追加するために使用するものです。この場合のヘッダーには、上部に 3 ビットの画像と、テキストを含む 2 つのボックスがあります。

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;
}

次に、pdfファイルが作成されたら、呼び出すだけです

var theDoc = new Doc();

/// Your document creation stuff!!!
theDoc = AddHeader(theDoc, propertyDetails);
于 2011-12-05T18:56:35.463 に答える