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.

Example

Executing the example requires to 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;

See also:

General Programming Principles Using the Tab Assembly