0
私はpdfを作成するのにionicframeworkのpdf makeプラグインを使用していますが、pdfを作成してダウンロードするとうまくいきますが、動的なページを追加すると、 pdf makeを使ってページ区切りを自動で行う方法。私は試してみました。ionic pdfmakeでダイナミックページ区切りを作成するには
しかし、それはページを破壊しません。
コード:
var dd = {
pageSize: 'A4',
pageOrientation: 'portrait',
content: [
{ text: $translate.instant('{{"billnumber_message" | translate}}') + invoice.billno, alignment: 'left', style: 'subheader'},
{ text: $translate.instant('{{"billdate_message" | translate}}') + currentbilldate, alignment: 'right', style: 'subheader'},
{ text: $translate.instant('{{"billto_message" | translate}}') + invoice.name + ',\n' + invoice.location + ',\n' + invoice.mobileno + '\n', style: 'subheader' },
{
style: 'itemsTable',
table: {
widths: ['*', '*', '*', '*'],
body: [
[
{ text: $translate.instant('{{"billDescription_message" | translate}}'), style: 'itemsTableHeader' },
{ text: $translate.instant('{{"billquantity_message" | translate}}'), style: 'itemsTableHeader' },
{ text: $translate.instant('{{"billrate_message" | translate}}'), style: 'itemsTableHeader' },
{ text: $translate.instant('{{"billtotal_message" | translate}}'), style: 'itemsTableHeader' },
]
].concat(items)
}
},
{
style: 'totalsTable',
table: {
widths: [75, '*', 75],
body: [
[
'',
$translate.instant('{{"billtotalamount_message" | translate}}'),
invoice.Subtotal,
],
[
'',
$translate.instant('{{"billothercharges_message" | translate}}'),
invoice.OtherCharges,
],
[
'',
$translate.instant('{{"billdebitcapture_message" | translate}}'),
invoice.debitcapure,
],
[
'',
'',
'',
],
[
'',
'',
'',
]
]
},
layout: 'noBorders'
},
{
style: 'subheaderbalance',
table: {
widths: [75, '*', 75],
body: [
[
'',
$translate.instant('{{"billamountgiven_message" | translate}}'),
invoice.Total,
]
]
},
layout: 'noBorders'
},
{ text: '', alignment: 'right'},
{ text: '', alignment: 'right'},
{ text: '', alignment: 'right'},
{ text: $translate.instant('{{"billhistory_message" | translate}}') + invoice.Previousbill, alignment: 'center' },
{ text: '', alignment: 'right'},
{ text: '', alignment: 'right'},
{ text: '', alignment: 'right'},
/*{ text: $translate.instant('{{"billpreviousdebit_message" | translate}}') + invoice.PreviousDebitCapture, alignment: 'right' },*/
{
style: 'itemsTable',
table: {
widths: [75, '*', 75],
body: [
[
{ text: $translate.instant('{{"billdate_message" | translate}}'), style: 'itemsTableHeader' },
{ text: $translate.instant('{{"description_message" | translate}}'), style: 'itemsTableHeader' },
{ text: $translate.instant('{{"amount_message" | translate}}'), style: 'itemsTableHeader' },
]
].concat(previousbillitems)
},
},
{
style: 'totalsTable',
table: {
widths: [75, '*', 75],
body: [
[
'',
$translate.instant('{{"billpreviousdebit_message" | translate}}'),
invoice.PreviousDebitCapture,
],
[
'',
$translate.instant('{{"billtotaldebit_message" | translate}}'),
totaldebit,
],
[
'',
$translate.instant('{{"billtotaldebitcapture_message" | translate}}'),
invoice.debitcapure,
]
]
},
layout: 'noBorders'
},
{
style: 'subheaderbalance',
table: {
widths: [75, '*', 75],
body: [
[
':',
$translate.instant('{{"billledgerbalance" | translate}}'),
(totaldebit - invoice.debitcapure),
]
]
},
layout: 'noBorders'
},
//{ text: $translate.instant('{{"billtotaldebit_message" | translate}}') + totaldebit , alignment: 'right' },
//{ text: $translate.instant('{{"billtotaldebitcapture_message" | translate}}') + invoice.debitcapure, alignment: 'right'},
//{ text: '', alignment: 'left'},
//{ text: $translate.instant('{{"billledgerbalance" | translate}}') + (totaldebit - invoice.debitcapure), alignment: 'right', style: 'subheader'},
// add signature
{ text: '', alignment: 'right'},
{ text: '', alignment: 'right'},
{ text: '', alignment: 'right'},
{ text: '', alignment: 'right'},
{ text: '', alignment: 'right'},
{ text: '', alignment: 'right'},
{ text: $translate.instant('{{"billsignature_message" | translate}}'), alignment: 'right', style: 'subheader'},
{ text: '', alignment: 'right'},
],
pageBreakBefore: function (currentNode, followingNodesOnPage) {
return currentNode.headlineLevel === 1 && followingNodesOnPage.length === 0;
},
styles: {
subheader: {
fontSize: 16,
bold: true,
margin: [0, 20, 0, 5]
},
subheaderbalance: {
fontSize: 16,
bold: true,
alignment: 'right',
margin: [0, 20, 0, 5]
},
itemsTable: {
alignment: 'center',
margin: [0, 5, 0, 15]
},
itemsTableHeader: {
bold: true,
fontSize: 13,
color: 'black',
alignment: 'center'
},
itemsTableAmount: {
bold: true,
fontSize: 13,
color: 'black',
alignment: 'right'
},
totalsTable: {
bold: true,
alignment: 'right',
margin: [0, 30, 0, 0]
},
},
defaultStyle: {
//font: 'TSCu_SaiIndira'
}
};
私はそれを試してみましょう。 –
正常に動作しています。 –