FlexGridコントロールをPDFにエクスポートするには、ユーザーアプリケーションに次の2つの追加モジュールをインクルードする必要があります。
FlexGridをPDFにエクスポートするには、FlexGridPdfConverter.exportメソッドを呼び出し、エクスポートするグリッドへの参照とファイル名に加えて、ページ書式、ヘッダー、フッター、スタイルなどを定義するオプションを提供します。
import * as grid from '@mescius/wijmo.grid';
import * as pdf from '@mescius/wijmo.pdf';
import * as gridPdf from '@mescius/wijmo.grid.pdf';
gridPdf.FlexGridPdfConverter.export(theGrid, 'Wijmo.pdf', {
maxPages: 10,
scaleMode: gridPdf.ScaleMode.PageWidth,
documentOptions: {
compress: true,
header: { declarative: { text: '\t&[Page] / &[Pages]' } },
footer: { declarative: { text: '\t&[Page] / &[Pages]' } },
info: { author: 'GrapeCity', title: 'Wijmo PDF' }
},
styles: {
cellStyle: { backgroundColor: '#ffffff', borderColor: '#c6c6c6' },
altCellStyle: { backgroundColor: '#f9f9f9' },
groupCellStyle: { backgroundColor: '#dddddd' },
headerCellStyle: { backgroundColor: '#eaeaea' }
}
});
また、PDFを手動で作成し、エクスポートされるグリッドやその他の必要な情報を追加することもできます。この機能は、グリッドのデータを含むカスタムレポートやドキュメントを生成する際に便利です。
// ドキュメントを作成します
var doc = new pdf.PdfDocument({
compress: true,
header: { declarative: { text: '\t&[Page] / &[Pages]' } },
ended: function (sender, args) {
wijmo.pdf.saveBlob(args.blob, 'WijmoDoc.pdf');
}
});
// コンテンツを追加します
doc.drawText('これはFlexGridコントロールです。');
// グリッドを追加します(400pt幅)
gridPdf.FlexGridPdfConverter.draw(theGrid, doc, 400);
// ドキュメントを完了します
doc.end();