• <menu id="w2i4a"></menu>
  • logo Stimulsoft Reports.WinForms教程-2019

    文檔首頁>>Stimulsoft Reports.WinForms教程-2019>>【Stimulsoft Reports.WinForms教程】使用報表頁面畫布獲取版權(quán)

    【Stimulsoft Reports.WinForms教程】使用報表頁面畫布獲取版權(quán)


    【下載Stimulsoft Reports.Ultimate最新版本】

    此示例顯示如何在報表頁面上放置水印,頁面上的水印可以是文本,表達(dá)的結(jié)果或圖像。水印也可以放在頁面的任何位置。在此示例中,我們將添加文本水印。為此,我們使用報表的繪圖頁面事件:

    static void Main() 
    {
        StiPage.PagePainting += new StiPagePaintEventHandler(OnPagePainting);
        StiPage.PagePainted += new StiPagePaintEventHandler(OnPagePainted);
     
        Application.EnableVisualStyles();
        Application.Run(new Form1());
    }
     
    private static void OnPagePainting(StiPage sender, StiPagePaintEventArgs e)
    {
        if (copyrightPosition == Position.Behind)
        {
            StiPage page = sender as StiPage;
            DrawCopyright(page, e);
        }
    }
     
    private static void OnPagePainted(StiPage sender, StiPagePaintEventArgs e)
    {
        if (copyrightPosition == Position.Front)
        {
            StiPage page = sender as StiPage;
            DrawCopyright(page, e);
        }
    }

    渲染水印的方法如下:

    private static void DrawCopyright(StiPage page, StiPagePaintEventArgs e)
    {
        if (e.IsPrinting && (!printer))return;
        if (e.IsDesigning && (!designer))return;
        if ((!e.IsDesigning) && (!e.IsPrinting) && (!preview))return;
     
        Rectangle rect = e.FullRectangle;
        if (rectClient)rect = e.ClientRectangle;
     
        using (Font font = new Font("Arial", 20 * (float)page.Zoom))
        using (StringFormat sf = new StringFormat())
        {
            switch (copyrightPlace)
            {
                case Place.TopLeft:
                    sf.Alignment = StringAlignment.Near;
                    sf.LineAlignment = StringAlignment.Near;
                    break;
     
                case Place.TopRight:
                    sf.Alignment = StringAlignment.Far;
                    sf.LineAlignment = StringAlignment.Near;
                    break;
     
                case Place.Center:
                    sf.Alignment = StringAlignment.Center;
                    sf.LineAlignment = StringAlignment.Center;
                    break;
     
                case Place.BottomLeft:
                    sf.Alignment = StringAlignment.Near;
                    sf.LineAlignment = StringAlignment.Far;
                    break;
     
                case Place.BottomRight:
                    sf.Alignment = StringAlignment.Far;
                    sf.LineAlignment = StringAlignment.Far;
                    break;
            }
     
            e.Graphics.DrawString(copyrightString, font, Brushes.Red, rect, sf);
        }
    }
    

    示例代碼的結(jié)果如下圖所示:

    Stimulsoft

    下載示例

    掃碼咨詢


    添加微信 立即咨詢

    電話咨詢

    客服熱線
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();