ComponentOne ASP.NET MVC Controls
In This Topic
    FlexGridPdfConverter Class
    In This Topic
    File
    wijmo.grid.pdf.js
    Module
    wijmo.grid.pdf

    Provides a functionality to export the FlexGrid to PDF.

    The example below shows how you can use a FlexGridPdfConverter to export a FlexGrid to PDF:

    {@sample Grid/ImportExportPrint/PDF/ExportToFile/purejs Example}

    Methods

    Static draw

    draw(flex: any, doc: PdfDocument, width?: number, height?: number, settings?: IFlexGridDrawSettings): void
    

    Draws the FlexGrid to an existing PdfDocument at the (0, @wijmo.pdf.PdfDocument.y) coordinates.

    If width is not specified, then grid will be rendered in actual size, breaking into pages as needed. If height is not specified, then grid will be scaled to fit the width, breaking into pages vertically as needed. If both, width and height are determined, then grid will be scaled to fit the specified rectangle without any page breaks.

    var doc = new wijmo.pdf.PdfDocument({
       ended: function (sender, args) {
          wijmo.pdf.saveBlob(args.blob, 'FlexGrid.pdf');
       }
    });
    
    wijmo.grid.pdf.FlexGridPdfConverter.draw(grid, doc, null, null, {
       maxPages: 10,
       styles: {
          cellStyle: {
             backgroundColor: '#ffffff',
             borderColor: '#c6c6c6'
          },
          headerCellStyle: {
             backgroundColor: '#eaeaea'
          }
       }
    });
    
    Parameters
    • flex: any

      The FlexGrid instance to export.

    • doc: wijmo.pdf.PdfDocument

      The PdfDocument instance to draw in.

    • width: number Optional

      The width of the drawing area in points.

    • height: number Optional

      The height of the drawing area in points.

    • settings: IFlexGridDrawSettings Optional

      The draw settings.

    Returns
    void

    Static drawToPosition

    drawToPosition(flex: any, doc: wijmo.pdf.PdfDocument, point: Point, width?: number, height?: number, settings?: IFlexGridDrawSettings): void
    

    Draws the FlexGrid to an existing PdfDocument instance at the specified coordinates.

    If width is not specified, then grid will be rendered in actual size without any page breaks. If height is not specified, then grid will be scaled to fit the width without any page breaks. If both, width and height are determined, then grid will be scaled to fit the specified rectangle without any page breaks.

    var doc = new wijmo.pdf.PdfDocument({
       ended: function (sender, args) {
          wijmo.pdf.saveBlob(args.blob, 'FlexGrid.pdf');
       }
    });
    
    wijmo.grid.pdf.FlexGridPdfConverter.drawToPosition(grid, doc, new wijmo.Point(0, 0), null, null, {
       maxPages: 10,
       styles: {
          cellStyle: {
             backgroundColor: '#ffffff',
             borderColor: '#c6c6c6'
          },
          headerCellStyle: {
             backgroundColor: '#eaeaea'
          }
       }
    });
    
    Parameters
    • flex: any

      The FlexGrid instance to export.

    • doc: wijmo.pdf.PdfDocument

      The PdfDocument instance to draw in.

    • point: Point

      The position to draw at, in points.

    • width: number Optional

      The width of the drawing area in points.

    • height: number Optional

      The height of the drawing area in points.

    • settings: IFlexGridDrawSettings Optional

      The draw settings.

    Returns
    void

    Static export

    export(flex: FlexGrid, fileName: string, settings?: IFlexGridExportSettings): void
    

    Exports the FlexGrid to PDF.

    wijmo.grid.pdf.FlexGridPdfConverter.export(grid, 'FlexGrid.pdf', {
       scaleMode: wijmo.grid.pdf.ScaleMode.PageWidth,
       maxPages: 10,
       styles: {
          cellStyle: {
             backgroundColor: '#ffffff',
             borderColor: '#c6c6c6'
          },
          headerCellStyle: {
             backgroundColor: '#eaeaea'
          }
       },
       documentOptions: {
          info: {
             title: 'Sample'
          }
       }
    });
    
    Parameters
    Returns
    void