Table Printing

To print the table, the ITabSheetPrinter interface is used.

The example displays setting up page parameters and printing parameters for a regular report with the REPORT_TAB identifier.

As a result of executing the example, the first page of the report will be printed.

Fore Example

To execute the example, add links to the Drawing, Metabase, Report, Tab system assemblies.

Sub TablePrint;
Var
    mb: IMetabase;
    Report: IPrxReport;
    Table: ITabSheet;
    SheetPrinter: ITabSheetPrinter;
    PageSettings: ITabPageSettings;
    pCount: Integer;
    Image: IGxImage;
    Graph: IGxGraphics;
    Rect: IGxRect;
    Color: IGxColor;
    Printer: IGxDocumentPrinter;
Begin
    // Get current repository
    mb := MetabaseClass.Active;
    // Get regular report
    Report := mb.ItemById("REPORT_TAB").Bind As IPrxReport;
    // Get table
    Table := (Report.ActiveSheet As IPrxTable).TabSheet;
    // Get print parameters
    SheetPrinter := Table.CreatePrinter;
    // Set indents for the first page
    SheetPrinter.FirstPageHeaderGap := 20;
    SheetPrinter.FirstPageFooterGap := 20;
    SheetPrinter.DifferentFirstPageGap := True;
    // Set indents for even pages
    SheetPrinter.EvenHeaderGap := 10;
    SheetPrinter.EvenFooterGap := 10;
    SheetPrinter.DifferentEvenPageGap := True;
    // Get page parameters
    PageSettings := SheetPrinter.PageSettings;
    // Determine that it is table with formatting which is printed
    PageSettings.BlackAndWhite := False;
    // Determine that the A4 format is used
    PageSettings.PaperFormat := GxPaperFormat.A4;
    // Align the table horizontally
    PageSettings.CenterHorizontal := True;
    // Output the table for printing
    pCount := SheetPrinter.GetPageCount;
    If pCount > 0 Then
        Image := GxBitmap.CreateNew(10001000, GxPixelFormat.Format64bppArgb);
        Graph := GxGraphicsClass.FromImage(Image);
        Rect := New GxRect.Create(0110001000);
        Color := New GxColor.CreateRGB(255255255);
        Graph.FillColorRectangle(Color, Rect);
        SheetPrinter.PrintPage(1, Graph);
        Printer := GxPrinters.DefaultPrinter As IGxDocumentPrinter;
        Printer.StartDocument("Table");
        Printer.NewPage;
        Printer.Graphics.DrawImageTransparent(Image, NullNullNull);
        Printer.EndDocument;
    End If;
End Sub TablePrint;

Fore.NET Example

Imports Prognoz.Platform.Interop.Drawing;
Imports Prognoz.Platform.Interop.Report;
Imports Prognoz.Platform.Interop.Tab;

Public Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    Report: IPrxReport;
    Table: ITabSheet;
    SheetPrinter: ITabSheetPrinter;
    PageSettings: ITabPageSettings;
    pCount: Integer;
    Image: GxImage;
    Graph: GxGraphics;
    Rect: GxRectClass;
    Color: GxColorClass_2;
    Printer: IGxDocumentPrinter;
    Bitmap: GxBitmapClassClass;
    GraphicsClass: GxGraphicsClassClass;
    Printers: GxPrintersClassClass;
Begin
    // Get current repository
    mb := Params.Metabase;
    // Get regular report
    Report := mb.ItemById["REPORT_TAB"].Edit() As IPrxReport;
    // Get table
    Table := (Report.ActiveSheet As IPrxTable).TabSheet;
    // Get print parameters
    SheetPrinter := Table.CreatePrinter();
    // Set indents for the first page
    SheetPrinter.FirstPageHeaderGap := 20;
    SheetPrinter.FirstPageFooterGap := 20;
    SheetPrinter.DifferentFirstPageGap := True;
    // Set indents for even pages
    SheetPrinter.EvenHeaderGap := 10;
    SheetPrinter.EvenFooterGap := 10;
    SheetPrinter.DifferentEvenPageGap := True;
    // Get page parameters
    PageSettings := SheetPrinter.PageSettings;
    // Determine that it is table with formatting which is printed
    PageSettings.BlackAndWhite := False;
    // Determine that the A4 format is used
    PageSettings.PaperFormat := GxPaperFormat.pfA4;
    // Align the table horizontally
    PageSettings.CenterHorizontal := True;
    // Output the table for printing
    pCount := SheetPrinter.GetPageCount();
    If pCount > 0 Then
        Bitmap := New GxBitmapClassClass.Create();
        Image := Bitmap.CreateNew(10001000, GxPixelFormat.pifFormat64bppArgb);
        GraphicsClass := New GxGraphicsClassClass.Create();
        Graph := GraphicsClass.FromImage(Image);
        Rect := New GxRectClass.Create();
        Rect.Create(0110001000);
        Color := New GxColorClass_2.Create();
        Color.CreateRGB(255255255);
        Graph.FillColorRectangle(Color, Rect);
        SheetPrinter.PrintPage(1, Graph);
        Printers := New GxPrintersClassClass.Create();
        Printer := Printers.DefaultPrinter As IGxDocumentPrinter;
        Printer.StartDocument("Table");
        Printer.NewPage();
        Printer.Graphics.DrawImageTransparent(Image, NullNullNull);
        Printer.EndDocument();
    End If;
End Sub;

See also:

General Programming Principles Using the Tab Assembly