|
export class AppComponent {
@ViewChild('grid', { static: true }) public grid: GridComponent;
public data: object[];
public pageOptions;
public toolbarOptions: ToolbarItems[];
pdfQueryCellInfo(args: any) {
if(args.value == "VINET") {
args.value = "阿斯蒂芬"; //Chinese character
}
}
ngOnInit(): void {
this.data = hierarchyOrderdata;
this.pageOptions = { pageSize: 6 };
this.toolbarOptions = ['PdfExport'];
}
toolbarClick(args): void {
if (args.item.properties.text == "PDF導出") { // 'Grid_pdfexport' -> Grid component id + _ + toolbar item name
const pdfExportProperties = {
theme: {
header: { font: new PdfTrueTypeFont(adventProFont, 12) },
caption: { font: new PdfTrueTypeFont(adventProFont, 10) },
record: { font: new PdfTrueTypeFont(adventProFont, 9) }
}
};
this.grid.pdfExport(pdfExportProperties);
}
}
}
|
|
//Base64 string of Font
let fontBase64 : string ; -- > base64String of TTF font
let Font : PdfFont = new PdfTrueTypeFont(fontBase64, 12, PdfFontStyle.Bold); |
|
import { PdfTrueTypeFont, PdfFontFamily, PdfFont, PdfFontStyle } from '@syncfusion/ej2-pdf-export';
@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.css'],
providers: [ToolbarService, EditService, PageService]
})
export class AppComponent {
@ViewChild('grid', { static: true }) public grid: GridComponent;
public data: object[];
public pageOptions;
public toolbarOptions: ToolbarItems[];
public font_bold: PdfFont = new PdfTrueTypeFont(
adventProFont,
12,
PdfFontStyle.Bold
);
pdfQueryCellInfo(args: any) {
if (args.value == "VINET") {
args.value = "船名";
args.cell.gridRow.pdfGrid.rows.getRow(0).cells.getCell(1).style.font = this.font_bold;
}
}
ngOnInit(): void {
this.data = hierarchyOrderdata;
this.pageOptions = { pageSize: 6 };
this.toolbarOptions = ['PdfExport'];
}
} |