是否可以将jsPDF和Autotable插件结合使用?

时间:2019-06-13 19:08:23

标签: jspdf

是否可以使用jsPDF从HTML页面中获取文本,并使用jsPDF-autotable来获取表格并将其全部保存在一个PDF中?我有一个包含一些内容的文档,内容中间是表格。但是,我无法打印该文档。

示例代码: 示例代码:enter code here

在下面的代码中,我循环了我的Content数组。内容可以是不同的类型。对于表格内容,我尝试使用pdf.autoTable;对于文字内容,我尝试使用pdf.text

   var pdf = new jspdf('p', 'pt', 'a4');
     pdf.setFontSize(18);
    pdf.line(20, 25, 25, 25);

  for (let i = 0; i < this.dalSectionsArray.length; i++) {
  dynamicHtmlSource = dynamicHtmlSource + '<p style="text-align:left;"> 
      <b>' + this.dalSectionsArray[i].title + '</b></p><b/>';
    pdf.text(dynamicHtmlSource, 10+i, 10+i);
    for (let j = 0; j < this.dalContentsArray.length; j++) {
    if (this.dalSectionsArray[i].id === 
      this.dalContentsArray[j].sectionView.id) {
      if (this.dalContentsArray[j].subType === 'Clause') {
        dynamicHtmlSource = this.getClauseData(this.dalContentsArray[j]);
        pdf.text(dynamicHtmlSource,20+j,20+j);
      } else if (this.dalContentsArray[j].subType === 'Block') {
        dynamicHtmlSource = this.getBlockData(this.dalContentsArray[j]);
        pdf.text(dynamicHtmlSource,30+j,30+j);
      } else if (this.dalContentsArray[j].subType === 'Restriction') {
        dynamicHtmlSource = 
       this.getRestrictionData(this.dalContentsArray[j]);
        pdf.text(dynamicHtmlSource, 40+j, 40+j);
      } else if (this.dalContentsArray[j].subType === 'Table') {
        pdf.autoTable({
          startY:50+j,
          columnStyles: { europe: { halign: 'center' } }, // European 
       countries centered
          body: this.dalContentsArray[j].tableValues,
          columns: this.dalContentsArray[j].displayColumns
        })

      }
      } 

   pdf.fromHTML('',
   this.margins.left, // x coord
   this.margins.top,
   {
    // y coord
    width: this.margins.width// max width of content on PDF
    }, (dispose) => {
    this.headerFooterFormatting(pdf, pdf.internal.getNumberOfPages());
   },
   this.margins);

  var iframe = document.createElement('iframe');
  iframe.setAttribute('style', 'position:absolute;right:0; top:0; 
  bottom:0; height:100%; width:650px; padding:20px;');
   document.body.appendChild(iframe);

   pdf.setProperties({
   title: 'jspdf-iframe',
   subject: 'DAL Content',
   author: 'PDFAuthor',
   keywords: 'generated, javascript, web 2.0, ajax',
   creator: 'ABC'
   });
  iframe.src = pdf.output('datauristring');

 Issue is the pdf is completely messed and not printed properly.  Can any 
 one help me in this regard.

示例JSON:

   {
  "dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
  "sections": [
    {
      "title": "ABC",
      "description": "",
      "order": "1",
      "status": "Active",
      "startDate": "2018-12-12T00:00:00",
      "endDate": null,
      "id": "{b3cdda34-1fd2-4463-9aa0-24beff4b83fe}-{1}",
      "_etag": "\"0d0006a2-0000-0c00-0000-5c94e5760000\"",
      "partitionKey": "GGG-Section-{b3cdda34-1fd2-4463-9aa0-24beff4b83fe}-{1}",
      "type": "Section",
      "clientId": "GGG",
      "createdBy": "FFFFF",
      "createdDate": "2018-11-12T00:00:00",
      "modifiedBy": "FFFFF",
      "modifiedDate": "2018-11-12T00:00:00",
      "isactive": false
    },
    {
      "title": "DEF",
      "description": "",
      "order": "2",
      "status": "Active",
      "startDate": "2018-12-12T00:00:00",
      "endDate": null,
      "id": "{fca09906-dff9-40b2-a971-28fef7f37dbf}-{1}",
      "_etag": "\"0d0004a2-0000-0c00-0000-5c94e5760000\"",
      "partitionKey": "GGG-Section-{fca09906-dff9-40b2-a971-28fef7f37dbf}-{1}",
      "type": "Section",
      "clientId": "GGG",
      "createdBy": "FFFFF",
      "createdDate": "2018-11-12T00:00:00",
      "modifiedBy": "FFFFF",
      "modifiedDate": "2018-11-12T00:00:00",
      "isactive": false
    },
    {
      "title": "GHI",
      "description": "",
      "order": "3",
      "status": "Active",
      "startDate": "2018-12-12T00:00:00",
      "endDate": null,
      "id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
      "_etag": "\"0d00faa1-0000-0c00-0000-5c94e5750000\"",
      "partitionKey": "GGG-Section-{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
      "type": "Section",
      "clientId": "GGG",
      "createdBy": "FFFFF",
      "createdDate": "2018-11-12T00:00:00",
      "modifiedBy": "FFFFF",
      "modifiedDate": "2018-11-12T00:00:00",
      "isactive": false
    }
  ],
  "contents": [
    {
      "dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
      "baseDataid": "{a351366f-bf4b-44e0-94ff-a81be899ec3a}-{1}",
      "subType": "Table",
      "sectionView": {
        "id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
        "title": "AAA",
        "description": "",
        "order": "4"
      },
      "title": "PL",
      "description": "",
      "order": "3",
      "status": "Active",
      "startDate": "2018-12-12T00:00:00",
      "endDate": null,
      "displayColumns": [ "N", "M", "O", "P" ],
      "tableValues": [
        {
          "N": "Level 21",
          "M": "22",
          "O": "",
          "P": "",
          "isRowEditable": false
        },
        {
          "id": "6cb79b9f-2ef2-4d3a-b6c4-7d84dd61aaf7",
          "isDeleted": true,
          "N": "KKKKKKK",
          "M": "GBP 20M",
          "O": "",
          "isRowEditable": false
        },
        {
          "id": "c83caf0b-8f00-4dc8-bf35-473bda398937",
          "isDeleted": true,
          "N": "EP",
          "M": "GBP 15M",
          "O": "",
          "isRowEditable": false
        }
      ],
      "placeHolderValues": "",
      "organizationDataView": [
        {
          "id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
          "orgGroupName": "QQ",
          "orgGroupType": "DD",
          "orgLevel": 1,
          "orgParentGroupId": ""
        }
      ],
      "id": "{16a3fb1e-f7fa-4dfe-a4d3-c51b56c8dbee-uw}-{1}",
      "_etag": "\"0d00a0ca-0000-0c00-0000-5c94ef3f0000\"",
      "partitionKey": "GGG-CCCCOOOOO-{16a3fb1e-f7fa-4dfe-a4d3-c51b56c8dbee-uw}-{1}",
      "type": "CCCCOOOOO",
      "clientId": "GGG",
      "createdBy": "MM",
      "createdDate": "2018-12-12T00:00:00",
      "modifiedBy": "PPP",
      "modifiedDate": null,
      "isactive": false
    },
    {
      "dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
      "baseDataid": "{2b498850-8f11-475d-b170-5705d05c4bf1}-{1}",
      "subType": "Clause",
      "sectionView": {
        "id": "{b3cdda34-1fd2-4463-9aa0-24beff4b83fe}-{1}",
        "title": "LLL",
        "description": "",
        "order": "3"
      },
      "title": "kkkkk",
      "Description": [
        {
          "type": "label",
          "value": "<br/>Some sample text here"
        }
      ],
      "order": "6",
      "status": "Active",
      "startDate": "2018-12-12T00:00:00",
      "endDate": null,
      "displayColumns": [],
      "tableValues": null,
      "placeHolderValues": "",
      "organizationDataView": [
        {
          "id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
          "orgGroupName": "QQ",
          "orgGroupType": "DD",
          "orgLevel": 1,
          "orgParentGroupId": ""
        }
      ],
      "id": "{6193cef1-2fe5-47c2-8367-0650ab66caf3-uw}-{1}",
      "_etag": "\"0d00a5ca-0000-0c00-0000-5c94ef400000\"",
      "partitionKey": "GGG-CCCCOOOOO-{6193cef1-2fe5-47c2-8367-0650ab66caf3-uw}-{1}",
      "type": "CCCCOOOOO",
      "clientId": "GGG",
      "createdBy": "MM",
      "createdDate": "2018-12-12T00:00:00",
      "modifiedBy": "PPP",
      "modifiedDate": null,
      "isactive": false
    },
    {
      "dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
      "baseDataid": "{d6793120-5e5b-40ec-a1ea-e82e7bdc9d1a}-{1}",
      "subType": "Clause",
      "sectionView": {
        "id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
        "title": "UT",
        "description": "Sample Text",
        "order": "4"
      },
      "title": "PR",
      "Description": [
        {
          "type": "label",
          "value": "Sample"
        },
        {
          "type": "dropDown",
          "value": "USD",
          "options": [ "USD", "INR", "Dollar" ]
        },
        {
          "type": "text",
          "value": "50"
        },
        {
          "type": "label",
          "value": "Sample "
        },
        {
          "type": "dropDown",
          "value": "USD",
          "options": [ "USD", "INR", "Dollar" ]
        },
        {
          "type": "text",
          "value": "50"
        },
        {
          "type": "label",
          "value": "Sample"
        },
        {
          "type": "dropDown",
          "value": "USD",
          "options": [ "USD", "INR", "Dollar" ]
        },
        {
          "type": "text",
          "value": "50"
        },
        {
          "type": "label",
          "value": "Sample "
        },
        {
          "type": "dropDown",
          "value": "USD",
          "options": [ "USD", "INR", "Dollar" ]
        },
        {
          "type": "text",
          "value": "50"
        },
        {
          "type": "label",
          "value": "Sample"
        },
        {
          "type": "dropDown",
          "value": "USD",
          "options": [ "USD", "INR", "Dollar" ]
        },
        {
          "type": "text",
          "value": "50"
        },
        {
          "type": "label",
          "value": "any one programme/risk</li><li>a maximum premium of "
        },
        {
          "type": "dropDown",
          "value": "USD",
          "options": [ "USD", "INR", "Dollar" ]
        },
        {
          "type": "text",
          "value": "50"
        },
        {
          "type": "label",
          "value": "Sample"
        },
        {
          "type": "dropDown",
          "value": "USD",
          "options": [ "USD", "INR", "Dollar" ]
        },
        {
          "type": "text",
          "value": "50"
        },
        {
          "type": "label",
          "value": "<br/>SSample"
        },
        {
          "type": "dropDown",
          "value": "USD",
          "options": [ "USD", "INR", "Dollar" ]
        },
        {
          "type": "text",
          "value": "50"
        },
        {
          "type": "label",
          "value": "Sample"
        },
        {
          "type": "dropDown",
          "value": "USD",
          "options": [ "USD", "INR", "Dollar" ]
        },
        {
          "type": "text",
          "value": "50"
        },
        {
          "type": "label",
          "value": ".Sample"
        },
        {
          "type": "dropDown",
          "value": "USD",
          "options": [ "USD", "INR", "Dollar" ]
        },
        {
          "type": "text",
          "value": "50"
        },
        {
          "type": "label",
          "value": ", on Lloyd&#39;s paper, in respect of Canadian domiciled Property risks<br/>Your authority for Health extends to unlimited Healthcare where required by statute<br/>You may accept up to "
        },
        {
          "type": "dropDown",
          "value": "USD",
          "options": [ "USD", "INR", "Dollar" ]
        },
        {
          "type": "text",
          "value": "50"
        },
        {
          "type": "label",
          "value": ", on Lloyd&#39;s paper, in respect of declarations under the Coast P&I Facility<br/>You may accept up to "
        },
        {
          "type": "dropDown",
          "value": "USD",
          "options": [ "USD", "INR", "Dollar" ]
        },
        {
          "type": "text",
          "value": "50"
        },
        {
          "type": "label",
          "value": ", on Lloyd&#39;s paper, in respect of combined primary and excess grounding liability<br/>"
        }
      ],
      "order": "6",
      "status": "Active",
      "startDate": "2018-12-12T00:00:00",
      "endDate": null,
      "displayColumns": [],
      "tableValues": null,
      "placeHolderValues": "",
      "organizationDataView": [
        {
          "id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
          "orgGroupName": "QQ",
          "orgGroupType": "DD",
          "orgLevel": 1,
          "orgParentGroupId": ""
        }
      ],
      "id": "{22505164-4d56-493e-8df2-b1bb53ab419a-uw}-{1}",
      "_etag": "\"0d00acca-0000-0c00-0000-5c94ef400000\"",
      "partitionKey": "GGG-CCCCOOOOO-{22505164-4d56-493e-8df2-b1bb53ab419a-uw}-{1}",
      "type": "CCCCOOOOO",
      "clientId": "GGG",
      "createdBy": "MM",
      "createdDate": "2018-12-12T00:00:00",
      "modifiedBy": "PPP",
      "modifiedDate": null,
      "isactive": false
    },
    {
      "dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
      "baseDataid": "{ac949799-60c7-4f85-840f-f30203c5ee43}-{1}",
      "subType": "Block",
      "sectionView": {
        "id": "{fca09906-dff9-40b2-a971-28fef7f37dbf}-{1}",
        "title": "GR",
        "description": "",
        "order": "2"
      },
      "title": "",
      "description": "Sample",
      "order": "1",
      "status": "Active",
      "startDate": "2018-12-12T00:00:00",
      "endDate": null,
      "displayColumns": [],
      "tableValues": null,
      "placeHolderValues": "",
      "organizationDataView": [
        {
          "id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
          "orgGroupName": "QQ",
          "orgGroupType": "DD",
          "orgLevel": 1,
          "orgParentGroupId": ""
        }
      ],
      "id": "{8652fedc-0d7c-48d8-bc3f-577294551671-uw}-{1}",
      "_etag": "\"0d00baca-0000-0c00-0000-5c94ef400000\"",
      "partitionKey": "GGG-CCCCOOOOO-{8652fedc-0d7c-48d8-bc3f-577294551671-uw}-{1}",
      "type": "CCCCOOOOO",
      "clientId": "GGG",
      "createdBy": "MM",
      "createdDate": "2018-12-12T00:00:00",
      "modifiedBy": "PPP",
      "modifiedDate": null,
      "isactive": false
    },
    {
      "dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
      "baseDataid": "{522f1248-0882-4348-9bba-59c056c816c8}-{1}",
      "subType": "Clause",
      "sectionView": {
        "id": "{b3cdda34-1fd2-4463-9aa0-24beff4b83fe}-{1}",
        "title": "LLL",
        "description": "",
        "order": "3"
      },
      "title": "UP",
      "Description": [
        {
          "type": "label",
          "value": "Sample"
        }
      ],
      "order": "1",
      "status": "Active",
      "startDate": "2018-12-12T00:00:00",
      "endDate": null,
      "displayColumns": [],
      "tableValues": null,
      "placeHolderValues": "",
      "organizationDataView": [
        {
          "id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
          "orgGroupName": "QQ",
          "orgGroupType": "DD",
          "orgLevel": 1,
          "orgParentGroupId": ""
        }
      ],
      "id": "{944eae3d-fa0f-4b0e-9c66-3499a16fc2fd-uw}-{1}",
      "_etag": "\"0d00bfca-0000-0c00-0000-5c94ef400000\"",
      "partitionKey": "GGG-CCCCOOOOO-{944eae3d-fa0f-4b0e-9c66-3499a16fc2fd-uw}-{1}",
      "type": "CCCCOOOOO",
      "clientId": "GGG",
      "createdBy": "MM",
      "createdDate": "2018-12-12T00:00:00",
      "modifiedBy": "PPP",
      "modifiedDate": null,
      "isactive": false
    },
    {
      "dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
      "baseDataid": "{6c6a3c80-3536-4c51-8ccf-fcdc16d94090}-{1}",
      "subType": "Table",
      "sectionView": {
        "id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
        "title": "KKPKPKPK",
        "description": "",
        "order": "4"
      },
      "title": "PT",
      "description": "",
      "order": "4",
      "status": "Active",
      "startDate": "2018-12-12T00:00:00",
      "endDate": null,
      "displayColumns": [ ".", "KKKKKKK", "EP", "P" ],
      "tableValues": [
        {
          ".": "Level 11",
          "KKKKKKK": "",
          "EP": "Level 21",
          "P": "",
          "isRowEditable": false
        },
        {
          ".": "Asbestos - other than licensed removers",
          "KKKKKKK": "GBP 5M",
          "EP": ".",
          "isRowEditable": false
        },
        {
          ".": "Auto manufacturing - safety critical components",
          "KKKKKKK": "GBP 10M",
          "EP": ".",
          "isRowEditable": false
        },
        {
          ".": "Rail - contracting companies",
          "KKKKKKK": "GBP 5M",
          "EP": ".",
          "isRowEditable": false
        },
        {
          ".": "Asbestos - other than licensed removers",
          "KKKKKKK": ".",
          "EP": "GBP 10M",
          "isRowEditable": false
        },
        {
          ".": "Rail - contracting companies",
          "KKKKKKK": ".",
          "EP": "GBP 10M",
          "isRowEditable": false
        }
      ],
      "placeHolderValues": "",
      "organizationDataView": [
        {
          "id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
          "orgGroupName": "QQ",
          "orgGroupType": "DD",
          "orgLevel": 1,
          "orgParentGroupId": "."
        }
      ],
      "id": "{91de8a0b-4156-4121-be05-844b03928c29-uw}-{1}",
      "_etag": "\"0d00c5ca-0000-0c00-0000-5c94ef410000\"",
      "partitionKey": "GGG-CCCCOOOOO-{91de8a0b-4156-4121-be05-844b03928c29-uw}-{1}",
      "type": "CCCCOOOOO",
      "clientId": "GGG",
      "createdBy": "MM",
      "createdDate": "2018-12-12T00:00:00",
      "modifiedBy": "PPP",
      "modifiedDate": null,
      "isactive": false
    },
    {
      "dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
      "baseDataid": "{92860693-e038-4a58-814c-6a74d59e7cce}-{1}",
      "subType": "Clause",
      "sectionView": {
        "id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
        "title": "KKPKPKPK",
        "description": "",
        "order": "4"
      },
      "title": "",
      "Description": [
        {
          "type": "label",
          "value": "Sample"
        }
      ],

      "order": "9",
      "status": "Active",
      "startDate": "2018-12-12T00:00:00",
      "endDate": null,
      "displayColumns": [],
      "tableValues": null,
      "placeHolderValues": "",
      "organizationDataView": [
        {
          "id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
          "orgGroupName": "QQ",
          "orgGroupType": "DD",
          "orgLevel": 1,
          "orgParentGroupId": ""
        }
      ],
      "id": "{af17341e-a88c-4564-8296-c513e3708af2-uw-per}-{1}",
      "_etag": "\"0d00e3ca-0000-0c00-0000-5c94ef420000\"",
      "partitionKey": "GGG-CCCCOOOOO-{af17341e-a88c-4564-8296-c513e3708af2-uw-per}-{1}",
      "type": "CCCCOOOOO",
      "clientId": "GGG",
      "createdBy": "MM",
      "createdDate": "2018-12-12T00:00:00",
      "modifiedBy": "PPP",
      "modifiedDate": null,
      "isactive": false
    },
    {
      "dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
      "baseDataid": "{92860693-e038-4a58-814c-6a74d59e7cce}-{1}",
      "subType": "Clause",
      "sectionView": {
        "id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
        "title": "KKPKPKPK",
        "description": "",
        "order": "4"
      },
      "title": "PL",

      "Description": [
        {
          "type": "label",
          "value": "Sample"
        }
      ],
      "order": "7",
      "status": "Active",
      "startDate": "2018-12-12T00:00:00",
      "endDate": null,
      "displayColumns": [],
      "tableValues": null,
      "placeHolderValues": "",
      "organizationDataView": [
        {
          "id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
          "orgGroupName": "QQ",
          "orgGroupType": "DD",
          "orgLevel": 1,
          "orgParentGroupId": ""
        }
      ],
      "id": "{af17341e-a88c-4564-8296-c513e3708af2-uw}-{1}",
      "_etag": "\"0d00e8ca-0000-0c00-0000-5c94ef420000\"",
      "partitionKey": "GGG-CCCCOOOOO-{af17341e-a88c-4564-8296-c513e3708af2-uw}-{1}",
      "type": "CCCCOOOOO",
      "clientId": "GGG",
      "createdBy": "MM",
      "createdDate": "2018-12-12T00:00:00",
      "modifiedBy": "PPP",
      "modifiedDate": null,
      "isactive": false
    },

    {
      "dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
      "baseDataid": "{92c5bd05-c8a2-45c1-a1e9-fd3f78c705ab}-{1}",
      "subType": "Table",
      "sectionView": {
        "id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
        "title": "KKPKPKPK",
        "description": "",
        "order": "4"
      },
      "title": "KKPKPKPK PP",
      "description": "",
      "order": "1",
      "status": "Active",
      "startDate": "2018-12-12T00:00:00",
      "endDate": null,
      "displayColumns": [ "N", "kkk", "LPLPLPL", "Ccy", "M", "LTLT", "P" ],
      "tableValues": [
        {
          "N": "Level 11",
          "kkk": "",
          "LPLPLPL": "",
          "Ccy": "",
          "M": "",
          "LTLT": "",
          "P": "",
          "isRowEditable": false
        },
        {
          "N": "Level 11",
          "kkk": "",
          "LPLPLPL": "",
          "Ccy": "",
          "M": "11",
          "LTLT": "",
          "P": "",
          "isRowEditable": false
        },
        {
          "N": "QQQl",
          "kkk": "QQQQ",
          "LPLPLPL": "DDDD",
          "Ccy": "GBP",
          "M": "10M",
          "LTLT": "Any one vessel",
          "isRowEditable": false
        },
        {
          "N": "Marine Cargo",
          "kkk": "QIEL",
          "LPLPLPL": "Lineslip and other non-coverholder facilities",
          "Ccy": "GBP",
          "M": "5M",
          "LTLT": "Any one event",
          "isRowEditable": false
        },
        {
          "N": "KKKK",
          "kkk": "PPPP",
          "LPLPLPL": "DDDD",
          "Ccy": "GBP",
          "M": "20M",
          "LTLT": "Any one vessel",
          "isRowEditable": false
        }
      ],
      "placeHolderValues": "",
      "organizationDataView": [
        {
          "id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
          "orgGroupName": "QQ",
          "orgGroupType": "DD",
          "orgLevel": 1,
          "orgParentGroupId": ""
        }
      ],
      "id": "{d036bc60-db2d-4c93-86ff-981a62e207ca-uw}-{1}",
      "_etag": "\"0d00eacb-0000-0c00-0000-5c94ef530000\"",
      "partitionKey": "GGG-CCCCOOOOO-{d036bc60-db2d-4c93-86ff-981a62e207ca-uw}-{1}",
      "type": "CCCCOOOOO",
      "clientId": "GGG",
      "createdBy": "MM",
      "createdDate": "2018-12-12T00:00:00",
      "modifiedBy": "PPP",
      "modifiedDate": null,
      "isactive": false
    },

    {
      "dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
      "baseDataid": "{bf1f6e82-6afd-4837-81ab-acabc665da14}-{1}",
      "subType": "Clause",
      "sectionView": {
        "id": "{b3cdda34-1fd2-4463-9aa0-24beff4b83fe}-{1}",
        "title": "LLL",
        "description": "",
        "order": "3"
      },
      "title": "klklkl",

      "Description": [
        {
          "type": "label",
          "value": "sAMPLE tEXT"
        }
      ],
      "order": "4",
      "status": "Active",
      "startDate": "2018-12-12T00:00:00",
      "endDate": null,
      "displayColumns": [],
      "tableValues": null,
      "placeHolderValues": "",
      "organizationDataView": [
        {
          "id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
          "orgGroupName": "QQ",
          "orgGroupType": "DD",
          "orgLevel": 1,
          "orgParentGroupId": ""
        }
      ],
      "id": "{QQ-851f96e7-542f-4a57-a0b1-35feb4698f5e-uw}-{1}",
      "_etag": "\"0d0062cc-0000-0c00-0000-5c94ef5a0000\"",
      "partitionKey": "GGG-CCCCOOOOO-{QQ-851f96e7-542f-4a57-a0b1-35feb4698f5e-uw}-{1}",
      "type": "CCCCOOOOO",
      "clientId": "GGG",
      "createdBy": "MM",
      "createdDate": "2018-12-12T00:00:00",
      "modifiedBy": "PPP",
      "modifiedDate": null,
      "isactive": false
    }
  ]
}
   getClauseData(dalContentdata) {
    let dynamicClauseHtmlSource = '<h4>' + dalContentdata.title + '</h4>';
    dynamicClauseHtmlSource = dynamicClauseHtmlSource + '<p></p>';
    dynamicClauseHtmlSource = dynamicClauseHtmlSource + + '<p style="text-align:justify;line-height:0.3em">' + dalContentdata.description + '</p>';
    dynamicClauseHtmlSource = this.brToNewLine(dynamicClauseHtmlSource);
    return dynamicClauseHtmlSource;
  }

  getBlockData(dalContentdata) {
    let dynamicBlockHtmlSource = '<h4>' + dalContentdata.title + '</h4>';
    dynamicBlockHtmlSource = dynamicBlockHtmlSource + '<p></p>';
    dynamicBlockHtmlSource = dynamicBlockHtmlSource + dalContentdata.description;
    dynamicBlockHtmlSource = this.brToNewLine(dynamicBlockHtmlSource);
    return dynamicBlockHtmlSource;
  }

  getTableData(dalContentdata) {
    let tableSource = "<table>";
    tableSource = tableSource + "<tr>";

    for (var k = 0; k < dalContentdata.displayColumns.length; k++) {
      tableSource = tableSource + "<th style='word-wrap: break-word'>" + dalContentdata.displayColumns[k] + "</th>";
    }
    tableSource = tableSource + "</tr>";

    for (var j = 0; j < dalContentdata.tableValues.length; j++) {
      tableSource = tableSource + "<tr>";
      for (var k = 0; k < dalContentdata.displayColumns.length; k++) {
        tableSource = tableSource + "<td style='word-wrap: break-word'>" + dalContentdata.tableValues[0][dalContentdata.displayColumns[k]] + "</td>";
      }
      tableSource = tableSource + "</tr>";
    }
    tableSource = tableSource + "</table>";
    return tableSource;
    }

 brToNewLine(str) {
    return str.replace(/<br ?\/?>/g, "\n");
  }

0 个答案:

没有答案