{"action":"created","issue":{"url":"https://api.github.com/repos/bpampuch/pdfmake/issues/808","repository_url":"https://api.github.com/repos/bpampuch/pdfmake","labels_url":"https://api.github.com/repos/bpampuch/pdfmake/issues/808/labels{/name}","comments_url":"https://api.github.com/repos/bpampuch/pdfmake/issues/808/comments","events_url":"https://api.github.com/repos/bpampuch/pdfmake/issues/808/events","html_url":"https://github.com/bpampuch/pdfmake/issues/808","id":198804799,"number":808,"title":"Dynamic headers and footers","user":{"login":"mevillep","id":13953662,"avatar_url":"https://avatars.githubusercontent.com/u/13953662?v=3","gravatar_id":"","url":"https://api.github.com/users/mevillep","html_url":"https://github.com/mevillep","followers_url":"https://api.github.com/users/mevillep/followers","following_url":"https://api.github.com/users/mevillep/following{/other_user}","gists_url":"https://api.github.com/users/mevillep/gists{/gist_id}","starred_url":"https://api.github.com/users/mevillep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mevillep/subscriptions","organizations_url":"https://api.github.com/users/mevillep/orgs","repos_url":"https://api.github.com/users/mevillep/repos","events_url":"https://api.github.com/users/mevillep/events{/privacy}","received_events_url":"https://api.github.com/users/mevillep/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-01-04T20:36:50Z","updated_at":"2017-01-09T15:40:04Z","closed_at":null,"body":"I am passing an array of multiple objects to my docDefinition Object. I am wanting to put dynamic data for the headers and footers from these multiple objects.\r\n\r\n\r\nFooter code:\r\n\r\n  docDefinition.footer = function (page, pages) {\r\n                            return {\r\n                               style: 'fRepeat',\r\n                            table: {\r\n                                widths: [250, 300, 250, 302],\r\n                                body: [\r\n                                    [Send Correspondence to Buyer,key.buyerName, Buyer Email, key.buyerEmailAddress],\r\n                                    [Sourcing Signature/Date, some text1, Supplier Signature/Date, some text 2]\r\n  ]\r\n                                   }\r\n                                  }\r\n\r\n     }                  \r\n\r\nAbove, the key.buyerName and key.buyerEmailAddress are present in every object that I pass to docDefinition. Hence, I want the footer to be unique per object passed.\r\nExample, If I pass 3 objects to the docDefinition, I am expecting to get 3 pdf's with unique footer data on each one of them.\r\nInstead what I observe is that the footer data on the third object is repeated on all the three pdf's.\r\n\r\nP.s.: I got rid of quotes around the text in the code above.\r\nKindly help. @bpampuch "},"comment":{"url":"https://api.github.com/repos/bpampuch/pdfmake/issues/comments/271316328","html_url":"https://github.com/bpampuch/pdfmake/issues/808#issuecomment-271316328","issue_url":"https://api.github.com/repos/bpampuch/pdfmake/issues/808","id":271316328,"user":{"login":"mevillep","id":13953662,"avatar_url":"https://avatars.githubusercontent.com/u/13953662?v=3","gravatar_id":"","url":"https://api.github.com/users/mevillep","html_url":"https://github.com/mevillep","followers_url":"https://api.github.com/users/mevillep/followers","following_url":"https://api.github.com/users/mevillep/following{/other_user}","gists_url":"https://api.github.com/users/mevillep/gists{/gist_id}","starred_url":"https://api.github.com/users/mevillep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mevillep/subscriptions","organizations_url":"https://api.github.com/users/mevillep/orgs","repos_url":"https://api.github.com/users/mevillep/repos","events_url":"https://api.github.com/users/mevillep/events{/privacy}","received_events_url":"https://api.github.com/users/mevillep/received_events","type":"User","site_admin":false},"created_at":"2017-01-09T15:40:04Z","updated_at":"2017-01-09T15:40:04Z","body":"`var pdfObjects = [{\r\n    \"foot\":\"0\",\r\n    \"poRevisionType\": \"NON-CORE\",\r\n    \"poRevisionNumber\": 0,\r\n    \"poRevisionDate\": null,\r\n    \"poNumber\": \"111111\",  //THIS IS TH DATA IN THE HEADERS \r\n    \"poReleaseNumber\": 0,\r\n    \"creationDate\": '1473638400000',\r\n    \"poTypeCode\": \"STANDARD\",\r\n    \"buyerId\": '11127493',\r\n    \"buyerName\": \"AAAAAA\" , //THIS IS TH DATA IN THE FOOTER \r\n    \"vendorId\": '436706',\r\n    \"vendorName\": \"LEMAC PACKAGING\",\r\n    \"vendorGslId\": \"023047\",\r\n    \"poLineTypeCode\": null,\r\n    \"billToLocationId\": '0',\r\n    \"billToLocDescription\": null,\r\n    \"billToLocAddrLine1\": null,\r\n    \"billToLocAddrLine2\": null,\r\n    \"billToLocAddrLine3\": null,\r\n    \"billToLocAddrLine4\": null,\r\n    \"billToLocAddrCityName\": null,\r\n    \"billToLocAddrStateCode\": null,\r\n    \"billToLocAddrProvinceCode\": null,\r\n    \"billToLocAddrPostalCode\": null,\r\n    \"billToLocAddrCountryCode\": null,\r\n    \"shipToLocationId\": '2226000',\r\n    \"shipToLocDescription\": null,\r\n    \"shipToLocAddrLine1\": \"1503 W. MAIN ST. EXT.\",\r\n    \"shipToLocAddrLine2\": \" \",\r\n    \"shipToLocAddrLine3\": \" \",\r\n    \"shipToLocAddrLine4\": \" \",\r\n    \"shipToLocAddrCityName\": \"GROVE CITY\",\r\n    \"shipToLocAddrStateCode\": \"PA\",\r\n    \"shipToLocAddrProvinceCode\": null,\r\n    \"shipToLocAddrPostalCode\": \"16127\",\r\n    \"shipToLocAddrCountryCode\": \"US\",\r\n    \"shipFromLocId\": '473358',\r\n    \"shipFromLocAddrLine1\": \"P.O. BOX 10788\",\r\n    \"shipFromLocAddrLine2\": \" \",\r\n    \"shipFromLocAddrLine3\": \" \",\r\n    \"shipFromLocAddrLine4\": \" \",\r\n    \"shipFromLocAddrCityName\": \"ERIE\",\r\n    \"shipFromLocAddrStateCode\": \"PA\",\r\n    \"shipFromLocAddrProvinceCode\": null,\r\n    \"shipFromLocAddrPostalCode\": \"16514\",\r\n    \"shipFromLocAddrCountryCode\": \"US\",\r\n    \"approvedById\": \"11127493\",\r\n    \"mailInvoiceToLocId\": '2226000',\r\n    \"vatNumber\": null,\r\n    \"vatAmount\": null,\r\n    \"netTotalAmount\": '204',\r\n    \"currencyCode\": \"USD\",\r\n    \"incotermsCode\": null,\r\n    \"poHeaderNote\": null,\r\n    \"dd\": null,\r\n    \"tncTxt\": \"SOME TEXT THERE\" ,\r\n    \"fobLookupCode\": null,\r\n    \"approvedByName\": \"Magaly Escamilla\",\r\n    \"approverPositionDescription\": \"Sr. Buyer\",\r\n    \"shipmentPriorityDescription\": null,\r\n    \"shippingInstructionDescription\": null,\r\n    \"packingInstructionDescription\": null,\r\n    \"buyerEmailAddress\": \"magaly.escamilla1@ge.com\",\r\n    \"poLine\": [{\r\n        \"poLineNumber\": '32',\r\n        \"itemDescription\": \"LABEL          CAUTION\",\r\n        \"itemRevisionCode\": \"0\",\r\n        \"itemPartNumber\": \"84A233484P4\",\r\n        \"approvedMfgName\": null,\r\n        \"mfgPartNumber\": null,\r\n        \"lineQuantity\": '140',\r\n        \"lineNoteToVendorTxt\": null,\r\n        \"drawingRevisionNumber\": \"0\",\r\n        \"poLineNote\": null,\r\n        \"unitPriceAmount\": '23',\r\n        \"totalPrice\": '204',\r\n        \"lineTypeCode\": \"Goods\",\r\n        \"shipment\": [{\r\n            \"poShipmentNumber\": '1',\r\n            \"poShipmentNote\": null,\r\n            \"needByDate\": '1479859200000',\r\n            \"promiseDate\": null,\r\n            \"shipQuantity\": '140',\r\n            \"uomCode\": \"PC\",\r\n            \"shipToLocationId\": 0,\r\n            \"shipToLocDescription\": null,\r\n            \"shipToLocAddrLine1\": \"1503 W. MAIN ST. EXT.\",\r\n            \"shipToLocAddrLine2\": null,\r\n            \"shipToLocAddrLine3\": null,\r\n            \"shipToLocAddrLine4\": null,\r\n            \"shipToLocAddrCityName\": \"GROVE CITY\",\r\n            \"shipToLocAddrStateCode\": \"PA\",\r\n            \"shipToLocAddrProvinceCode\": null,\r\n            \"shipToLocAddrPostalCode\": \"16127\",\r\n            \"shipToLocAddrCountryCode\": \"US\",\r\n            \"workOrderNumber\": null\r\n        }\r\n        ]\r\n    }]\r\n},\r\n{\r\n    \"foot\":\"1\",\r\n    \"poRevisionType\": \"NON-CORE\",\r\n    \"poRevisionNumber\": 0,\r\n    \"poRevisionDate\": null,\r\n    \"poNumber\": \"222222\",  //THIS IS TH DATA IN THE HEADERS \r\n    \"poReleaseNumber\": 0,\r\n    \"creationDate\": '1473638400000',\r\n    \"poTypeCode\": \"STANDARD\",\r\n    \"buyerId\": '11127493',\r\n    \"buyerName\": \"BBBBBB\", //THIS IS TH DATA IN THE FOOTER \r\n    \"vendorId\": '436706',\r\n    \"vendorName\": \"LEMAC PACKAGING\",\r\n    \"vendorGslId\": \"023047\",\r\n    \"poLineTypeCode\": null,\r\n    \"billToLocationId\": '0',\r\n    \"billToLocDescription\": null,\r\n    \"billToLocAddrLine1\": null,\r\n    \"billToLocAddrLine2\": null,\r\n    \"billToLocAddrLine3\": null,\r\n    \"billToLocAddrLine4\": null,\r\n    \"billToLocAddrCityName\": null,\r\n    \"billToLocAddrStateCode\": null,\r\n    \"billToLocAddrProvinceCode\": null,\r\n    \"billToLocAddrPostalCode\": null,\r\n    \"billToLocAddrCountryCode\": null,\r\n    \"shipToLocationId\": '2226000',\r\n    \"shipToLocDescription\": null,\r\n    \"shipToLocAddrLine1\": \"1503 W. MAIN ST. EXT.\",\r\n    \"shipToLocAddrLine2\": \" \",\r\n    \"shipToLocAddrLine3\": \" \",\r\n    \"shipToLocAddrLine4\": \" \",\r\n    \"shipToLocAddrCityName\": \"GROVE CITY\",\r\n    \"shipToLocAddrStateCode\": \"PA\",\r\n    \"shipToLocAddrProvinceCode\": null,\r\n    \"shipToLocAddrPostalCode\": \"16127\",\r\n    \"shipToLocAddrCountryCode\": \"US\",\r\n    \"shipFromLocId\": '473358',\r\n    \"shipFromLocAddrLine1\": \"P.O. BOX 10788\",\r\n    \"shipFromLocAddrLine2\": \" \",\r\n    \"shipFromLocAddrLine3\": \" \",\r\n    \"shipFromLocAddrLine4\": \" \",\r\n    \"shipFromLocAddrCityName\": \"ERIE\",\r\n    \"shipFromLocAddrStateCode\": \"PA\",\r\n    \"shipFromLocAddrProvinceCode\": null,\r\n    \"shipFromLocAddrPostalCode\": \"16514\",\r\n    \"shipFromLocAddrCountryCode\": \"US\",\r\n    \"approvedById\": \"11127493\",\r\n    \"mailInvoiceToLocId\": '2226000',\r\n    \"vatNumber\": null,\r\n    \"vatAmount\": null,\r\n    \"netTotalAmount\": '204',\r\n    \"currencyCode\": \"USD\",\r\n    \"incotermsCode\": null,\r\n    \"poHeaderNote\": null,\r\n    \"dd\": null,\r\n   \"tncTxt\": \"SOME TEXT THERE\" ,\r\n    \"fobLookupCode\": null,\r\n    \"approvedByName\": \"Magaly Escamilla\",\r\n    \"approverPositionDescription\": \"Sr. Buyer\",\r\n    \"shipmentPriorityDescription\": null,\r\n    \"shippingInstructionDescription\": null,\r\n    \"packingInstructionDescription\": null,\r\n    \"buyerEmailAddress\": \"magaly.escamilla1@ge.com\",\r\n    \"poLine\": [{\r\n        \"poLineNumber\": '32',\r\n        \"itemDescription\": \"LABEL          CAUTION\",\r\n        \"itemRevisionCode\": \"0\",\r\n        \"itemPartNumber\": \"84A233484P4\",\r\n        \"approvedMfgName\": null,\r\n        \"mfgPartNumber\": null,\r\n        \"lineQuantity\": '140',\r\n        \"lineNoteToVendorTxt\": null,\r\n        \"drawingRevisionNumber\": \"0\",\r\n        \"poLineNote\": null,\r\n        \"unitPriceAmount\": '23',\r\n        \"totalPrice\": '204',\r\n        \"lineTypeCode\": \"Goods\",\r\n        \"shipment\": [{\r\n            \"poShipmentNumber\": '1',\r\n            \"poShipmentNote\": null,\r\n            \"needByDate\": '1479859200000',\r\n            \"promiseDate\": null,\r\n            \"shipQuantity\": '140',\r\n            \"uomCode\": \"PC\",\r\n            \"shipToLocationId\": 0,\r\n            \"shipToLocDescription\": null,\r\n            \"shipToLocAddrLine1\": \"1503 W. MAIN ST. EXT.\",\r\n            \"shipToLocAddrLine2\": null,\r\n            \"shipToLocAddrLine3\": null,\r\n            \"shipToLocAddrLine4\": null,\r\n            \"shipToLocAddrCityName\": \"GROVE CITY\",\r\n            \"shipToLocAddrStateCode\": \"PA\",\r\n            \"shipToLocAddrProvinceCode\": null,\r\n            \"shipToLocAddrPostalCode\": \"16127\",\r\n            \"shipToLocAddrCountryCode\": \"US\",\r\n            \"workOrderNumber\": null\r\n        }]\r\n    }]\r\n}]\r\n\r\n                var dd = {\r\n                    pageOrientation: 'landscape',\r\n                    pageSize: 'A3',\r\n                     pageMargins: [150, 170, 0, 40]\r\n                    }\r\n\r\n\r\n                dd.content = [];\r\n\r\n                dd.styles = {\r\n                    small: {\r\n                        fontSize: 8\r\n                    },\r\n                    sellerHeader: {\r\n                        fontSize: 12,\r\n                        bold: true,\r\n                        margin: [-120, -10, 0, 5]  //change\r\n                    },\r\n                    hRepeat: {\r\n                        margin: [30, 30, 30, 40],\r\n                        bold: true \r\n                    },\r\n                    fRepeat: {\r\n                        margin: [30, -5, 30, 40],\r\n                         bold: true\r\n                    },  \r\n                    shipmentHeader: {\r\n                        fontSize: 12,\r\n                        bold: true,\r\n                        margin: [-120, 5, 0, 5]\r\n\r\n                    },\r\n                    supplierNote: {\r\n                        fontSize: 12,\r\n                        bold: true,\r\n                        margin: [-120, 5, 0, 5]\r\n                    },\r\n                    invoiceNotes: {\r\n                        fontSize: 12,\r\n                        bold: true,\r\n                        margin: [-120, 5, 0, 5]\r\n                    },\r\n                    headerLine: {\r\n                        fontSize: 14,\r\n                        bold: true,\r\n                        margin: [-120, 10, 10, 5]\r\n                    },\r\n                    shipHeader: {\r\n                        fontSize: 12,\r\n                        bold: true,\r\n                        margin: [-70, 5, 30, 5]\r\n\r\n                    },\r\n                    lineNotesHeader: {\r\n                        fontSize: 14,\r\n                        bold: true,\r\n                        margin: [-10, 5, 0, 30]\r\n                    },\r\n                    totalHeader: {\r\n                        margin: [-120, 5, 0, 5],\r\n                        fontSize: 14\r\n                    },\r\n                    tncHeader: {\r\n                        fontSize: 14,\r\n                        bold: true,\r\n                        margin: [-120, 5, 0, 5],\r\n                    },\r\n                    buyerHeader: {\r\n                        fontSize: 14,\r\n                        bold: true,\r\n                        margin: [-120, 5, 0, 25],\r\n                    },\r\n\r\n\r\n                    subheader: {\r\n                        fontSize: 14,\r\n                        bold: true,\r\n                        margin: [0, 10, 0, 5]\r\n                    },\r\n                    tableExample: {\r\n                        margin: [0, 5, 0, 15],\r\n                        fontSize: 14\r\n                    },\r\n\r\n                    tableHeader: {\r\n                        bold: true,\r\n                        color: 'black',\r\n                        fillColor: '#ceebfd'\r\n\r\n                    }, tableHeader1: {\r\n                        bold: true,\r\n                        color: 'black',\r\n                        fillColor: '#ceebfd'\r\n\r\n                    },\r\n\r\n                    greyArea: {\r\n                        fillColor: '#d9d9d9'\r\n                    },\r\n                    greyAreaHead: {\r\n                        fillColor: '#d9d9d9',\r\n                        fontSize: 22\r\n                    }\r\n                };\r\n\r\n                /**\r\n                 *\r\n                 *\r\n                 *\r\n                 *\r\n                 *\r\n                 *\r\n                 * */\r\n                var convertToStringDate = function (date) {\r\n                    if (date) {\r\n                        var today = new Date(date);\r\n\r\n                    } else {\r\n                        return null;\r\n                    }\r\n                    var dd = today.getUTCDate(),\r\n                        mm = today.getUTCMonth() + 1, //January is 0!\r\n                        yyyy = today.getUTCFullYear(),\r\n                        dateString;\r\n\r\n                    if (dd < 10) {\r\n                        dd = '0' + dd;\r\n                    }\r\n                    if (mm < 10) {\r\n                        mm = '0' + mm;\r\n                    }\r\n\r\n                    dateString = mm + '-' + dd + '-' + yyyy;\r\n\r\n\r\n                    return dateString;\r\n                };\r\n\r\n\r\n                var replaceNull = function (data) {\r\n                    if (data != null && data) {\r\n                        return data.toString();\r\n                    }\r\n                    else {\r\n                        return '';\r\n                    }\r\n                }\r\n\r\n                if (!pdfObjects) {\r\n\r\n                    dd.content.push(\r\n                        {\r\n                            text: 'Sorry, no data is available right now!',\r\n                            style: 'header'\r\n                        }\r\n                    );\r\n                }\r\n                $scope.footArray = []\r\n                angular.forEach(pdfObjects, function (key, value) {    // footer loop\r\n                    $scope.footArray.push( { \r\n                            \r\n                              style: 'fRepeat',\r\n                            table: {\r\n                                widths: [250, 300, 250, 302],\r\n                                body: [\r\n                                    ['Send Correspondence to Buyer', replaceNull(key.buyerName), 'Buyer Email', replaceNull(key.buyerEmailAddress)],\r\n                                    ['GE Sourcing Signature/Date', '', 'Supplier Signature/Date', '']\r\n\r\n                                      ]\r\n                                  } \r\n                            \r\n\r\n                        })\r\n                })\r\n                var index = 0;\r\n                angular.forEach(pdfObjects, function (key, value) {   // main loop\r\n                   \r\n                    var k = key.vatAmount + key.netTotalAmount;\r\n\r\n\r\n                  if(key.foot == 0) {   \r\n                        dd.footer = function(page,pages){ return $scope.footArray[0]  }  //////\r\n                            }\r\n                            else if(key.foot == 1)\r\n                             {   \r\n                      //  dd.footer = function(page,pages){ return $scope.footArray[1]  }  //////\r\n                            }\r\n                    dd.header =\r\n                        function (page, pages) {\r\n                            return {\r\n\r\n                                style: 'hRepeat',\r\n                                color: '#444',\r\n                                table: {\r\n                                    widths: [120, 250, 370, 178, 180],\r\n\r\n                                    body: [\r\n                                        [{\r\n                                            rowSpan: 8,\r\n                                            margin: [0, 20, 0, 15],\r\n                                            text: 'APP',\r\n                                            width: 80,\r\n                                            height: 80,\r\n                                            alignment: 'center'\r\n                                        },\r\n                                            {\r\n                                                rowSpan: 8,\r\n                                                text: 'Bill To : \\n' + replaceNull(key.billToLocDescription) + '\\n' + replaceNull(key.billToLocAddrLine1) + '\\n' + replaceNull(key.billToLocAddrLine2) + '\\n' + replaceNull(key.billToLocAddrCityName) + ', ' + replaceNull(key.billToLocAddrStateCode) + ',' + replaceNull(key.billToLocAddrPostalCode) + '\\n' + replaceNull(key.billToLocAddrCountryCode)\r\n                                            }, {\r\n                                            rowSpan: 8,\r\n                                            alignment: 'center',\r\n                                            style: 'greyAreaHead',\r\n                                            text: '\\nPurchase Order\\n' + replaceNull(key.poTypeCode) + ' Order Release \\n'\r\n                                        }, {rowSpan: 1, text: 'Order Number'}, {\r\n                                            rowSpan: 1,\r\n                                            text: replaceNull(key.poNumber)\r\n                                        }],\r\n                                        [{}, {}, {}, {rowSpan: 1, text: 'Order Date'}, {\r\n                                            rowSpan: 1,\r\n                                            text: replaceNull(convertToStringDate(key.creationDate))\r\n                                        }],\r\n                                        [{}, {}, {}, {rowSpan: 1, text: 'Release Number'}, {\r\n                                            rowSpan: 1,\r\n                                            text: key.foot\r\n                                        }],\r\n                                        [{}, {}, {}, {rowSpan: 1, text: 'Revision'}, {\r\n                                            rowSpan: 1,\r\n                                            text: replaceNull(key.poRevisionNumber)\r\n                                        }],\r\n                                        [{}, {}, {}, {rowSpan: 1, text: 'Revision Date'}, {\r\n                                            rowSpan: 1,\r\n                                            text: replaceNull(convertToStringDate(key.poRevisionDate))\r\n                                        }],\r\n                                        [{}, {}, {}, {rowSpan: 3, colspan: 2, text: 'Page'}, {\r\n                                            rowSpan: 3,\r\n                                            text: page.toString() + ' of ' + pages.toString()\r\n                                        }],\r\n                                        [{}, {}, {}, {}, {}],\r\n                                        [{}, {}, {}, {}, {}]\r\n                                    ]\r\n                                }\r\n                            }\r\n                        }, \r\n                            \r\n                        //     if(key.foot == 0) {   \r\n                        // dd.footer = function(page,pages){ return $scope.footArray[key.foot]  }  //////\r\n                        //     }\r\n                        // dd.content.push($scope.footArray[1])\r\n                        index ++;\r\n                    dd.content.push(\r\n                        {\r\n\r\n                            style: 'sellerHeader',\r\n                            table: {\r\n                                headerRows: 1,\r\n                                widths: [375, 370, 370],\r\n\r\n                                body: [\r\n                                    [{text: 'Seller', style: 'tableHeader'}, {\r\n                                        text: 'Ship To:',\r\n                                        style: 'tableHeader'\r\n                                    }, {text: 'Invoice To', style: 'tableHeader'}],\r\n                                    [{text: key.foot+'<<<<<<<<<<<' + replaceNull(key.vendorName) + '\\n' + replaceNull(key.shipFromLocAddrLine1) + '\\n' + replaceNull(key.shipFromLocAddrLine2) + '\\n' + replaceNull(key.shipFromLocAddrLine3) + replaceNull(key.shipFromLocAddrCityName) + ', ' + replaceNull(key.shipFromLocAddrStateCode) + ', ' + replaceNull(key.shipFromLocAddrPostalCode) + '\\n' + replaceNull(key.shipFromLocAddrCountryCode)},\r\n                                        {text: replaceNull(key.shipToLocDescription) + '\\n' + replaceNull(key.shipToLocAddrLine1) + '\\n' + replaceNull(key.shipToLocAddrLine2) + '\\n' + replaceNull(key.shipToLocAddrLine3) + replaceNull(key.shipToLocAddrCityName) + ', ' + replaceNull(key.shipToLocAddrStateCode) + ', ' + replaceNull(key.shipToLocAddrPostalCode) + '\\n' + replaceNull(key.shipToLocAddrCountryCode)},\r\n                                        {text: replaceNull(key.mailInvoiceToLocId) + '\\n'}]\r\n\r\n                                ]\r\n                            }\r\n                        },\r\n\r\n                        {\r\n                            style: 'shipmentHeader',\r\n                            color: '#444',\r\n                            table: {\r\n                                headerRows: 1,\r\n                                widths: [180, 185, 180, 185, 180, 175],\r\n\r\n                                body: [[{text: 'Ship Via', style: 'tableHeader'}, {\r\n                                    colSpan: 5,\r\n                                    text: replaceNull(key.shipToLocDescription) + '\\n' + replaceNull(key.shipToLocAddrLine1) + '\\n' + replaceNull(key.shipToLocAddrLine2) + '\\n' + replaceNull(key.shipToLocAddrLine3) + replaceNull(key.shipToLocAddrCityName) + ', ' + replaceNull(key.shipToLocAddrStateCode) + ', ' + replaceNull(key.shipToLocAddrPostalCode) + '\\n' + replaceNull(key.shipToLocAddrCountryCode)\r\n                                }, {}, {}, {}, {}],\r\n                                    [{\r\n                                        text: 'Approved By ',\r\n                                        style: 'tableHeader'\r\n                                    }, {text: replaceNull(key.approvedByName)}, {\r\n                                        text: 'Approver Position',\r\n                                        style: 'tableHeader'\r\n                                    }, {text: replaceNull(key.approverPositionDescription)}, {\r\n                                        text: 'GE Supplier Code',\r\n                                        style: 'tableHeader'\r\n                                    }, {text: replaceNull(key.vendorGslId)}],\r\n                                    [{\r\n                                        text: 'Currency ',\r\n                                        style: 'tableHeader'\r\n                                    }, {text: replaceNull(key.currencyCode)}, {\r\n                                        text: 'Incoterms',\r\n                                        style: 'tableHeader'\r\n                                    }, {text: replaceNull(key.incotermsCode)}, {\r\n                                        text: 'Payment Terms',\r\n                                        style: 'tableHeader'\r\n                                    }, {text: 'PAYMENT_TERMS'}],\r\n\r\n\r\n                                ]\r\n                            }\r\n                        },\r\n\r\n                        {\r\n                            style: 'supplierNote',\r\n                            color: '#444',\r\n                            table: {\r\n                                headerRows: 1,\r\n                                widths: [1130],\r\n\r\n                                body: [[{text: 'Special Note to Supplier:', style: 'tableHeader'}],\r\n                                    [\r\n\r\n                                        {\r\n                                            style: 'tableExample',\r\n                                            text: replaceNull(key.poHeaderNote) + ' \\n' + 'Shipping Instructions :' + replaceNull(key.shippingInstructionDescription) + ' \\n' + 'Shipping Priorities :' + replaceNull(key.shipmentPriorityDescription) + ' \\n' + 'Packing Instructions :' + replaceNull(key.packingInstructionDescription) + ' \\n' + 'Customer PO :' + replaceNull(key.poNumber) + ' \\n' + 'FOB :' + replaceNull(key.fobLookupCode) + ' \\n' + 'Fright Terms :' + replaceNull(key.billToLocDescription)\r\n                                        }\r\n                                    ]\r\n                                ]\r\n                            }\r\n                        },\r\n\r\n\r\n                        {\r\n                            style: 'invoiceNotes',\r\n                            color: '#444',\r\n                            table: {\r\n                                headerRows: 1,\r\n                                widths: [1130],\r\n\r\n                                body: [[{text: 'Shipment / Invoice Notes ', style: 'tableHeader'}],\r\n                                    [\r\n                                        {\r\n                                            style: 'tableExample', stack: [\r\n                                            {\r\n                                                ul: [\r\n                                                    'Our Order and Release Numbers must appear on all correspondence, invoices, packages and shipping memoranda.',\r\n                                                    'Foreign Suppliers must send Certificate of Origin with each shipment',\r\n                                                    'Packing List and Commercial Invoice must accompany each shipment',\r\n                                                    'Two original (blue ink) signed invoices should be prepared.  One sent together with the cargo and the other sent by courier to the indicated address', 'Seller will not invoice until after Products and Services delivery'\r\n\r\n                                                ]\r\n                                            }\r\n                                        ]\r\n                                        }\r\n                                    ]\r\n                                ]\r\n                            }\r\n                        },\r\n                        {text: '', pageBreak: 'before'}\r\n                    )\r\n                    angular.forEach(key, function (innerkey, innervalue) {\r\n                        // console.log(innerkey);\r\n                        // console.log(innervalue);\r\n                        if (innervalue == 'poLine') {\r\n\r\n                            angular.forEach(innerkey, function (ininnerkey, ininnervalue) {\r\n\r\n\r\n                                dd.content.push(\r\n                                    {\r\n                                        style: 'headerLine',\r\n                                        color: '#444',\r\n                                        id: 'signature',\r\n                                        table: {\r\n                                             headerRows: 1,\r\n                                            widths: [70, '*', '*', '*', 100, '*', 50, '*', '*'],\r\n\r\n                                            body: [[{text: 'Line MEville', style: 'tableHeader'}, {\r\n                                                text: 'Line Type',\r\n                                                style: 'tableHeader'\r\n                                            }, {text: 'Part Number', style: 'tableHeader'}, {\r\n                                                text: 'Description',\r\n                                                style: 'tableHeader'\r\n                                            }, {text: 'Rev', style: 'tableHeader'}, {\r\n                                                text: 'Manufacturer Part Number',\r\n                                                style: 'tableHeader'\r\n                                            }, {text: 'Total Quantity', style: 'tableHeader'}, {\r\n                                                text: 'Unit Price',\r\n                                                style: 'tableHeader'\r\n                                            }, {text: 'Total Price', style: 'tableHeader'}],\r\n                                                [{\r\n                                                    text: replaceNull(ininnerkey.poLineNumber),\r\n                                                    style: 'subheader'\r\n                                                }, {\r\n                                                    text: replaceNull(ininnerkey.lineTypeCode),\r\n                                                    style: 'subheader'\r\n                                                }, {\r\n                                                    text: replaceNull(ininnerkey.itemPartNumber),\r\n                                                    style: 'subheader'\r\n                                                }, {\r\n                                                    text: replaceNull(ininnerkey.itemDescription),\r\n                                                    style: 'subheader'\r\n                                                }, {\r\n                                                    text: replaceNull(ininnerkey.itemRevisionCode),\r\n                                                    style: 'subheader'\r\n                                                }, {\r\n                                                    text: replaceNull(ininnerkey.mfgPartNumber),\r\n                                                    style: 'subheader'\r\n                                                }, {\r\n                                                    text: replaceNull(ininnerkey.lineQuantity),\r\n                                                    style: 'subheader'\r\n                                                }, {\r\n                                                    text: replaceNull(ininnerkey.unitPriceAmount),\r\n                                                    style: 'subheader'\r\n                                                }, {text: replaceNull(ininnerkey.totalPrice), style: 'subheader'}]\r\n                                                // [{text: 'shipment', style: 'tableHeader1',colSpan:2 },{},{ text: 'Due Date',style: 'tableHeader1' ,colSpan:2 },{},{text: 'Shipment Quantity',style: 'tableHeader1',colSpan:2 },{},{text: 'UOM',style: 'tableHeader1',colSpan:2 },{},{text: 'Shipto',style: 'tableHeader1',colSpan:2 },{}]\r\n\r\n\r\n                                            ]\r\n                                        }\r\n\r\n                                    }\r\n                                ); //pushing the line\r\n\r\n\r\n                                angular.forEach(ininnerkey, function (inininnerkey, inininnervalue) {\r\n\r\n                                    if (inininnervalue === 'shipment') {\r\n                                        angular.forEach(inininnerkey, function (ininininnerkey, ininininnervalue) {\r\n                                            dd.content.push(\r\n                                                {\r\n                                                     pageBreak: 'after', \r\n                                                    //  pageOrientation: 'portrait'    ,\r\n                                                    style: 'shipHeader',\r\n                                                    color: '#444',\r\n                                                    table: {\r\n                                                        headerRows: 1,\r\n                                                        widths: [120, 120, 120, 120, 120, 240, 100],\r\n                                                        height: [200],\r\n                                                        body: [[{\r\n                                                            text: 'Shipment ',\r\n                                                            style: 'tableHeader'\r\n                                                        }, {\r\n                                                            text: 'Due Date',\r\n                                                            style: 'tableHeader'\r\n                                                        }, {\r\n                                                            text: 'Promise Date',\r\n                                                            style: 'tableHeader'\r\n                                                        }, {\r\n                                                            text: 'Shipment Quantity',\r\n                                                            style: 'tableHeader'\r\n                                                        }, {text: 'UOM', style: 'tableHeader'}, {\r\n                                                            text: 'ShipTo',\r\n                                                            style: 'tableHeader'\r\n                                                        }, {text: 'Work Order No', style: 'tableHeader'}],\r\n                                                            [{\r\n                                                                text: replaceNull(ininininnerkey.poShipmentNumber),\r\n                                                                style: 'subheader'\r\n                                                            }, {\r\n                                                                text: replaceNull(convertToStringDate(ininininnerkey.needByDate)),\r\n                                                                style: 'subheader'\r\n                                                            }, {\r\n                                                                text: replaceNull(convertToStringDate(ininininnerkey.promiseDate)),\r\n                                                                style: 'subheader'\r\n                                                            }, {\r\n                                                                text: replaceNull(ininininnerkey.shipQuantity),\r\n                                                                style: 'subheader'\r\n                                                            }, {\r\n                                                                text: replaceNull(ininininnerkey.uomCode),\r\n                                                                style: 'subheader'\r\n                                                            }, {\r\n                                                                text: replaceNull(ininininnerkey.shipToLocDescription) + '\\n' + replaceNull(ininininnerkey.shipToLocAddrLine1) + '\\n' + replaceNull(ininininnerkey.shipToLocAddrLine2) + '\\n' + replaceNull(ininininnerkey.shipToLocAddrCityName) + ', ' + replaceNull(ininininnerkey.shipToLocAddrStateCode) + ', ' + replaceNull(ininininnerkey.shipToLocAddrPostalCode) + ', ' + replaceNull(ininininnerkey.shipToLocAddrCountryCode),\r\n                                                                style: 'subheader'\r\n                                                            }, {\r\n                                                                text: replaceNull(ininininnerkey.workOrderNumber),\r\n                                                                style: 'subheader'\r\n                                                            }]\r\n\r\n                                                        ]\r\n                                                    }\r\n                                                }\r\n                                            );\r\n\r\n                                        }); // for inner shipment\r\n\r\n                                    }\r\n\r\n                                });    // for outer shipment\r\n\r\n\r\n                                dd.content.push(\r\n                                    {\r\n                                        style: 'lineNotesHeader',\r\n                                        color: '#444',\r\n                                        table: {\r\n                                            headerRows: 1,\r\n                                            widths: [1130],\r\n                                            body: [[{text: 'Line Level Supplier Notes:', style: 'tableHeader'}],\r\n                                                [\r\n                                                    {\r\n                                                        style: 'tableExample',\r\n                                                        text: replaceNull(ininnerkey.lineNoteToVendorTxt) + '\\n '\r\n                                                    }\r\n                                                ]\r\n                                            ]\r\n                                        }\r\n                                    }\r\n                                )\r\n                                if (!ininnerkey.lineNoteToVendorTxt) {\r\n                                    dd.content.pop()\r\n                                }\r\n                                //\r\n\r\n                            });// for inner line\r\n\r\n\r\n                        }\r\n\r\n\r\n                    }); //for outer line\r\n\r\n\r\n                    dd.content.push({\r\n                            style: 'totalHeader',\r\n                            color: '#444',\r\n                            table: {\r\n                                widths: [660, 230, 220],\r\n\r\n                                body: [\r\n                                    [{rowSpan: 3, text: '', style: 'greyArea'}, {\r\n                                        text: 'Net Total:',\r\n                                        style: 'tableHeader'\r\n                                    }, {text: replaceNull(key.netTotalAmount)}],\r\n                                    [{rowSpan: 3, text: '', style: 'greyArea'}, {\r\n                                        text: 'Tax/VAT (if applicable)',\r\n                                        style: 'tableHeader'\r\n                                    }, {text: replaceNull(key.vatAmount)}],\r\n                                    [{rowSpan: 3, text: '', style: 'greyArea'}, {\r\n                                        text: 'Grand Total',\r\n                                        style: 'tableHeader',\r\n                                        fontSize: '20'\r\n                                    }, {text: replaceNull(k)}]\r\n                                ]\r\n                            }\r\n                        },\r\n                        {text: '', pageBreak: 'before'},\r\n\r\n                        {\r\n                            \r\n                            style: 'tncHeader',\r\n                            color: '#444',\r\n                            table: {\r\n                                headerRows: 1,\r\n                                widths: [1130],\r\n\r\n                                body: [[{text: 'Terms and Contitions Information:', style: 'tableHeader'}],\r\n                                    [\r\n                                        {style: 'tableExample', text: replaceNull(key.tncTxt)}\r\n                                    ]\r\n                                ]\r\n                            }\r\n                        }\r\n                        // ,\r\n                        // {\r\n                        //     style: 'buyerHeader',\r\n                        //     table: {\r\n                        //         widths: [250, 300, 250, 302],\r\n                        //         body: [\r\n                        //             ['Send Correspondence to Buyer', replaceNull(key.buyerName), 'Buyer Email', replaceNull(key.buyerEmailAddress)],\r\n                        //             ['GE Sourcing Signature/Date', '', 'Supplier Signature/Date', ''],\r\n\r\n                        //         ]\r\n                        //     }\r\n                        // }\r\n                        ,\r\n                        {text: '', pageBreak: 'before'}\r\n                    )\r\n\r\n                });\r\n                dd.content.pop();\r\n                pdfMake.createPdf(dd);\r\n               \r\n         \r\n\r\n\r\n            `"}}
{"actor":{"display_login":"mevillep"}}