    var client = invoice.client;
	    var account = invoice.account;
	    var currencyId = client.currency_id;

	    layout.headerRight = 400;
	    layout.rowHeight = 15;


	    doc.setFontSize(7);

	    // add header
	    doc.setLineWidth(0.5);

	    if (NINJA.primaryColor) {
	      setDocHexFill(doc, NINJA.primaryColor);
	      setDocHexDraw(doc, NINJA.primaryColor);
	    } else {
	      doc.setDrawColor(242,101,34);
	      doc.setFillColor(242,101,34);
	    }  

	    var x1 =0;
	    var y1 = 0;
	    var w2 = 595;
	    var h2 = Math.max(110, getInvoiceDetailsHeight(invoice, layout) + 30);
	    doc.rect(x1, y1, w2, h2, 'FD');

	    SetPdfColor('White',doc);

	    //second column
	    doc.setFontType('bold');
	    var name = invoice.account.name;    
	    if (name) {
	        doc.setFontSize('30');
	        doc.setFontType('bold');
	        doc.text(40, 50, name);
	    }

	    if (invoice.image)
	    {
	        y=130;
	        var left = layout.headerRight - invoice.imageWidth;
	        doc.addImage(invoice.image, 'JPEG', layout.marginLeft, y);
	    }

	    // add footer 
	    doc.setLineWidth(0.5);

	    if (NINJA.primaryColor) {
	      setDocHexFill(doc, NINJA.primaryColor);
	      setDocHexDraw(doc, NINJA.primaryColor);
	    } else {
	      doc.setDrawColor(242,101,34);
	      doc.setFillColor(242,101,34);
	    }  

	    var x1 = 0;//tableLeft-tablePadding ;
	    var y1 = 750;
	    var w2 = 596;
	    var h2 = 94;//doc.internal.getFontSize()*length+length*1.1;//+h;//+tablePadding;

	    doc.rect(x1, y1, w2, h2, 'FD');

	    if (!invoice.is_pro && logoImages.imageLogo3)
	    {
	        pageHeight=820;
	      // var left = 25;//250;//headerRight ;
	        y=pageHeight-logoImages.imageLogoHeight3;
	        //var headerRight=370;

	        //var left = headerRight - invoice.imageLogoWidth3;
	        doc.addImage(logoImages.imageLogo3, 'JPEG', 40, y, logoImages.imageLogoWidth3, logoImages.imageLogoHeight3);
	    }

	    doc.setFontSize(10);  
	    var marginLeft = 340;
	    displayAccount(doc, invoice, marginLeft, 780, layout);


	    SetPdfColor('White',doc);    
	    doc.setFontSize('8');
	    var detailsHeight = displayInvoice(doc, invoice, layout.headerRight, layout.accountTop-10, layout);
	    layout.headerTop = Math.max(layout.headerTop, detailsHeight + 50);
	    layout.tableTop = Math.max(layout.tableTop, detailsHeight + 150);

	    SetPdfColor('Black',doc); //set black color
	    doc.setFontSize(7);
	    doc.setFontType('normal');
	    displayClient(doc, invoice, layout.headerRight, layout.headerTop, layout);


	      
	    SetPdfColor('White',doc);    
	    doc.setFontType('bold');

	    doc.setLineWidth(0.3);
	    if (NINJA.secondaryColor) {
	      setDocHexFill(doc, NINJA.secondaryColor);
	      setDocHexDraw(doc, NINJA.secondaryColor);
	    } else {
	      doc.setDrawColor(63,60,60);
	      doc.setFillColor(63,60,60);
	    }  

	    var left = layout.marginLeft - layout.tablePadding;
	    var top = layout.tableTop - layout.tablePadding;
	    var width = layout.marginRight - (2 * layout.tablePadding);
	    var height = 20;
	    doc.rect(left, top, width, height, 'FD');
	    

	    displayInvoiceHeader(doc, invoice, layout);
	    SetPdfColor('Black',doc);
	    var y = displayInvoiceItems(doc, invoice, layout);


	    var height1 = displayNotesAndTerms(doc, layout, invoice, y);
	    var height2 = displaySubtotals(doc, layout, invoice, y, layout.unitCostRight);
	    y += Math.max(height1, height2);


	    var left = layout.marginLeft - layout.tablePadding;
	    var top = y - layout.tablePadding;
	    var width = layout.marginRight - (2 * layout.tablePadding);
	    var height = 20;
	    if (NINJA.secondaryColor) {
	      setDocHexFill(doc, NINJA.secondaryColor);
	      setDocHexDraw(doc, NINJA.secondaryColor);
	    } else {
	      doc.setDrawColor(63,60,60);
	      doc.setFillColor(63,60,60);
	    }  
	    doc.rect(left, top, width, height, 'FD');
	    
	    doc.setFontType('bold');
	    SetPdfColor('White', doc);
	    doc.setFontSize(12);
	    
	    var label = invoice.is_quote ? invoiceLabels.total : invoiceLabels.balance_due;
	    var labelX = layout.unitCostRight-(doc.getStringUnitWidth(label) * doc.internal.getFontSize());
	    doc.text(labelX, y+2, label);


	    doc.setFontType('normal');
	    var amount = formatMoney(invoice.balance_amount , currencyId);
	    headerLeft=layout.headerRight+400;
	    var amountX = layout.lineTotalRight - (doc.getStringUnitWidth(amount) * doc.internal.getFontSize());
	    doc.text(amountX, y+2, amount);