1

printdocument があり、それを使用して最初のページ (タイトルまたはカバー ページ) を印刷したいと考えています。それから、次のページの他のすべて。

printDocument コントロールを正常に作成し、その printpage イベントをメソッドにリンクすることができました。

印刷します。ただし、実際には、印刷物の表紙を印刷したいと考えています。私は自分のコードを見つめ続けていますが、すべてに適合する 1 つのソリューションを思いつくことができません。

私は、タイトルページのためだけに別のprintDocumentを持ち、それ以外のすべてのために別のprintDocumentを独自のprintPageイベントで持つか、タイトルページとその他すべてのprintpageイベント内にif elseブロックを持たせる必要があります。

それで、あなたはそれをどのようにしますか?例をいただければ幸いです。

ありがとう、

4

1 に答える 1

2

私の頭の上から:

// set to false before calling PrintDocument.Print()
bool firstPagePrinted = false;
private void printdocument_PrintPage(object sender, PringPageEventArgs e)
{
  if(!firstPagePrinted)
  {
    // TODO: whatever you want
    e.Graphics.DrawString("Header page", printFont, 
      Brushes.Black, e.MarginBounds.left, e.MarginBounds.Top, new StringFormat();
    firstPagePrinted = true;
    e.HasMorePage = true;
  }
  // do 2nd and subsequent pages here...
}
于 2012-07-19T00:36:29.273 に答える