Overload | Description |
---|---|
OwnerPrintDraw | Prints the specified page of the specified sheet to a specified graphics interface with the specified size. |
You can display a preview of the pages to print using this method. For more information about previewing a printing job, refer to Providing a Preview of the Printing.
The page parameter is one-based, not zero-based.
You can display a preview of the pages to print using this method. For more information about previewing a printing job, refer to Providing a Preview of the Printing.
The page parameter is one-based, not zero-based.
This example prints the specified page of the specified sheet to a user-supplied Graphics object and Rectangle.
For a larger sample, see the sample project in the sample OwnerPrint directory in your installation directory. (The default location is Program Files\FarPoint Technologies\Spread.WinForms.v4.0\v4.0.x.x\Samples\Examples\examplesXX\OwnerPrint where x.x is the version number, and XX is the language, either CS for C# or VB for Visual Basic .NET).
C# | Copy Code |
---|---|
private System.Drawing.Printing.PrintDocument pd; this.pd = new System.Drawing.Printing.PrintDocument(); this.pd.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.pd_PrintPage); private void pd_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs ev) { Rectangle rect = new Rectangle(ev.PageBounds.X, ev.PageBounds.Y, ev.PageBounds.Width/2, ev.PageBounds.Height/2); int cnt = fpSpread1.GetOwnerPrintPageCount(ev.Graphics, rect, 0); fpSpread1.OwnerPrintDraw(ev.Graphics, rect, 0, cnt); ev.Graphics.DrawString("End of Print Job", new Font("MS Sans Serif", 10), new SolidBrush(Color.Black), new Rectangle(ev.PageBounds.X, ev.PageBounds.Y + ev.PageBounds.Height/2, ev.PageBounds.Width/2, ev.PageBounds.Height/2)); ev.HasMorePages = false; } |
Visual Basic | Copy Code |
---|---|
Friend WithEvents pd As System.Drawing.Printing.PrintDocument Me.pd = New System.Drawing.Printing.PrintDocument() Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As System.Drawing.Printing.PrintPageEventArgs) Handles pd.PrintPage Dim rect As New Rectangle(ev.PageBounds.X, ev.PageBounds.Y, ev.PageBounds.Width / 2, ev.PageBounds.Height / 2) Dim cnt As Integer = FpSpread1.GetOwnerPrintPageCount(ev.Graphics, rect, 0) FpSpread1.OwnerPrintDraw(ev.Graphics, rect, 0, cnt) ev.Graphics.DrawString("End of Print Job", New Font("MS Sans Serif", 10), New SolidBrush(Color.Black), ev.PageBounds.X, ev.PageBounds.Y + ev.PageBounds.Height / 2) ev.HasMorePages = False End Sub |
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
Reference
FpSpread ClassFpSpread Members
User-Task Documentation
Providing a Preview of the PrintingPrinting an Area of the Sheet