首页 > 解决方案 > 更新打字稿角度中单独行中的位置表字段以导出pdf

问题描述

我正在尝试以角度创建一个pdf文件。一切正常,我只是在某一点上卡住了。下表中是 order.orderItems.map 对象的值。价值观是应该的。我只想将我用黄色绘制的字段作为当前值上方的一条线。它应该像第二张图片它是可能的,但我不能这样做。我的代码如下;

async generatePDF(action = 'download', id: number) {
    this.currentUser$ = this.accountService.currentUser$;
    var order = this.orders.find(o => o.id === id);
    this.currentUser$.pipe(take(1)).subscribe(
      value => this.user = value);
    let docDefinition = {
      content: [
        {
          text: '',
          style: 'sectionHeader'
        },
        {
          columns: [
            [
              {
                text: `Order Date: ${new Date(order.orderDate).toLocaleString()}`,
                alignment: 'right'
              },
              {
                text: `Order No : "${((order.id).toFixed(0))}"`,
                alignment: 'right'
              }
            ]
          ]
        },
        {
          text: '',
          style: 'sectionHeader'
        },
        {
          text: 'Sayın' + ' ' + this.user.displayName + ' ,\n\n' +
            ' here is some text \n\n' +
            'here is some text,\n' +
            'here is some text'
          ,
          margin: [0, 0, 0, 15]
        },
        {
          text: 'Vehicle List',
          style: 'sectionHeader',
        },
        {
          table: {

            headerRows: 1,
            widths: ['auto', 'auto', 'auto', 'auto', 'auto', 'auto', 'auto', 'auto', 'auto'],
            body: [

              [
                '',
                'Status',
                'Time',
                'Km',
                'Rent Cost',
                'Over Km Cost',
                'Gear Type',
                'Fuel Type',
                'Quantity',
              ],
              ...order.orderItems.map(p => {
                return [
                  [p.productName + ' ' + p.productModel + ' ' + p.productVersion + ' ' + p.productModelYear],
                  (p.vehicleKm) ? (p.productType + ' ' + "(" + p.vehicleKm + " KM)") : p.productType,
                  p.rentMonth,
                  p.rentKm,
                  (p.additionalProfit * p.quantity).toFixed(2) + 'TL',
                  p.overKmPrice,
                  p.productGearType,
                  p.productFuelType,
                  p.quantity
                ]
              })
            ]
          }
        }

在此处输入图像描述

在此处输入图像描述

标签: javascriptangulartypescriptpdfmake

解决方案


推荐阅读