package com.reallinkbilling.print;

import static java.awt.Color.WHITE;
import static org.apache.pdfbox.pdmodel.font.PDType1Font.HELVETICA;
import static org.vandeseer.easytable.settings.HorizontalAlignment.CENTER;
import static org.vandeseer.easytable.settings.HorizontalAlignment.LEFT;
import static org.vandeseer.easytable.settings.HorizontalAlignment.RIGHT;
import static org.vandeseer.easytable.settings.VerticalAlignment.BOTTOM;
import static org.vandeseer.easytable.settings.VerticalAlignment.MIDDLE;


import java.awt.Color;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.sql.Blob;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.io.FileUtils;
import org.apache.fontbox.ttf.TTFParser;
import org.apache.fontbox.ttf.TrueTypeFont;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageContentStream;
import org.apache.pdfbox.pdmodel.PDPageContentStream.AppendMode;
import org.apache.pdfbox.pdmodel.common.PDRectangle;
import org.apache.pdfbox.pdmodel.font.PDFont;
import org.apache.pdfbox.pdmodel.font.PDType0Font;
import org.apache.pdfbox.pdmodel.font.PDType1Font;
import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.dispatcher.SessionMap;
import org.apache.struts2.interceptor.SessionAware;
import org.vandeseer.easytable.TableDrawer;
import org.vandeseer.easytable.structure.Row;
import org.vandeseer.easytable.structure.Table;
import org.vandeseer.easytable.structure.Table.TableBuilder;
import org.vandeseer.easytable.structure.cell.TextCell;


import com.opensymphony.xwork2.ActionSupport;
import com.reallinkbilling.DAO.BillInformationDAO;
import com.reallinkbilling.DAO.BillProductInfoDAO;
import com.reallinkbilling.cipher.EncryptionDecryption;
import com.reallinkbilling.db.GetDBConnection;
import com.reallinkbilling.resource.GetListResource;
import com.reallinkbilling.resource.NumberToWordsConverter;
import com.reallinkbilling.utils.GetCustomerCreditAmountById;



public class BillPrintOnly extends ActionSupport implements SessionAware{

	/**
	 * 
	 */
	private static final long serialVersionUID = -1414976236123269184L;
	/**
	 * 
	 */

	
	private HttpSession session;
	private SessionMap<String,Object> sessionMap;
	private BillInformationDAO billInfoDAO = null;
	private List<BillProductInfoDAO> productInfoList = null;
	public HttpServletRequest request;
	public HttpServletResponse response;
	private String billNumber;
	private String billType;
	private String typeOfBill;
	private String key;
	private String language;
	private String billDateTime;
	
	private final static Color BLUE_DARK = new Color(76, 129, 190);
    private final static Color BLUE_LIGHT_1 = new Color(186, 206, 230);
    private final static Color BLUE_LIGHT_2 = new Color(218, 230, 242);

    private final static Color GRAY_LIGHT_1 = new Color(245, 245, 245);
    private final static Color GRAY_LIGHT_2 = new Color(240, 240, 240);
    private final static Color GRAY_LIGHT_3 = new Color(216, 216, 216);
    private static final float PADDING10 = 10f;
    private static final float PADDING20 = 20f;
    private static final float PADDING30 = 30f;
    
    private final static Color tableHedaerLightBlue = new Color(205, 223, 235);
    
	
	
	public void printBillOnly(){
		
		boolean isBillNumberFound = false;
		
		//System.out.println("Bill Number : "+billNumber);
			DecimalFormat df =new DecimalFormat("##.##");
				Connection connection = null;
				PreparedStatement preparedStatement= null;
				ResultSet resultSet = null;
				boolean isBillTypeIGST = false;
				String sql = "";
				String db = (String) this.getSessionMap().get("db");
				
				String shopId = (String) this.getSessionMap().get("shopId");
	    		String shopCode = (String) this.getSessionMap().get("shopCode");
	    		try
	    		{
	    			
	    		
	    		if(this.getKey() != null)
	    		{
	    			if(!this.getKey().equals(""))
	    			{
	    				String actualKey = EncryptionDecryption.decrypt(this.getKey());
	    				String [] keyData = actualKey.split("#");
	    				
	    				this.setBillNumber(keyData[0]);
	    				shopId = keyData[1];
	    				shopCode = keyData[2];
	    				db = "reallinkshop";
	    				
	    			}
	    		}
	    		
	    		}catch(Exception e){}
			
				String billDateTime = "";
				try
	        	{
	        		
					billInfoDAO = new BillInformationDAO();
					productInfoList = new ArrayList<BillProductInfoDAO>();
	        	      
	        
				connection = GetDBConnection.getDBConnection(db);
				
				if(this.getTypeOfBill() == null)
	        	{
	        		this.setTypeOfBill("CASH-MEMO");
	        	}
	        	
	        	sql = "SELECT "
	        			+ "DATE_FORMAT(bill_date,'%d-%m-%Y'),"
	        			+ "TIME_FORMAT(bill_time,'%h:%i %p'),"	    	        	
	        			+ "payment_type,"
	        			+ "bill_type,"
	        			+ "customer_id,"
	        			+ "customer_name,"
	        			+ "transportation_charges,"
	        			+ "comments,"
	        			+ "bill_total_amount,"
	        			+ "bill_amount_received,"
	        			+ "billed_by,"
	        			+ "buyer_order_number,"
	        			+ "dispatch_doc_number,"
	        			+ "vehicle_number "
	        			+ "FROM "
	        			+ "shop_bill_info_master "
	        			+ "WHERE "
	        			+ "bill_type = ? "
	        			+ "AND "
	        			+ "bill_number = ? "
	        					+ "AND "
	        					+ "shop_id = ? "
	        					+ "AND "
	        					+ "shop_code = ? "
	        					+ "AND "
	        					+ "bill_date = STR_TO_DATE(?,'%d-%m-%Y')";
	        	
	        	
	        	
	        	preparedStatement = connection.prepareStatement(sql);
	        	preparedStatement.setString(1, this.getTypeOfBill());
	        	preparedStatement.setString(2, this.getBillNumber());
	        	preparedStatement.setString(3, shopId);
	        	preparedStatement.setString(4, shopCode);
	        	preparedStatement.setString(5, this.getBillDateTime());
	        	
	      
	        	resultSet = preparedStatement.executeQuery();
	        	
	        	resultSet.last();
	        	int rowCount = resultSet.getRow();
	        	resultSet.beforeFirst();	        	
	        	
	        	if(rowCount>0)
	        	{
	        		Map<String,String> unitShortName = GetListResource.GetUnitShortEnglishName();
	        		
	        		
	        		isBillNumberFound = true;
	        	
	        	if(resultSet.next())
	        	{
	        		if(this.getBillType() != null && this.getBillType().equals("BILL-OF-SUPPLY"))
	        		{
	        			billInfoDAO.setBillType(this.getBillType());
	        		}
	        		else
	        		{
	        			billInfoDAO.setBillType(resultSet.getString(4));
	        		}
	        			
	        		billDateTime = resultSet.getString(1)+" "+resultSet.getString(2);
	        		this.getBillInfoDAO().setBillDate(resultSet.getString(1)+" "+resultSet.getString(2));
	        		this.getBillInfoDAO().setBillNumber(getBillNumber());
	        		this.getBillInfoDAO().setPaymentType(resultSet.getString(3));
	        		this.getBillInfoDAO().setCustId(resultSet.getString(5));
	        		this.getBillInfoDAO().setCustomerName(resultSet.getString(6).split("-")[1]); 
	        		this.getBillInfoDAO().setCustomerMobile(resultSet.getString(6).split("-")[2]); 
	        		this.getBillInfoDAO().setTotalBillAmount(resultSet.getString(9));
	        		this.getBillInfoDAO().setComments(resultSet.getString(8));
	        		this.getBillInfoDAO().setBilledBy(resultSet.getString(11));
	        		this.getBillInfoDAO().setBuyerOrderNumber(resultSet.getString(12));
	        		this.getBillInfoDAO().setDispatchDocNumber(resultSet.getString(13));
	        		this.getBillInfoDAO().setVehicleNumber(resultSet.getString(14));
	        		
	        		
	        	}
	        	
			        	if(resultSet != null)
			        	{
			        		resultSet.close();
			        		resultSet = null;
			        	}
			        	if(preparedStatement != null)
			        	{
			        		preparedStatement.close();
			        		preparedStatement = null;
			        	
			        	}
			        	
			        	
			        	sql = "SELECT "
			        			+ "billProductInfo.product_name,"
			        			+ "billProductInfo.product_name_in_marathi,"
			        			+ "billProductInfo.sales_unit,"
			        			+ "billProductInfo.id_tax_table,"
			        			+ "billProductInfo.sales_rate,"
			        			+ "billProductInfo.product_quantity,"
			        			+ "billProductInfo.discount_percentage,"
			        			+ "billProductInfo.discount_ruppees,"
			        			+ "billProductInfo.product_total_amount,"
			        			+ "billProductInfo.product_total_amount_aft_discount,"
			        			+ "billProductInfo.product_net_amount,"
			        			+ "billProductInfo.product_igst_amount,"
			        			+ "billProductInfo.product_cgst_amount,"
			        			+ "billProductInfo.product_sgst_amount,"
			        			+ "billProductInfo.making_labor_charge,"
			        			+ "productInfo.hsn_sac_code,"
			        			+ "productInfo.product_short_code,"
			        			+ "billProductInfo.product_quantity_2,"
			        			+ "billProductInfo.serial_no_batch_id "
			        			+ "FROM "
			        			+ "shop_bill_product_info_master AS billProductInfo "
			        			+ "INNER JOIN "
			        			+ "shop_product_master AS productInfo "
			        			+ "ON "
			        			+ "billProductInfo.product_id = productInfo.product_id "
			        			+ "where "
			        			+ "billProductInfo.bill_type = ? "
			        			+ "AND "
			        			+ "billProductInfo.bill_number = ? "
			        			+ "AND "
			        			+ "billProductInfo.shop_id = ? "
			        			+ "AND "
			        			+ "billProductInfo.shop_code = ? "
			        			+ "AND "
			        			+ "productInfo.shop_id = ? "
			        			+ "AND "
			        			+ "productInfo.shop_code = ? "
			        			+ "AND "
			        			+ "billProductInfo.bill_date = STR_TO_DATE(?,'%d-%m-%Y') "
			        			+ "ORDER BY "
			        			+ "billProductInfo.entry_id";
			        	
			        	
			        	
			        	
			        	
			        	
			        	preparedStatement = connection.prepareStatement(sql);
			        	
			        	preparedStatement.setString(1, this.getTypeOfBill());
			        	preparedStatement.setString(2, this.getBillNumber());
			        	preparedStatement.setString(3, shopId);
			        	preparedStatement.setString(4, shopCode);
			        	preparedStatement.setString(5, shopId);
			        	preparedStatement.setString(6, shopCode);
			        	preparedStatement.setString(7, this.getBillDateTime());
			        	
			        	resultSet = preparedStatement.executeQuery();
			        	
			        	while(resultSet.next())
			        	{
			        		BillProductInfoDAO billProductInfoDAO = new BillProductInfoDAO();
			        		billProductInfoDAO.setProductName(resultSet.getString(1));
			        		billProductInfoDAO.setProductNameMarathi(resultSet.getString(2));
			        		billProductInfoDAO.setSalesUnit(resultSet.getString(3));
			        		billProductInfoDAO.setTaxId(resultSet.getString(4));
			        		billProductInfoDAO.setSalesRate(resultSet.getFloat(5));
			        		billProductInfoDAO.setQuantity(resultSet.getFloat(6));
			        		billProductInfoDAO.setDiscountPecentage(resultSet.getFloat(7));
			        		billProductInfoDAO.setDiscountRupees(resultSet.getFloat(8));
			        		billProductInfoDAO.setAmount(resultSet.getFloat(9));
			        		billProductInfoDAO.setAmountAfterDiscount(resultSet.getFloat(10));
			        		billProductInfoDAO.setGrossAmount(resultSet.getFloat(11));
			        		billProductInfoDAO.setIgst(resultSet.getFloat(12));
			        		billProductInfoDAO.setCgst(resultSet.getFloat(13));
			        		billProductInfoDAO.setSgst(resultSet.getFloat(14));
			        		billProductInfoDAO.setSalesUnitShortName(unitShortName.get(resultSet.getString(3)));
			        		billProductInfoDAO.setMakingLaborCharge(resultSet.getFloat(15));
			        		billProductInfoDAO.setHsnCode(resultSet.getString(16));
			        		billProductInfoDAO.setProductCode(resultSet.getString(17));
			        		billProductInfoDAO.setQuantity2(resultSet.getFloat(18));
			        		billProductInfoDAO.setProductTotalDiscount(resultSet.getFloat(9)-resultSet.getFloat(10));
			        		billProductInfoDAO.setSerialNoBatchId(resultSet.getString(19));
			        		if(resultSet.getFloat(12) > 0)
			        		{
			        			isBillTypeIGST = true;
			        		}
			        		
			        		this.getProductInfoList().add(billProductInfoDAO);
			        		
			        		Map<String,String> taxInfo = GetListResource.GetTaxNamePercentage(resultSet.getString(4),this.getSessionMap());
				        	
							String taxName = taxInfo.get("TAX-NAME");
							String taxPercentage = taxInfo.get("TAX-PERCENTAGE");
							
							billProductInfoDAO.setTaxName(taxName);
							billProductInfoDAO.setTaxPercentage(Float.parseFloat(taxPercentage));
							
			        				
			        	}
			        	
	        	}
	        	
	        	
				
				if(isBillNumberFound)
				{
					
					@SuppressWarnings("unchecked")
					HashMap<String,String> shopSettingsMap = (HashMap<String, String>) this.getSessionMap().get("shop_settings");
					
					
					String addDiscountColumnString = shopSettingsMap.get("add_discount_column_to_bill");
					String addQRCodeString = shopSettingsMap.get("add_QR_code_to_bill");
					String addGSTNumberString = shopSettingsMap.get("add_gst_number_to_bill");
					String addCustCreditAmtSettings = shopSettingsMap.get("add_credit_amount_to_bill");
					String billMessageFont = shopSettingsMap.get("bill_message_font");
					String showTotalQuantitySettings = shopSettingsMap.get("show_total_quantity");
					String addMakingLaborColumn = shopSettingsMap.get("add_making_charge_column");
					
					 boolean addCustomerCreditAmountToBill = false;		        	
					 boolean addDiscountColumn = false;
					 boolean addQRCode = false;
			         boolean addShortUnit = false;
			         boolean addGSTNumber = false;
			         boolean showTotalQuantity = false;
			         
			        
			         
			         if(showTotalQuantitySettings.equals("TRUE"))
			         {
			        	 showTotalQuantity = true;
			         }
			         
			         if(addCustCreditAmtSettings.equals("TRUE"))
			         {
			        	 addCustomerCreditAmountToBill = true;
			         }
					 if(addDiscountColumnString.equals("TRUE"))
					 {
						 addDiscountColumn = true;
					 }
					 if(addQRCodeString.equals("TRUE"))
					 {
						 addQRCode = true;
					 }
					 if(addGSTNumberString.equals("TRUE"))
					 {
						 addGSTNumber = true;
					 }
	        	
				String gstNum = (String)this.getSessionMap().get("shopgstnumber");
	        	
	        	
	        	float floatTotalAmount = 0.0F;
	        	float floatTotalDiscount = 0.0F;
	        	float floatTotalAmtAfterDiscount = 0.0F;
	        	float totalQuantity = 0.0F;
	        	int listSize = this.getProductInfoList().size();
	        	

	        	for(BillProductInfoDAO infoDAO : this.getProductInfoList())
	        	{
	        		//System.out.println(infoDAO.getProductTotalDiscount());
	        		//System.out.print("Amount after discount : "+infoDAO.getProductTotalDiscount());
	        		floatTotalAmount  = floatTotalAmount+ infoDAO.getAmount();
	        		floatTotalAmtAfterDiscount = floatTotalAmtAfterDiscount + infoDAO.getAmountAfterDiscount();
	        		floatTotalDiscount = floatTotalDiscount + (infoDAO.getProductTotalDiscount());
	        		totalQuantity = totalQuantity + infoDAO.getQuantity();
	        	}
	        	
	        	/*System.out.println("Total Amount : "+floatTotalAmount);
	        	System.out.println("Total Discount : "+floatTotalDiscount);
	        	System.out.println("Total amount Payble : "+floatTotalAmtAfterDiscount);*/
	        	
	        	response = ServletActionContext.getResponse();
				request = ServletActionContext.getRequest();
				
				
				String path= this.getRequest().getSession().getServletContext().getRealPath("/images/");
				
			
				
				
				 
				    
				  int multipleRowsCount = 0;
		         
		         if(this.getBillInfoDAO().getBillType().equals("CASH-MEMO") 
		        		 || (this.getBillInfoDAO().getBillType().equals("COMPOSITE-BILL") 
		        				 && (this.getBillType() == null || (!this.getBillType().equals("A4") && !this.getBillType().equals("A5")))))
		         {
		        	 
		        	 PDDocument document = new PDDocument(); 
						PDPage page = null;
						
						float pageHeight = 430.0F+(listSize*16.2F);
						
						if(addQRCode)
						{
							pageHeight = pageHeight + 30;
						}
						
						if(shopSettingsMap.get("THERMALPRINTHEADER").equals("IMAGE"))
						{
							pageHeight = pageHeight + 50;
						}
						
						PDRectangle pdRectangle = new PDRectangle(220.0F, pageHeight);
						 page = new PDPage(pdRectangle);
						 
						 document.addPage(page);
						 
						 PDImageXObject pdImageQRCode = null;
						 Blob blob = (Blob) this.getSessionMap().get("qr_image_bolb");
						 
						 if(blob != null)
						 {
						 InputStream in = blob.getBinaryStream();
						 File qrFile = new File(path+"/"+shopId+"qr.jpeg");
						 FileOutputStream out = new FileOutputStream(qrFile);
						 byte[] buffer = new byte[1024];
						    int read;
						    while ((read = in.read(buffer)) != -1) {
						        out.write(buffer, 0, read);
						    }
						    
						    in.close();
						    out.close();
						    pdImageQRCode = PDImageXObject.createFromFile(path+"/"+shopId+"qr.jpeg", document);
						 }
						 
						
					         PDImageXObject thermalPrintHeaderImage = null;
					         Blob thermalPrintHeaderImageBlob = null;
					         InputStream thermalPrintHeaderImageIS = null;
					        		 
					         if(shopSettingsMap.get("THERMALPRINTHEADER").equals("IMAGE"))
							 {
									
									 byte[]  thermalPrintHeaderImageBytes =(byte[]) this.getSessionMap().get("thermal_print_header_image");
									 thermalPrintHeaderImage = PDImageXObject.createFromByteArray(document, thermalPrintHeaderImageBytes, "thermalPrintHeader");
								
							 }
						 
						 File fontFile  =  new File( request.getSession().getServletContext().getRealPath("/fonts/Nirmala.ttf"));
						 File fontFileBold  =  new File( request.getSession().getServletContext().getRealPath("/fonts/nirmala-bold.ttf"));
						 File fontFileKrutiBold  =  new File( request.getSession().getServletContext().getRealPath("/fonts/Kruti_Dev_100__Bold.ttf"));
							
						 TrueTypeFont ttf1 = new TTFParser().parse(fontFile);
						 PDFont fontMarathi = PDType0Font.load(document, ttf1, true);
						 
						 TrueTypeFont ttf2 = new TTFParser().parse(fontFileBold);
						 PDFont fontMarathiBold = PDType0Font.load(document, ttf2, true);
						 
						 TrueTypeFont ttf3 = new TTFParser().parse(fontFileKrutiBold);
						 PDFont fontMarathiKrutiBold = PDType0Font.load(document, ttf3, true);
						 
				         PDPageContentStream contentStream = new PDPageContentStream(document, page);
		         
		         Table header;
		         Table billInfoTable;
		         Table itemInfo;
		         Table bottomInfo;
		         
		         TableBuilder tableHeaderBuilder = Table.builder()
			                .addColumnsOfWidth(200)				                
			                .font(HELVETICA)
			                .borderColor(Color.BLACK)
			                .horizontalAlignment(CENTER);
		         
		     
		         if(shopSettingsMap.get("THERMALPRINTHEADER").equals("TEXT"))
				 {
			         
			         Row dairyNameHeader = Row.builder()
				                .add(TextCell.builder().text((String)this.getSessionMap().get("shopname2")).horizontalAlignment(CENTER).borderWidth(0).lineSpacing(0.5F).build())				               
				                .backgroundColor(WHITE)
				                .textColor(Color.BLACK)
				                .font(fontMarathiKrutiBold).fontSize(17)				              
				                .horizontalAlignment(CENTER)
				                .build();
			         
			         tableHeaderBuilder.addRow(dairyNameHeader);
				 }
		         else
		         {
		        	  
			         if(thermalPrintHeaderImage != null)
		        	 {
			        	
		        		 contentStream.drawImage(thermalPrintHeaderImage, 20, pageHeight-50 , 180, 50);
		        		
		        	 }
		         }
		         
		         int addressFontSize = 11;
		         String billAddress = (String)this.getSessionMap().get("shopbillAddress");
		         
		         if(billAddress.length() > 40)
		         {
		        	 addressFontSize = 8;
		         }
		         
		         Row addressRow1 = Row.builder()
			                .add(TextCell.builder().text((String)this.getSessionMap().get("shopbillAddress")).horizontalAlignment(CENTER).borderWidth(0).lineSpacing(0.5F).build())				               
			                .backgroundColor(WHITE)
			                .textColor(Color.BLACK)
			                .font(fontMarathiKrutiBold).fontSize(addressFontSize)				              
			                .horizontalAlignment(CENTER)
			                .build();
		         
		         Row addressRow2 = Row.builder()
			                .add(TextCell.builder()
			                		.text("Mo:"+(String)this.getSessionMap().get("shopcustcarenumber"))
			                		.horizontalAlignment(CENTER).borderWidth(0).lineSpacing(0.5F).build())				               
			                .backgroundColor(WHITE)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD).fontSize(9)				              
			                .horizontalAlignment(CENTER)
			                .build();
		     
		         
		         
		         
		  
		         tableHeaderBuilder.addRow(addressRow1);
		         tableHeaderBuilder.addRow(addressRow2);
		        
		         
		         header = tableHeaderBuilder.build();
		         
		         
		         
		         TableBuilder tableBillInfoBuilder = Table.builder()
			                .addColumnsOfWidth(80,120)				                
			                .font(HELVETICA)
			                .borderColor(Color.BLACK)
			                .horizontalAlignment(CENTER);
		         
		         Row billInfoRow1 = Row.builder()
			                .add(TextCell.builder().text("बिल नंबर:"+this.getBillNumber()).horizontalAlignment(CENTER).borderWidthTop(0.5F).lineSpacing(0.5F).build())				               
			                .add(TextCell.builder().text("तारीख–:"+billDateTime).fontSize(8).horizontalAlignment(CENTER).borderWidthTop(0.5F).lineSpacing(0.5F).build())				               
				            .backgroundColor(WHITE)
			                .textColor(Color.BLACK)
			                .font(fontMarathiBold).fontSize(10)				              
			                .horizontalAlignment(CENTER)
			                .build();
		         
		         
		        
		         Row billInfoRow2 = Row.builder()
			                .add(TextCell.builder().text("Type: "+this.getBillInfoDAO().getPaymentType()).horizontalAlignment(CENTER).borderWidth(0).lineSpacing(0.5F).build())				               
			                .add(TextCell.builder().text("Bill By: "+this.getBillInfoDAO().getBilledBy()).horizontalAlignment(CENTER).borderWidth(0).lineSpacing(0.5F).build())				               
				            .backgroundColor(WHITE)
			                .textColor(Color.BLACK)
			                .font(fontMarathiBold).fontSize(10)				              
			                .horizontalAlignment(CENTER)
			                .build();
		         
		         Row billInfoRow3 = Row.builder()
			                .add(TextCell.builder().text("GST No:"+gstNum).colSpan(2).horizontalAlignment(CENTER).borderWidth(0).lineSpacing(0.5F).build())				               
			                .backgroundColor(WHITE)
			                .textColor(Color.BLACK)
			                .font(fontMarathiBold).fontSize(9)				              
			                .horizontalAlignment(CENTER)
			                .build();
		         Row custName = Row.builder()
			                .add(TextCell.builder().text("Customer : "+this.getBillInfoDAO().getCustomerName()).colSpan(2).horizontalAlignment(CENTER).borderWidthTop(0.5F).lineSpacing(0.5F).build())				               
			                .backgroundColor(WHITE)
			                .textColor(Color.BLACK)
			                .fontSize(9)
			                .font(fontMarathiBold)			              
			                .horizontalAlignment(CENTER)
			                .build();
		         Row custmobile = Row.builder()
			                .add(TextCell.builder().text(this.getBillInfoDAO().getCustomerMobile()).colSpan(2).horizontalAlignment(CENTER).borderWidthTop(0F).lineSpacing(0.5F).build())				               
			                .backgroundColor(WHITE)
			                .textColor(Color.BLACK)
			                .fontSize(8)
			                .font(fontMarathiBold)			              
			                .horizontalAlignment(CENTER)
			                .build();
		        		 
		        		
		         
		         tableBillInfoBuilder.addRow(billInfoRow1);
		         tableBillInfoBuilder.addRow(billInfoRow2);
		         if(addGSTNumber)
		         {
		        	 tableBillInfoBuilder.addRow(billInfoRow3);
		         }
		         tableBillInfoBuilder.addRow(custName);
		         tableBillInfoBuilder.addRow(custmobile);
		          billInfoTable = tableBillInfoBuilder.build();
		          
		          
			         float startY = page.getMediaBox().getHeight()-2;
			         if(shopSettingsMap.get("THERMALPRINTHEADER").equals("IMAGE"))
					 {
			        	 startY = startY - 50;
					 }
			         
			         TableDrawer.builder()
		                .contentStream(contentStream)
		                .table(header)
		                .startX(5F)
		                .startY(startY)
		                .build()
		                .draw();
			         
			         float currectY = startY - 55;
			        
			         TableDrawer.builder()
		                .contentStream(contentStream)
		                .table(billInfoTable)
		                .startX(5F)
		                .startY(currectY)
		                .build()
		                .draw();
			         
			         currectY = currectY - 70;
			          float itemEndY = currectY - 10;
			     
			       if(addDiscountColumn)
		          {

			          if(!addShortUnit)
			          {
				         TableBuilder tableItemInfoBuilder = Table.builder()
					                .addColumnsOfWidth(60,30,35,25,40)				                
					                .font(HELVETICA)
					                .borderColor(Color.BLACK)
					                .horizontalAlignment(CENTER);
			          
				         Row itemInfoHeader = Row.builder()
					                .add(TextCell.builder().text("तपशील").fontSize(9).horizontalAlignment(LEFT).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
					                .add(TextCell.builder().text("QTY").fontSize(9).horizontalAlignment(LEFT).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
					                .add(TextCell.builder().text("दर").fontSize(9).horizontalAlignment(RIGHT).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
					                .add(TextCell.builder().text("सूट").fontSize(9).horizontalAlignment(RIGHT).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
							        .add(TextCell.builder().text("jDde").fontSize(11).font(fontMarathiKrutiBold).horizontalAlignment(RIGHT).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
							        .backgroundColor(WHITE)
					                .textColor(Color.BLACK)
					                .font(fontMarathiBold)          
					                .horizontalAlignment(CENTER)
					                .build();
				         
				         
				         
				         
				         tableItemInfoBuilder.addRow(itemInfoHeader);
				     	
				        
				         
				         int size = this.getProductInfoList().size();
				         Row itemDetails = null;
							for(BillProductInfoDAO informationDAO : this.getProductInfoList())
							{
								
								 int nameLength = informationDAO.getProductNameMarathi().length();
								if(size == 1)
								{
									
									 itemDetails = Row.builder()
								                .add(TextCell.builder().text(informationDAO.getProductNameMarathi()).horizontalAlignment(LEFT).borderWidth(0.0F).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
								                .add(TextCell.builder().text(""+informationDAO.getQuantity()).fontSize(8).horizontalAlignment(LEFT).borderWidth(0F).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
								                .add(TextCell.builder().text(""+informationDAO.getSalesRate()).horizontalAlignment(RIGHT).borderWidth(0.0F).lineSpacing(0.2F).borderWidthBottom(0.5F).build())				               
								                .add(TextCell.builder().text(df.format(informationDAO.getProductTotalDiscount())).horizontalAlignment(RIGHT).borderWidth(0.0F).lineSpacing(0.2F).borderWidthBottom(0.5F).build())				               
									            .add(TextCell.builder().text(df.format(informationDAO.getAmountAfterDiscount())).paddingRight(5F).horizontalAlignment(RIGHT).borderWidth(0.0F).lineSpacing(0.2F).borderWidthBottom(0.5F).build())				               
										        .backgroundColor(WHITE)
								                .textColor(Color.BLACK)
								                .font(fontMarathiBold).fontSize(8)	
								                .horizontalAlignment(CENTER)
								                .build();
								}else
								{
						         itemDetails = Row.builder()
							                .add(TextCell.builder().text(informationDAO.getProductNameMarathi()).horizontalAlignment(LEFT).borderWidth(0.0F).lineSpacing(0.5F).build())				               
							                .add(TextCell.builder().text(""+informationDAO.getQuantity()).fontSize(8).horizontalAlignment(LEFT).borderWidth(0F).lineSpacing(0.5F).build())				               
							                .add(TextCell.builder().text(""+informationDAO.getSalesRate()).horizontalAlignment(RIGHT).borderWidth(0.0F).lineSpacing(0.5F).build())				               
							                .add(TextCell.builder().text(df.format(informationDAO.getProductTotalDiscount())).horizontalAlignment(RIGHT).borderWidth(0.0F).lineSpacing(0.5F).build())				               
								            .add(TextCell.builder().text(df.format(informationDAO.getAmountAfterDiscount())).paddingRight(5F).horizontalAlignment(RIGHT).borderWidth(0.0F).lineSpacing(0.5F).build())				               
									        .backgroundColor(WHITE)
							                .textColor(Color.BLACK)
							                .font(fontMarathiBold).fontSize(8)				              
							                .horizontalAlignment(CENTER)
							                .build();
								}
							
						         tableItemInfoBuilder.addRow(itemDetails);
						         
						         size--;
						       
						        	
						         
								}
							itemInfo = tableItemInfoBuilder.build();
							 itemEndY = itemEndY - itemInfo.getHeight();		
							}
			          else
			          {

					         TableBuilder tableItemInfoBuilder = Table.builder()
						                .addColumnsOfWidth(75,35,30,20,40)				                
						                .font(HELVETICA)
						                .borderColor(Color.BLACK)
						                .horizontalAlignment(CENTER);
				          
					         Row itemInfoHeader = Row.builder()
						                .add(TextCell.builder().text("तपशील").fontSize(9).horizontalAlignment(LEFT).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
						                .add(TextCell.builder().text("QTY").fontSize(9).horizontalAlignment(LEFT).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
						                .add(TextCell.builder().text("दर").fontSize(9).horizontalAlignment(RIGHT).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
						                .add(TextCell.builder().text("सूट").fontSize(9).horizontalAlignment(RIGHT).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
								        .add(TextCell.builder().text("रक्कम").fontSize(9).horizontalAlignment(RIGHT).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
								        .backgroundColor(WHITE)
						                .textColor(Color.BLACK)
						                .font(fontMarathiBold)          
						                .horizontalAlignment(CENTER)
						                .build();
					         
					         
					         
					         
					         tableItemInfoBuilder.addRow(itemInfoHeader);
					     	
					        
					         
					         int size = this.getProductInfoList().size();
					         Row itemDetails = null;
								for(BillProductInfoDAO informationDAO : this.getProductInfoList())
								{
									
									if(size == 1)
									{
										
										 itemDetails = Row.builder()
									                .add(TextCell.builder().text(informationDAO.getProductNameMarathi()).horizontalAlignment(LEFT).borderWidth(0.0F).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
									                .add(TextCell.builder().text(informationDAO.getQuantity()+" "+informationDAO.getSalesUnitShortName()).fontSize(7).horizontalAlignment(LEFT).borderWidth(0F).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
									                .add(TextCell.builder().text(""+informationDAO.getSalesRate()).horizontalAlignment(RIGHT).borderWidth(0.0F).lineSpacing(0.5F).borderWidthBottom(0.5F).build())				               
									                .add(TextCell.builder().text(""+informationDAO.getProductTotalDiscount()).horizontalAlignment(RIGHT).borderWidth(0.0F).lineSpacing(0.5F).borderWidthBottom(0.5F).build())				               
										            .add(TextCell.builder().text(""+informationDAO.getAmountAfterDiscount()).horizontalAlignment(RIGHT).borderWidth(0.0F).lineSpacing(0.5F).borderWidthBottom(0.5F).build())				               
											        .backgroundColor(WHITE)
									                .textColor(Color.BLACK)
									                .font(fontMarathiBold).fontSize(8)				              
									                .horizontalAlignment(CENTER)
									                .build();
									}else
									{
							         itemDetails = Row.builder()
								                .add(TextCell.builder().text(informationDAO.getProductNameMarathi()).horizontalAlignment(LEFT).borderWidth(0.0F).lineSpacing(0.5F).build())				               
								                .add(TextCell.builder().text(informationDAO.getQuantity()+" "+informationDAO.getSalesUnitShortName()).fontSize(7).horizontalAlignment(LEFT).borderWidth(0F).lineSpacing(0.5F).build())				               
								                .add(TextCell.builder().text(""+informationDAO.getSalesRate()).horizontalAlignment(RIGHT).borderWidth(0.0F).lineSpacing(0.5F).build())				               
								                .add(TextCell.builder().text(""+informationDAO.getProductTotalDiscount()).horizontalAlignment(RIGHT).borderWidth(0.0F).lineSpacing(0.5F).build())				               
									            .add(TextCell.builder().text(""+informationDAO.getAmountAfterDiscount()).horizontalAlignment(RIGHT).borderWidth(0.0F).lineSpacing(0.5F).build())				               
										        .backgroundColor(WHITE)
								                .textColor(Color.BLACK)
								                .font(fontMarathiBold).fontSize(8)				              
								                .horizontalAlignment(CENTER)
								                .build();
									}
								
							         tableItemInfoBuilder.addRow(itemDetails);
							         
							         size--;
							         
							       
									}
								itemInfo = tableItemInfoBuilder.build();
								
								 itemEndY = itemEndY - itemInfo.getHeight();
									
			          }
			    	  
			          
							  
							if(addQRCode)
							{
								TableBuilder tableBottomInfoBuilder = Table.builder()
						                .addColumnsOfWidth(70,50)				                
						                .font(HELVETICA)
						                .borderColor(Color.BLACK)
						                .horizontalAlignment(CENTER);
							  
								 Row itemTotalItemsInfo = null;
						          if(showTotalQuantity)
						          {
								  
							          itemTotalItemsInfo = Row.builder()
								                .add(TextCell.builder().text(",dw.k oLrw ").font(fontMarathiKrutiBold).fontSize(11).horizontalAlignment(LEFT).borderWidthTop(0.5F).borderWidthBottom(0.5F).borderWidthLeft(0.5F).borderWidthRight(0.5F).lineSpacing(2F).build())				               
								                .add(TextCell.builder().text(df.format(totalQuantity)).horizontalAlignment(RIGHT).borderWidthTop(0.5F).borderWidthBottom(0.5F).borderWidthLeft(0.5F).borderWidthRight(0.5F).lineSpacing(2F).build())				               
									            .backgroundColor(WHITE)
								                .textColor(Color.BLACK)
								                .font(fontMarathiBold)	
								                .fontSize(9)
								                .horizontalAlignment(CENTER)
								                .height(15F)
								                .build();
						          }
						          else
						          {
						        	  itemTotalItemsInfo = Row.builder()
								                .add(TextCell.builder().text(",dw.k oLrw ").font(fontMarathiKrutiBold).fontSize(11).horizontalAlignment(LEFT).borderWidthTop(0.5F).borderWidthBottom(0.5F).borderWidthLeft(0.5F).borderWidthRight(0.5F).lineSpacing(2F).build())				               
								                .add(TextCell.builder().text(""+listSize).horizontalAlignment(RIGHT).borderWidthTop(0.5F).borderWidthBottom(0.5F).borderWidthLeft(0.5F).borderWidthRight(0.5F).lineSpacing(2F).build())				               
									            .backgroundColor(WHITE)
								                .textColor(Color.BLACK)
								                .font(fontMarathiBold)	
								                .fontSize(9)
								                .horizontalAlignment(CENTER)
								                .height(15F)
								                .build();
						          }
							         Row itemTotalInfo = Row.builder()
								                .add(TextCell.builder().text("jDde").font(fontMarathiKrutiBold).fontSize(11).horizontalAlignment(LEFT).borderWidthLeft(0.5F).borderWidthRight(0.5F).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(2F).build())				               
								                .add(TextCell.builder().text("" +floatTotalAmtAfterDiscount).horizontalAlignment(RIGHT).borderWidthLeft(0.5F).borderWidthRight(0.5F).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(2F).build())				               
								                .backgroundColor(WHITE)
								                .textColor(Color.BLACK)
								                .font(fontMarathiBold)	
								                .fontSize(9)
								                .height(15F)
								                .horizontalAlignment(CENTER)
								                .build();
							         Row discountInfo = Row.builder()
								                .add(TextCell.builder().text(",dw.k cpr").font(fontMarathiKrutiBold).fontSize(11).horizontalAlignment(LEFT).borderWidthLeft(0.5F).borderWidthRight(0.5F).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(2F).build())				               
								                .add(TextCell.builder().text("" +floatTotalDiscount).horizontalAlignment(RIGHT).borderWidthLeft(0.5F).borderWidthRight(0.5F).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(2F).build())				               
									            .backgroundColor(WHITE)
								                .textColor(Color.BLACK)
								                .font(fontMarathiBold)
								                .fontSize(9)
								                .height(15F)
								                .horizontalAlignment(CENTER)
								                .build();
							    
							         
							       
							         tableBottomInfoBuilder.addRow(itemTotalItemsInfo);
							         tableBottomInfoBuilder.addRow(itemTotalInfo);
							         tableBottomInfoBuilder.addRow(discountInfo);
							      
							         bottomInfo = tableBottomInfoBuilder.build();
							}
							else
							{
								TableBuilder tableBottomInfoBuilder = Table.builder()
						                .addColumnsOfWidth(200)				                
						                .font(HELVETICA)
						                .borderColor(Color.BLACK)
						                .horizontalAlignment(CENTER);
								
								Row itemTotalItemsInfo = null;
								if(showTotalQuantity)
								{
									 itemTotalItemsInfo = Row.builder()
							                .add(TextCell.builder().text("एकूण वस्तू‚ :"+totalQuantity+"       |    एकूण रक्कम: " +floatTotalAmtAfterDiscount+"\u20B9").horizontalAlignment(CENTER).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(2F).build())				               
							                .backgroundColor(WHITE)
							                .textColor(Color.BLACK)
							                .font(fontMarathiBold)	
							                .fontSize(9)
							                .horizontalAlignment(CENTER)
							                .build();
									
								}
								else
								{
						          itemTotalItemsInfo = Row.builder()
							                .add(TextCell.builder().text("एकूण वस्तू‚ :"+listSize+"       |    एकूण रक्कम : " +floatTotalAmtAfterDiscount+"\u20B9").horizontalAlignment(CENTER).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(2F).build())				               
							                .backgroundColor(WHITE)
							                .textColor(Color.BLACK)
							                .font(fontMarathiBold)	
							                .fontSize(9)
							                .horizontalAlignment(CENTER)
							                .build();
								}
						         Row discountInfo = Row.builder()
							                .add(TextCell.builder().text("Total Discount : " +floatTotalDiscount+" \u20B9").horizontalAlignment(CENTER).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(2F).build())				               
								             .backgroundColor(WHITE)
							                .textColor(Color.BLACK)
							                .font(fontMarathiBold)
							                .fontSize(9)
							                .horizontalAlignment(CENTER)
							                .build();
						      
						         
						    
						         
						         tableBottomInfoBuilder.addRow(itemTotalItemsInfo);
						         tableBottomInfoBuilder.addRow(discountInfo);
						       
						         bottomInfo = tableBottomInfoBuilder.build();
							}
			          
		        	  
		          }
		          else
		          {
		        	  

			          if(addQRCode)
			          {
			        	  

					         TableBuilder tableItemInfoBuilder = Table.builder()
						                .addColumnsOfWidth(70,40,40,45)				                
						                .font(HELVETICA)
						                .borderColor(Color.BLACK)
						                .horizontalAlignment(CENTER);
				          
					         Row itemInfoHeader = Row.builder()
						                .add(TextCell.builder().text("तपशील").fontSize(9).horizontalAlignment(LEFT).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
						                .add(TextCell.builder().text("QTY").fontSize(9).horizontalAlignment(LEFT).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
						                .add(TextCell.builder().text("दर").fontSize(9).horizontalAlignment(RIGHT).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
						                .add(TextCell.builder().text("रक्कम").fontSize(9).horizontalAlignment(RIGHT).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
								         
						                .backgroundColor(WHITE)
						                .textColor(Color.BLACK)
						                .font(fontMarathiBold).fontSize(10)				              
						                .horizontalAlignment(CENTER)
						                .build();
					       
					         tableItemInfoBuilder.addRow(itemInfoHeader);
					     	
					         int productListSize = productInfoList.size();
					         
					         Row itemDetails = null;
					         
								for(BillProductInfoDAO informationDAO : productInfoList)
								{
									
									 
									if(productListSize>1)
									{
							         itemDetails = Row.builder()
								                .add(TextCell.builder().text(informationDAO.getProductNameMarathi()).fontSize(7).horizontalAlignment(LEFT).borderWidth(0.0F).lineSpacing(0.5F).build())				               
								                .add(TextCell.builder().text(informationDAO.getQuantity()+" "+informationDAO.getSalesUnitShortName()).fontSize(8).horizontalAlignment(LEFT).borderWidth(0F).lineSpacing(0.5F).build())				               
								                .add(TextCell.builder().text(""+informationDAO.getSalesRate()).fontSize(9).horizontalAlignment(RIGHT).borderWidth(0.0F).lineSpacing(0.5F).build())				               
								                .add(TextCell.builder().text(""+informationDAO.getAmountAfterDiscount()).fontSize(9).horizontalAlignment(RIGHT).borderWidth(0.0F).lineSpacing(0.5F).build())				               
										        .backgroundColor(WHITE)
								                .textColor(Color.BLACK)
								                .font(fontMarathiBold).fontSize(9)				              
								                .horizontalAlignment(CENTER)
								                .build();
									}
									else
									{
										 itemDetails = Row.builder()
									                .add(TextCell.builder().text(informationDAO.getProductNameMarathi()).fontSize(9).horizontalAlignment(LEFT).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
									                .add(TextCell.builder().text(informationDAO.getQuantity()+" "+informationDAO.getSalesUnitShortName()).fontSize(8).horizontalAlignment(LEFT).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
									                .add(TextCell.builder().text(""+informationDAO.getSalesRate()).fontSize(9).horizontalAlignment(RIGHT).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
									                .add(TextCell.builder().text(""+informationDAO.getAmountAfterDiscount()).fontSize(9).horizontalAlignment(RIGHT).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
											        .backgroundColor(WHITE)
									                .textColor(Color.BLACK)
									                .font(fontMarathiBold).fontSize(9)				              
									                .horizontalAlignment(CENTER)
									                .build();
									}
							         tableItemInfoBuilder.addRow(itemDetails);
							        
							         
							         productListSize--;
								}
					         
								 itemInfo = tableItemInfoBuilder.build();
								 itemEndY = itemEndY - itemInfo.getHeight();	
								 TableBuilder tableBottomInfoBuilder = Table.builder()
							                .addColumnsOfWidth(70,50)				                
							                .font(HELVETICA)
							                .borderColor(Color.BLACK)
							                .horizontalAlignment(CENTER);
								  
							         
									  
								 Row itemTotalItemsInfo = null;
						          if(showTotalQuantity)
						          {
								  
							          itemTotalItemsInfo = Row.builder()
								                .add(TextCell.builder().text(",dw.k oLrw ").font(fontMarathiKrutiBold).fontSize(11).horizontalAlignment(LEFT).borderWidthTop(0.5F).borderWidthBottom(0.5F).borderWidthLeft(0.5F).borderWidthRight(0.5F).lineSpacing(2F).build())				               
								                .add(TextCell.builder().text(df.format(totalQuantity)).horizontalAlignment(RIGHT).borderWidthTop(0.5F).borderWidthBottom(0.5F).borderWidthLeft(0.5F).borderWidthRight(0.5F).lineSpacing(2F).build())				               
									            .backgroundColor(WHITE)
								                .textColor(Color.BLACK)
								                .font(fontMarathiBold)	
								                .fontSize(9)
								                .horizontalAlignment(CENTER)
								                .height(15F)
								                .build();
						          }
						          else
						          {
						        	  itemTotalItemsInfo = Row.builder()
								                .add(TextCell.builder().text(",dw.k oLrw ").font(fontMarathiKrutiBold).fontSize(11).horizontalAlignment(LEFT).borderWidthTop(0.5F).borderWidthBottom(0.5F).borderWidthLeft(0.5F).borderWidthRight(0.5F).lineSpacing(2F).build())				               
								                .add(TextCell.builder().text(""+listSize).horizontalAlignment(RIGHT).borderWidthTop(0.5F).borderWidthBottom(0.5F).borderWidthLeft(0.5F).borderWidthRight(0.5F).lineSpacing(2F).build())				               
									            .backgroundColor(WHITE)
								                .textColor(Color.BLACK)
								                .font(fontMarathiBold)	
								                .fontSize(9)
								                .horizontalAlignment(CENTER)
								                .height(15F)
								                .build();
						          }
								         Row itemTotalInfo = Row.builder()
									                .add(TextCell.builder().text("jDde").font(fontMarathiKrutiBold).fontSize(11).horizontalAlignment(LEFT).borderWidthLeft(0.5F).borderWidthRight(0.5F).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(2F).build())				               
									                .add(TextCell.builder().text("" +floatTotalAmtAfterDiscount).horizontalAlignment(RIGHT).borderWidthLeft(0.5F).borderWidthRight(0.5F).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(2F).build())				               
									                .backgroundColor(WHITE)
									                .textColor(Color.BLACK)
									                .font(fontMarathiBold)	
									                .fontSize(9)
									                .height(15F)
									                .horizontalAlignment(CENTER)
									                .build();
								         Row discountInfo = Row.builder()
									                .add(TextCell.builder().text(",dw.k cpr").font(fontMarathiKrutiBold).fontSize(11).horizontalAlignment(LEFT).borderWidthLeft(0.5F).borderWidthRight(0.5F).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(2F).build())				               
									                .add(TextCell.builder().text("" +floatTotalDiscount).horizontalAlignment(RIGHT).borderWidthLeft(0.5F).borderWidthRight(0.5F).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(2F).build())				               
										            .backgroundColor(WHITE)
									                .textColor(Color.BLACK)
									                .font(fontMarathiBold)
									                .fontSize(9)
									                .height(15F)
									                .horizontalAlignment(CENTER)
									                .build();
								    
								         
								       
								         tableBottomInfoBuilder.addRow(itemTotalItemsInfo);
								         tableBottomInfoBuilder.addRow(itemTotalInfo);
								       //  tableBottomInfoBuilder.addRow(discountInfo);
								      
								         bottomInfo = tableBottomInfoBuilder.build();
			        	  
			          }else
			          {
				         TableBuilder tableItemInfoBuilder = Table.builder()
					                .addColumnsOfWidth(70,40,40,45)				                
					                .font(HELVETICA)
					                .borderColor(Color.BLACK)
					                .horizontalAlignment(CENTER);
			          
				         Row itemInfoHeader = Row.builder()
					                .add(TextCell.builder().text("तपशील").fontSize(9).horizontalAlignment(LEFT).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
					                .add(TextCell.builder().text("QTY").fontSize(9).horizontalAlignment(LEFT).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
					                .add(TextCell.builder().text("दर").fontSize(9).horizontalAlignment(RIGHT).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
					                .add(TextCell.builder().text("रक्कम").fontSize(9).horizontalAlignment(RIGHT).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(0.5F).build())				               
							         
					                .backgroundColor(WHITE)
					                .textColor(Color.BLACK)
					                .font(fontMarathiBold).fontSize(10)				              
					                .horizontalAlignment(CENTER)
					                .build();
				       
				         tableItemInfoBuilder.addRow(itemInfoHeader);
				         Row itemDetails = null;
							for(BillProductInfoDAO informationDAO : productInfoList)
							{
								
								 
									
						         itemDetails = Row.builder()
							                .add(TextCell.builder().text(informationDAO.getProductNameMarathi()).fontSize(7).horizontalAlignment(LEFT).borderWidth(0.0F).lineSpacing(0.5F).build())				               
							                .add(TextCell.builder().text(informationDAO.getQuantity()+" "+informationDAO.getSalesUnitShortName()).fontSize(8).horizontalAlignment(LEFT).borderWidth(0F).lineSpacing(0.5F).build())				               
							                .add(TextCell.builder().text(""+informationDAO.getSalesRate()).fontSize(9).horizontalAlignment(RIGHT).borderWidth(0.0F).lineSpacing(0.5F).build())				               
							                .add(TextCell.builder().text(""+informationDAO.getAmountAfterDiscount()).fontSize(9).horizontalAlignment(RIGHT).borderWidth(0.0F).lineSpacing(0.5F).build())				               
									        .backgroundColor(WHITE)
							                .textColor(Color.BLACK)
							                .font(fontMarathiBold).fontSize(9)				              
							                .horizontalAlignment(CENTER)
							                .build();
						         
						      
						         
						         tableItemInfoBuilder.addRow(itemDetails);
						         
						        
						         
							}
							
							 itemInfo = tableItemInfoBuilder.build();
							 itemEndY = itemEndY - itemInfo.getHeight(); 
							    TableBuilder tableBottomInfoBuilder = Table.builder()
						                .addColumnsOfWidth(200)				                
						                .font(HELVETICA)
						                .borderColor(Color.BLACK)
						                .horizontalAlignment(CENTER);
							    Row itemTotalInfo = null;
								if(showTotalQuantity)
								{
									itemTotalInfo = Row.builder()
							                .add(TextCell.builder().text("एकूण वस्तू‚ :"+totalQuantity+"       |     रक्कम : " +floatTotalAmtAfterDiscount+"\u20B9").horizontalAlignment(CENTER).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(2F).build())				               
							                .backgroundColor(WHITE)
							                .textColor(Color.BLACK)
							                .font(fontMarathiBold)	
							                .fontSize(9)
							                .horizontalAlignment(CENTER)
							                .build();
									
								}
								else
								{
									itemTotalInfo = Row.builder()
							                .add(TextCell.builder().text("एकूण नग‚ :"+listSize+"       |     रक्कम : " +floatTotalAmtAfterDiscount+"\u20B9").horizontalAlignment(CENTER).borderWidthTop(0.5F).borderWidthBottom(0.5F).lineSpacing(2F).build())				               
							                .backgroundColor(WHITE)
							                .textColor(Color.BLACK)
							                .font(fontMarathiBold)	
							                .fontSize(9)
							                .horizontalAlignment(CENTER)
							                .build();
								}
					         
					     
					         
					     
					         
					         tableBottomInfoBuilder.addRow(itemTotalInfo);
					      
					         bottomInfo = tableBottomInfoBuilder.build();
					       
			          }
			          
		          }
			   
				String addBillMessage = shopSettingsMap.get("add_message_to_bill");
				 Table billMessageTable = null;
			       if(addBillMessage.equals("TRUE"))
			       {
			    	   String billMessage = shopSettingsMap.get("bill_message");
			    	   
			    	  
			    	   
			    	   TableBuilder tableBillMessageTableBuilder = Table.builder()
				                .addColumnsOfWidth(200)				                
				                .font(HELVETICA)
				                .borderColor(Color.BLACK)
				                .horizontalAlignment(CENTER);
			    	   
			    	   
			    	   Row messageInfoRow1 = null;
			    	   if(billMessageFont.equals("NIRMALA"))
			    	   {
			    	   
				    	    messageInfoRow1 = Row.builder()
					                .add(TextCell.builder().text(billMessage).horizontalAlignment(CENTER).borderWidthTop(0.5F).lineSpacing(0.5F).build())				               
					                .backgroundColor(WHITE)
					                .textColor(Color.BLACK)
					                .font(fontMarathiBold)
					                .height(25F)
					                .fontSize(12)				              
					                .horizontalAlignment(CENTER)
					                .build();
				    	  
			    	   }
			    	   else
			    	   {
			    		    messageInfoRow1 = Row.builder()
					                .add(TextCell.builder().text(billMessage).horizontalAlignment(CENTER).borderWidthTop(0.5F).lineSpacing(0.5F).build())				               
					                .backgroundColor(WHITE)
					                .textColor(Color.BLACK)
					                .font(fontMarathiKrutiBold)
					                .height(25F)
					                .fontSize(12)				              
					                .horizontalAlignment(CENTER)
					                .build();
				    	  
			    	   }
			    	   tableBillMessageTableBuilder.addRow(messageInfoRow1);
			    	   billMessageTable = tableBillMessageTableBuilder.build();
			        
			       }
		          
		          Table conmpanyInfo;
		          
		         TableBuilder tableCompanyInfoBuilder = Table.builder()
			                .addColumnsOfWidth(200)				                
			                .font(HELVETICA)
			                .borderColor(Color.BLACK)
			                .horizontalAlignment(CENTER);
		         
		         Row companyInfoRow1 = Row.builder()
			                .add(TextCell.builder().text("Developed By: Real Link Infotech:8208064913").horizontalAlignment(CENTER).borderWidthTop(0.5F).lineSpacing(0.5F).build())				               
			                .backgroundColor(WHITE)
			                .textColor(Color.BLACK)
			                .font(fontMarathiBold).fontSize(8)				              
			                .horizontalAlignment(CENTER)
			                .build();
		         tableCompanyInfoBuilder.addRow(companyInfoRow1);
		         
		         conmpanyInfo = tableCompanyInfoBuilder.build();
		        
		         
		        
		           TableDrawer.builder()
	                .contentStream(contentStream)
	                .table(itemInfo)
	                .startX(10F)
	                .startY(currectY)
	                .build()
	                .draw();
		       
		         
		        
		         if(addQRCode)
		         {
		        	 
		        	 TableDrawer.builder()
		                .contentStream(contentStream)
		                .table(bottomInfo)
		                .startX(75F)
		                .startY(itemEndY)
		                .build()
		                .draw();
		        	 if(pdImageQRCode != null)
		        	 {
		        		 contentStream.drawImage(pdImageQRCode, 15, itemEndY-50, 50, 50);
		        	 }
		        	 if(addBillMessage.equals("TRUE"))
				       {
		        		 itemEndY = itemEndY - 55; 
		        		  TableDrawer.builder()
			                .contentStream(contentStream)
			                .table(billMessageTable)
			                .startX(0F)
			                .startY(itemEndY)
			                .build()
			                .draw();
		        		  itemEndY = itemEndY - 25;
		        		  
				       }else
				       {
				    	   itemEndY = itemEndY - 55;
				       }
		        	 
			         TableDrawer.builder()
		                .contentStream(contentStream)
		                .table(conmpanyInfo)
		                .startX(5F)
		                .startY(itemEndY)
		                .build()
		                .draw();
		         }
		         else
		         {
		        	
		        	 itemEndY = itemEndY -5;
		        	 TableDrawer.builder()
		                .contentStream(contentStream)
		                .table(bottomInfo)
		                .startX(5F)
		                .startY(itemEndY)
		                .build()
		                .draw();
		        	 
		        	 	if(addBillMessage.equals("TRUE"))
				       {
		        	 		  itemEndY = itemEndY - 25;
		        		 
		        		  TableDrawer.builder()
			                .contentStream(contentStream)
			                .table(billMessageTable)
			                .startX(5F)
			                .startY(itemEndY)
			                .build()
			                .draw();
		        		  itemEndY = itemEndY - 25;
		        		  
				       }else
				       {
				    	   itemEndY = itemEndY - 35;
				       }
		        	
			         TableDrawer.builder()
		                .contentStream(contentStream)
		                .table(conmpanyInfo)
		                .startX(5F)
		                .startY(itemEndY)
		                .build()
		                .draw();
		         }
		         
		        
		         
		      
		         contentStream.close();
				 	document.save(path+"/bill.pdf");
			        document.close();
			        
			        

					response.setHeader("Content-disposition", "inline; filename=bill.pdf");
					response.setContentType("application/pdf");
					FileInputStream fileInputStream = new FileInputStream(path+"/bill.pdf");
					PrintWriter outFile = response.getWriter();  
					int bytes;
					while ((bytes = fileInputStream.read()) != -1) {
						outFile.write(bytes);
					}
					fileInputStream.close();
					outFile.flush();
					outFile.close();
					ttf1.close();
					ttf2.close();
					ttf3.close();
					
				}
		         
         if((this.getBillInfoDAO().getBillType().equals("QUOTATION") || this.getBillInfoDAO().getBillType().equals("ESTIMATE")) && this.getLanguage().equals("ENGLISH"))
			{
        	 String docTypeLabel = this.getBillInfoDAO().getBillType().equals("ESTIMATE") ? "ESTIMATE" : "QUOTATION";
        	 String docNameLabel = this.getBillInfoDAO().getBillType().equals("ESTIMATE") ? "Estimate" : "Quotation";
        	 

	        	
	        	String custMobile = "";
	        	String custAddress = "";
	        	
	        	if(resultSet != null)
	        	{
	        		resultSet.close();
	        		resultSet = null;
	        	}
	        	
	        	if(preparedStatement != null)
	        	{
	        		preparedStatement.close();
	        		preparedStatement = null;
	        	}
	        	
	        	
	        	sql = "SELECT "
	        			+ "mobile_number,"
	        			+ "billing_address "
	        			+ "FROM "
	        			+ "shop_customer_master "
	        			+ "WHERE "
	        			+ "customer_name = ? "
	        			+ "AND "
	        			+ "customer_id = ? "
	        			+ "AND "
	        			+ "shop_id = ? "
	        			+ "AND "
	        			+ "shop_code = ?";
	        	
	        	preparedStatement = connection.prepareStatement(sql);
	        	preparedStatement.setString(1, this.getBillInfoDAO().getCustomerName());
	        	preparedStatement.setString(2, this.getBillInfoDAO().getCustId());
	        	preparedStatement.setString(3, shopId);
	        	preparedStatement.setString(4, shopCode);
	        	
	        	resultSet = preparedStatement.executeQuery();
	        	
	        	while(resultSet.next())
	        	{
	        		custMobile = resultSet.getString(1);
	        		custAddress = resultSet.getString(2);
	        	}
	        	
	        	
	        	PDDocument document = new PDDocument(); 
				PDPage page = null;
				
				// + (listSize*20) + 20
			
				 page = new PDPage(PDRectangle.A4);
				 
				 document.addPage(page);
				 
					
				 File fontFile  =  new File( request.getSession().getServletContext().getRealPath("/fonts/Nirmala.ttf"));
				 File fontFileBold  =  new File( request.getSession().getServletContext().getRealPath("/fonts/nirmala-bold.ttf"));
				 
				 TrueTypeFont ttf1 = new TTFParser().parse(fontFile);
				 PDFont fontMarathi = PDType0Font.load(document, ttf1, true);
				 
				 TrueTypeFont ttf2 = new TTFParser().parse(fontFileBold);
				 PDFont fontMarathiBold = PDType0Font.load(document, ttf2, true);
				 
		         PDPageContentStream contentStream = new PDPageContentStream(document, page);
      
      Table header;
      Table billInfoTable;
      Table custInfoTable;
      Table itemInfo;
      
      
      TableBuilder tableHeaderBuilder = Table.builder()
	                .addColumnsOfWidth(550)				                
	                .font(HELVETICA)
	                .borderColor(Color.BLACK)
	                .horizontalAlignment(CENTER);
      
      Row billType = Row.builder()
	                .add(TextCell.builder().text(docTypeLabel).fontSize(10).horizontalAlignment(CENTER).borderWidth(0.0F).lineSpacing(1F).build())				               
	                .backgroundColor(WHITE)
	                .font(PDType1Font.HELVETICA_BOLD)	
	                .textColor(Color.BLACK)
	                .build();
      
      Row headerRow  = Row.builder()
	                .add(TextCell.builder().text(this.getHeaderShopName()).fontSize(24).horizontalAlignment(CENTER).borderWidth(0.0F).lineSpacing(1F).build())				               
	                .backgroundColor(WHITE)
	                .font(PDType1Font.HELVETICA_BOLD)	
	                .textColor(Color.BLACK)
	                .build();
      
      Row addressRow  = Row.builder()
	                .add(TextCell.builder().text((String)this.getSessionMap().get("shopaddresseng")).fontSize(10).horizontalAlignment(CENTER).borderWidth(0.0F).lineSpacing(1F).build())				               
	                .backgroundColor(WHITE)
	                .font(PDType1Font.HELVETICA_BOLD)	
	                .textColor(Color.BLACK)
	                .build();
      
      Row mobileRow  = Row.builder()
	                .add(TextCell.builder().text((String)this.getSessionMap().get("shopcustcarenumber")).fontSize(10).horizontalAlignment(CENTER).borderWidthBottom(1.0F).lineSpacing(1F).build())				               
	                .backgroundColor(WHITE)
	                .font(PDType1Font.HELVETICA_BOLD)	
	                .textColor(Color.BLACK)
	                .build();
      
      tableHeaderBuilder.addRow(billType);
      
      tableHeaderBuilder.addRow(headerRow);
      tableHeaderBuilder.addRow(addressRow);
      tableHeaderBuilder.addRow(mobileRow);
      
      header = tableHeaderBuilder.build();
      
      float startY = page.getMediaBox().getHeight() - PADDING20;
      TableDrawer.builder()
         .contentStream(contentStream)
         .table(header)
         .startX(PADDING20)
         .startY(startY)
         .build()
         .draw();
      
      TableBuilder tableBillInfoBuilder = Table.builder()
	                .addColumnsOfWidth(136,136,138,138)				                
	                .font(HELVETICA)
	                .borderColor(Color.BLACK)
	                .horizontalAlignment(CENTER);
      
      
      Row billInfoRow1  = Row.builder()
	                .add(TextCell.builder().text(docNameLabel+" Number").fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
	                .add(TextCell.builder().text(this.getBillNumber()).fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
	                .add(TextCell.builder().text(docNameLabel+" Date").fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
	                .add(TextCell.builder().text(this.getBillInfoDAO().getBillDate()).fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
				    .backgroundColor(WHITE)
	                .font(PDType1Font.HELVETICA_BOLD)	
	                .textColor(Color.BLACK)
	                .build();
      
      
      Row billInfoRow2  = Row.builder()
	                .add(TextCell.builder().text(docNameLabel+" By").fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
	                .add(TextCell.builder().text(this.getBillInfoDAO().getBilledBy()).fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
	                .add(TextCell.builder().text("Payment Type").fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
	                .add(TextCell.builder().text(this.getBillInfoDAO().getPaymentType()).fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
				    .backgroundColor(WHITE)
	                .font(PDType1Font.HELVETICA_BOLD)	
	                .textColor(Color.BLACK)
	                .build();
      
      tableBillInfoBuilder.addRow(billInfoRow1);
      tableBillInfoBuilder.addRow(billInfoRow2);
      
      billInfoTable = tableBillInfoBuilder.build();
      
      
      float currentY = startY - 80;
      
      TableDrawer.builder()
      .contentStream(contentStream)
      .table(billInfoTable)
      .startX(PADDING20)
      .startY(currentY)
      .build()
      .draw();
      
      
      TableBuilder tableCustInfoBuilder = Table.builder()
	                .addColumnsOfWidth(550);
      
      Row custInfoRow1 = Row.builder()
	                .add(TextCell.builder().text("Customer Name : "+this.getBillInfoDAO().getCustomerName()).fontSize(10).horizontalAlignment(LEFT).borderWidthBottom(1.0F).lineSpacing(1F).build())				               
	                .backgroundColor(WHITE)
	                .font(PDType1Font.HELVETICA_BOLD)	
	                .textColor(Color.BLACK)
	                .build();
      Row custInfoRow2 = Row.builder()
	                .add(TextCell.builder().text("Mobile : "+custMobile).fontSize(10).horizontalAlignment(LEFT).borderWidthBottom(1.0F).lineSpacing(1F).build())				               
	                .backgroundColor(WHITE)
	                .font(PDType1Font.HELVETICA_BOLD)	
	                .textColor(Color.BLACK)
	                .build();
      Row custInfoRow3 = Row.builder()
	                .add(TextCell.builder().text("Address : "+custAddress).fontSize(10).horizontalAlignment(LEFT).borderWidthBottom(1.0F).lineSpacing(1F).build())				               
	                .backgroundColor(WHITE)
	                .font(PDType1Font.HELVETICA_BOLD)	
	                .textColor(Color.BLACK)
	                .build();
      
 
      
      tableCustInfoBuilder.addRow(custInfoRow1);
      tableCustInfoBuilder.addRow(custInfoRow2);
      tableCustInfoBuilder.addRow(custInfoRow3);
      
      custInfoTable = tableCustInfoBuilder.build();
      

      currentY = currentY - 50;
      
      
      
      TableDrawer.builder()
      .contentStream(contentStream)
      .table(custInfoTable)
      .startX(PADDING20)
      .startY(currentY)
      .build()
      .draw();
      
      TableBuilder tableItemInfoBuilder = Table.builder()
	                .addColumnsOfWidth(50,250,80,80,100);
      
      
      Row inteInfoHeaderRow = Row.builder()
	                .add(TextCell.builder().text("Sr No").fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
	                .add(TextCell.builder().text("Items").fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
	                .add(TextCell.builder().text("Rate").fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
	                .add(TextCell.builder().text("Quantity").fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
		            .add(TextCell.builder().text("Amount").fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
	                .backgroundColor(GRAY_LIGHT_3)
	                .font(PDType1Font.HELVETICA_BOLD)	
	                .textColor(Color.BLACK)
	                .build();
      
      tableItemInfoBuilder.addRow(inteInfoHeaderRow);
      
   

      int srNo = 1;
      int pageCount = 1;
  	for(int i =0;i<listSize;i++)
			{
  		
  		//System.out.println("Starting Current Y :"+currentY);
				Row itemDetails = null;
				
				if(currentY  < 260)
				{
					
					Row toBeContinue =  Row.builder()
		        		 	.add(TextCell.builder().text("Page No."+pageCount+", To be continued on next page...").colSpan(5).fontSize(9).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(1F).build())				               
		        		 	.textColor(Color.BLACK)
			                .height(20F)
			                .font(fontMarathi)
			                .build();
					pageCount++;
					
					tableItemInfoBuilder.addRow(toBeContinue);
				
					itemInfo = tableItemInfoBuilder.build();
					
					 TableDrawer.builder()
		             .contentStream(contentStream)
		             .table(itemInfo)
		             .startX(PADDING20)
		             .startY(currentY+380)
		             .build()
		             .draw();
					
					 contentStream.close();
					 contentStream = null;
			        	PDPage newPage = new PDPage(PDRectangle.A4);
			        	 
			        	 contentStream = new PDPageContentStream(document,newPage);
			        	currentY = 20.0F;
			             document.addPage( newPage );
			             
				          startY = newPage.getMediaBox().getHeight() - PADDING20;
			             TableDrawer.builder()
			                .contentStream(contentStream)
			                .table(header)
			                .startX(PADDING20)
			                .startY(startY)
			                .build()
			                .draw();
			             
			             
				         currentY = startY - 80;
				         
				         TableDrawer.builder()
			             .contentStream(contentStream)
			             .table(billInfoTable)
			             .startX(PADDING20)
			             .startY(currentY)
			             .build()
			             .draw();
				         
				         currentY = currentY - 50;
				         
				         
				         TableDrawer.builder()
			             .contentStream(contentStream)
			             .table(custInfoTable)
			             .startX(PADDING20)
			             .startY(currentY)
			             .build()
			             .draw();
				         
				         itemInfo = null;
				         tableItemInfoBuilder = null;
				         
				         tableItemInfoBuilder = Table.builder()
				        		 .addColumnsOfWidth(50,250,80,80,100);
				         
				       
				         
				         tableItemInfoBuilder.addRow(inteInfoHeaderRow);
				}
				
				
					BillProductInfoDAO informationDAO = this.getProductInfoList().get(i);
				
					if(informationDAO != null)
					{
					
						
			         itemDetails = Row.builder()
			        		 	.add(TextCell.builder().text(""+srNo).fontSize(9).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())				               
			        		 	.add(TextCell.builder().text(informationDAO.getProductName()).fontSize(8).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				               
				                .add(TextCell.builder().text(""+informationDAO.getSalesRate()).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(1F).build())				               
				                .add(TextCell.builder().text(""+informationDAO.getQuantity()+" "+informationDAO.getSalesUnitShortName()).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(1F).build())				               
					            .add(TextCell.builder().text(""+informationDAO.getAmountAfterDiscount()).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(1F).build())				               
						        .backgroundColor(WHITE)
				                .textColor(Color.BLACK)
				                .height(20F)
				                .font(fontMarathi).fontSize(12)				              
				                .horizontalAlignment(CENTER)
				                .build();
			         srNo++;
					}
					else
					{
			         itemDetails = Row.builder()
			        		 	.add(TextCell.builder().text("").fontSize(9).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				               
			        		 	.add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				               
			        			.add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				               
					     	    .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				               
					            .add(TextCell.builder().text("").horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(1F).build())				               
						        .backgroundColor(WHITE)
				                .textColor(Color.BLACK)
				                .height(20F)
				                .font(fontMarathi).fontSize(12)				              
				                .horizontalAlignment(CENTER)
				                .build();
					}
				
		         tableItemInfoBuilder.addRow(itemDetails);
		        
		         currentY = (float) (currentY - 20.0F);
				//System.out.println("Inner : "+currentY);
				
			}
			
			
			Row totalInfoRow = Row.builder()
	        		 	.add(TextCell.builder().text("Total Bill Amount").colSpan(4).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(1F).build())				               
	        		 	.add(TextCell.builder().text(df.format(floatTotalAmtAfterDiscount)).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(1F).build())				               
	        		 	.backgroundColor(WHITE)
		                .textColor(Color.BLACK)
		                .height(20F)
		                .font(fontMarathiBold).fontSize(12)				              
		                .horizontalAlignment(CENTER)
		                .build();
			tableItemInfoBuilder.addRow(totalInfoRow);
			
			
			 if(addCustomerCreditAmountToBill)
	         {
	        	 float custCreditAmount = GetCustomerCreditAmountById.getCustomerCreditAmountById(this.getBillInfoDAO().getCustId(), this.getSessionMap());
	        	 Row totalDetailsRow2 = Row.builder()
			                .add(TextCell.builder().text("Total OutStanding Amount").colSpan(4).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(0.5F).build())				                
			                .add(TextCell.builder().text(df.format(custCreditAmount)).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(0.5F).build())
			                .backgroundColor(Color.WHITE)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD)
			                .fontSize(12)				              
			                .horizontalAlignment(CENTER)
			                .height(20F)	
			                .build();
	        	 tableItemInfoBuilder.addRow(totalDetailsRow2);
	         }
			
			  String convertedAmount = new NumberToWordsConverter().getConverted(""+floatTotalAmtAfterDiscount);
	      
			  Row amtInwordsRow = Row.builder()
	        		 	.add(TextCell.builder().text("Amount in Words : "+convertedAmount).colSpan(5).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				               
	        		 	.backgroundColor(WHITE)
		                .textColor(Color.BLACK)
		                .height(20F)
		                .font(fontMarathi).fontSize(12)				              
		                .horizontalAlignment(CENTER)
		                .build();
			tableItemInfoBuilder.addRow(amtInwordsRow);
			
			Row commentsRow = Row.builder()
     		 	.add(TextCell.builder().text("Comments:"+this.getBillInfoDAO().getComments()).colSpan(5).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				               
     		 	.backgroundColor(WHITE)
	                .textColor(Color.BLACK)
	                .height(15F)
	                .font(fontMarathi).fontSize(9)				              
	                .horizontalAlignment(LEFT)
	                .build();
		tableItemInfoBuilder.addRow(commentsRow);
      
      itemInfo = tableItemInfoBuilder.build();
      
      
      TableBuilder signatureBuiler = Table.builder()
	                .addColumnsOfWidth(275,275)				                
	                .font(HELVETICA)
	                .borderColor(Color.BLACK)
	                .horizontalAlignment(CENTER);
      
      
      Row signRow1 = Row.builder()
	                .add(TextCell.builder().text("Receiver Signature").verticalAlignment(BOTTOM).horizontalAlignment(CENTER).borderWidth(0).lineSpacing(10F).build())
	                .add(TextCell.builder().text("Authorized Signature").verticalAlignment(BOTTOM).horizontalAlignment(CENTER).borderWidth(0).lineSpacing(10F).build())					               
	                .backgroundColor(Color.WHITE)
	                .textColor(Color.BLACK)
	                .font(PDType1Font.HELVETICA_BOLD)
	                .fontSize(9)				              
	                .horizontalAlignment(CENTER)
	                .height(20F)	
	                .build();
      signatureBuiler.addRow(signRow1);
    
      
      Table signature = signatureBuiler.build();   
      
     
      float currentY2 = currentY;
      itemInfo = tableItemInfoBuilder.build();
      
     	float startY2 = page.getMediaBox().getHeight() - PADDING20;
     	currentY = startY2 - 190 ; 
     
		 TableDrawer.builder()
      .contentStream(contentStream)
      .table(itemInfo)
      .startX(PADDING20)
      .startY(currentY)
      .build()
      .draw();
		
     
  
      
      TableDrawer.builder()
      .contentStream(contentStream)
      .table(signature)
      .startX(PADDING20)
      .startY(currentY2-270)
      .build()
      .draw();
      
      
      	contentStream.close();
		 	document.save(path+"/bill.pdf");
	        document.close();
	        
	        

			response.setHeader("Content-disposition", "inline; filename=bill.pdf");
			response.setContentType("application/pdf");
			FileInputStream fileInputStream = new FileInputStream(path+"/bill.pdf");
			PrintWriter out = response.getWriter();  
			int bytes;
			while ((bytes = fileInputStream.read()) != -1) {
				out.write(bytes);
			}
			fileInputStream.close();
			out.flush();
			out.close();
			ttf1.close();
			ttf2.close();
		
      
     
			
			}
		         
		        if(this.getBillInfoDAO().getBillType().equals("BILL-OF-SUPPLY") || this.getBillInfoDAO().getBillType().equals("COMPOSITE-BILL"))
				{
		        	
		        	String custMobile = "";
		        	String custAddress = "";
		        	
		        	if(resultSet != null)
		        	{
		        		resultSet.close();
		        		resultSet = null;
		        	}
		        	
		        	if(preparedStatement != null)
		        	{
		        		preparedStatement.close();
		        		preparedStatement = null;
		        	}
		        	
		        	
		        	sql = "SELECT "
		        			+ "mobile_number,"
		        			+ "billing_address "
		        			+ "FROM "
		        			+ "shop_customer_master "
		        			+ "WHERE "
		        			+ "customer_name = ? "
		        			+ "AND "
		        			+ "customer_id = ? "
		        			+ "AND "
		        			+ "shop_id = ? "
		        			+ "AND "
		        			+ "shop_code = ?";
		        	
		        	preparedStatement = connection.prepareStatement(sql);
		        	preparedStatement.setString(1, this.getBillInfoDAO().getCustomerName());
		        	preparedStatement.setString(2, this.getBillInfoDAO().getCustId());
		        	preparedStatement.setString(3, shopId);
		        	preparedStatement.setString(4, shopCode);
		        	
		        	resultSet = preparedStatement.executeQuery();
		        	
		        	while(resultSet.next())
		        	{
		        		custMobile = resultSet.getString(1);
		        		custAddress = resultSet.getString(2);
		        	}
		        	
		        	
		        	PDDocument document = new PDDocument(); 
					PDPage page = null;
					
					// + (listSize*20) + 20
				
					 page = new PDPage(PDRectangle.A4);
					 
					 document.addPage(page);
					 
						
					 File fontFile  =  new File( request.getSession().getServletContext().getRealPath("/fonts/Nirmala.ttf"));
					 File fontFileBold  =  new File( request.getSession().getServletContext().getRealPath("/fonts/nirmala-bold.ttf"));
					 
					 TrueTypeFont ttf1 = new TTFParser().parse(fontFile);
					 PDFont fontMarathi = PDType0Font.load(document, ttf1, true);
					 
					 TrueTypeFont ttf2 = new TTFParser().parse(fontFileBold);
					 PDFont fontMarathiBold = PDType0Font.load(document, ttf2, true);
					 
			         PDPageContentStream contentStream = new PDPageContentStream(document, page);
	         
	         Table header;
	         Table billInfoTable;
	         Table custInfoTable;
	         Table itemInfo;
	         
	         
	         TableBuilder tableHeaderBuilder = Table.builder()
		                .addColumnsOfWidth(550)				                
		                .font(HELVETICA)
		                .borderColor(Color.BLACK)
		                .horizontalAlignment(CENTER);
	         
	         Row billType = Row.builder()
		                .add(TextCell.builder().text("BILL-OF-SUPPLY").fontSize(10).horizontalAlignment(CENTER).borderWidth(0.0F).lineSpacing(1F).build())				               
		                .backgroundColor(WHITE)
		                .font(PDType1Font.HELVETICA_BOLD)	
		                .textColor(Color.BLACK)
		                .build();
	         
	         Row headerRow  = Row.builder()
		                .add(TextCell.builder().text(this.getHeaderShopName()).fontSize(24).horizontalAlignment(CENTER).borderWidth(0.0F).lineSpacing(1F).build())				               
		                .backgroundColor(WHITE)
		                .font(PDType1Font.HELVETICA_BOLD)	
		                .textColor(Color.BLACK)
		                .build();
	         
	         Row addressRow  = Row.builder()
		                .add(TextCell.builder().text((String)this.getSessionMap().get("shopaddresseng")).fontSize(10).horizontalAlignment(CENTER).borderWidth(0.0F).lineSpacing(1F).build())				               
		                .backgroundColor(WHITE)
		                .font(PDType1Font.HELVETICA_BOLD)	
		                .textColor(Color.BLACK)
		                .build();
	         
	         Row mobileRow  = Row.builder()
		                .add(TextCell.builder().text((String)this.getSessionMap().get("shopcustcarenumber")).fontSize(10).horizontalAlignment(CENTER).borderWidthBottom(1.0F).lineSpacing(1F).build())				               
		                .backgroundColor(WHITE)
		                .font(PDType1Font.HELVETICA_BOLD)	
		                .textColor(Color.BLACK)
		                .build();
	         
	         tableHeaderBuilder.addRow(billType);
	         
	         tableHeaderBuilder.addRow(headerRow);
	         tableHeaderBuilder.addRow(addressRow);
	         tableHeaderBuilder.addRow(mobileRow);
	         
	         header = tableHeaderBuilder.build();
	         
	         float startY = page.getMediaBox().getHeight() - PADDING20;
	         TableDrawer.builder()
                .contentStream(contentStream)
                .table(header)
                .startX(PADDING20)
                .startY(startY)
                .build()
                .draw();
	         
	         TableBuilder tableBillInfoBuilder = Table.builder()
		                .addColumnsOfWidth(136,136,138,138)				                
		                .font(HELVETICA)
		                .borderColor(Color.BLACK)
		                .horizontalAlignment(CENTER);
	         
	         
	         Row billInfoRow1  = Row.builder()
		                .add(TextCell.builder().text("Bill Number").fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
		                .add(TextCell.builder().text(this.getBillNumber()).fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
		                .add(TextCell.builder().text("Bill Date").fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
		                .add(TextCell.builder().text(this.getBillInfoDAO().getBillDate()).fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
					    .backgroundColor(WHITE)
		                .font(PDType1Font.HELVETICA_BOLD)	
		                .textColor(Color.BLACK)
		                .build();
	         
	         
	         Row billInfoRow2  = Row.builder()
		                .add(TextCell.builder().text("Billed By").fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
		                .add(TextCell.builder().text(this.getBillInfoDAO().getBilledBy()).fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
		                .add(TextCell.builder().text("Payment Type").fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
		                .add(TextCell.builder().text(this.getBillInfoDAO().getPaymentType()).fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
					    .backgroundColor(WHITE)
		                .font(PDType1Font.HELVETICA_BOLD)	
		                .textColor(Color.BLACK)
		                .build();
	         
	         tableBillInfoBuilder.addRow(billInfoRow1);
	         tableBillInfoBuilder.addRow(billInfoRow2);
	         
	         billInfoTable = tableBillInfoBuilder.build();
	         
	         
	         float currentY = startY - 80;
	         
	         TableDrawer.builder()
             .contentStream(contentStream)
             .table(billInfoTable)
             .startX(PADDING20)
             .startY(currentY)
             .build()
             .draw();
	         
	         
	         TableBuilder tableCustInfoBuilder = Table.builder()
		                .addColumnsOfWidth(550);
	         
	         Row custInfoRow1 = Row.builder()
		                .add(TextCell.builder().text("Customer Name : "+this.getBillInfoDAO().getCustomerName()).fontSize(10).horizontalAlignment(LEFT).borderWidthBottom(1.0F).lineSpacing(1F).build())				               
		                .backgroundColor(WHITE)
		                .font(PDType1Font.HELVETICA_BOLD)	
		                .textColor(Color.BLACK)
		                .build();
	         Row custInfoRow2 = Row.builder()
		                .add(TextCell.builder().text("Mobile : "+custMobile).fontSize(10).horizontalAlignment(LEFT).borderWidthBottom(1.0F).lineSpacing(1F).build())				               
		                .backgroundColor(WHITE)
		                .font(PDType1Font.HELVETICA_BOLD)	
		                .textColor(Color.BLACK)
		                .build();
	         Row custInfoRow3 = Row.builder()
		                .add(TextCell.builder().text("Address : "+custAddress).fontSize(10).horizontalAlignment(LEFT).borderWidthBottom(1.0F).lineSpacing(1F).build())				               
		                .backgroundColor(WHITE)
		                .font(PDType1Font.HELVETICA_BOLD)	
		                .textColor(Color.BLACK)
		                .build();
	         
	    
	         
	         tableCustInfoBuilder.addRow(custInfoRow1);
	         tableCustInfoBuilder.addRow(custInfoRow2);
	         tableCustInfoBuilder.addRow(custInfoRow3);
	         
	         custInfoTable = tableCustInfoBuilder.build();
	         

	         currentY = currentY - 50;
	         
	         
	         
	         TableDrawer.builder()
             .contentStream(contentStream)
             .table(custInfoTable)
             .startX(PADDING20)
             .startY(currentY)
             .build()
             .draw();
	         
	         TableBuilder tableItemInfoBuilder = Table.builder()
		                .addColumnsOfWidth(50,250,80,80,100);
	         
	         
	         Row inteInfoHeaderRow = Row.builder()
		                .add(TextCell.builder().text("Sr No").fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
		                .add(TextCell.builder().text("Items").fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
		                .add(TextCell.builder().text("Rate").fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
		                .add(TextCell.builder().text("Quantity").fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
			            .add(TextCell.builder().text("Amount").fontSize(10).horizontalAlignment(LEFT).borderWidth(1.0F).lineSpacing(1F).build())				               
		                .backgroundColor(GRAY_LIGHT_3)
		                .font(PDType1Font.HELVETICA_BOLD)	
		                .textColor(Color.BLACK)
		                .build();
	         
	         tableItemInfoBuilder.addRow(inteInfoHeaderRow);
	         
	      

	         int srNo = 1;
	         int pageCount = 1;
	     	for(int i =0;i<listSize;i++)
				{
	     		
	     		//System.out.println("Starting Current Y :"+currentY);
					Row itemDetails = null;
					
					if(currentY  < 260)
					{
						
						Row toBeContinue =  Row.builder()
			        		 	.add(TextCell.builder().text("Page No."+pageCount+", To be continued on next page...").colSpan(5).fontSize(9).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(1F).build())				               
			        		 	.textColor(Color.BLACK)
				                .height(20F)
				                .font(fontMarathi)
				                .build();
						pageCount++;
						
						tableItemInfoBuilder.addRow(toBeContinue);
					
						itemInfo = tableItemInfoBuilder.build();
						
						 TableDrawer.builder()
			             .contentStream(contentStream)
			             .table(itemInfo)
			             .startX(PADDING20)
			             .startY(currentY+380)
			             .build()
			             .draw();
						
						 contentStream.close();
						 contentStream = null;
				        	PDPage newPage = new PDPage(PDRectangle.A4);
				        	 
				        	 contentStream = new PDPageContentStream(document,newPage);
				        	currentY = 20.0F;
				             document.addPage( newPage );
				             
					          startY = newPage.getMediaBox().getHeight() - PADDING20;
				             TableDrawer.builder()
				                .contentStream(contentStream)
				                .table(header)
				                .startX(PADDING20)
				                .startY(startY)
				                .build()
				                .draw();
				             
				             
					         currentY = startY - 80;
					         
					         TableDrawer.builder()
				             .contentStream(contentStream)
				             .table(billInfoTable)
				             .startX(PADDING20)
				             .startY(currentY)
				             .build()
				             .draw();
					         
					         currentY = currentY - 50;
					         
					         
					         TableDrawer.builder()
				             .contentStream(contentStream)
				             .table(custInfoTable)
				             .startX(PADDING20)
				             .startY(currentY)
				             .build()
				             .draw();
					         
					         itemInfo = null;
					         tableItemInfoBuilder = null;
					         
					         tableItemInfoBuilder = Table.builder()
					        		 .addColumnsOfWidth(50,250,80,80,100);
					         
					       
					         
					         tableItemInfoBuilder.addRow(inteInfoHeaderRow);
					}
					
					
						BillProductInfoDAO informationDAO = this.getProductInfoList().get(i);
					
						if(informationDAO != null)
						{
						
							
				         itemDetails = Row.builder()
				        		 	.add(TextCell.builder().text(""+srNo).fontSize(9).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())				               
				        		 	.add(TextCell.builder().text(informationDAO.getProductName()).fontSize(8).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				               
					                .add(TextCell.builder().text(""+informationDAO.getSalesRate()).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(1F).build())				               
					                .add(TextCell.builder().text(""+informationDAO.getQuantity()+" "+informationDAO.getSalesUnitShortName()).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(1F).build())				               
						            .add(TextCell.builder().text(""+informationDAO.getAmountAfterDiscount()).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(1F).build())				               
							        .backgroundColor(WHITE)
					                .textColor(Color.BLACK)
					                .height(20F)
					                .font(fontMarathi).fontSize(12)				              
					                .horizontalAlignment(CENTER)
					                .build();
				         srNo++;
						}
						else
						{
				         itemDetails = Row.builder()
				        		 	.add(TextCell.builder().text("").fontSize(9).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				               
				        		 	.add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				               
				        			.add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				               
						     	    .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				               
						            .add(TextCell.builder().text("").horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(1F).build())				               
							        .backgroundColor(WHITE)
					                .textColor(Color.BLACK)
					                .height(20F)
					                .font(fontMarathi).fontSize(12)				              
					                .horizontalAlignment(CENTER)
					                .build();
						}
					
			         tableItemInfoBuilder.addRow(itemDetails);
			        
			         currentY = (float) (currentY - 20.0F);
					//System.out.println("Inner : "+currentY);
					
				}
				
				
				Row totalInfoRow = Row.builder()
		        		 	.add(TextCell.builder().text("Total Bill Amount").colSpan(4).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(1F).build())				               
		        		 	.add(TextCell.builder().text(df.format(floatTotalAmtAfterDiscount)).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(1F).build())				               
		        		 	.backgroundColor(WHITE)
			                .textColor(Color.BLACK)
			                .height(20F)
			                .font(fontMarathiBold).fontSize(12)				              
			                .horizontalAlignment(CENTER)
			                .build();
				tableItemInfoBuilder.addRow(totalInfoRow);
				
				
				 if(addCustomerCreditAmountToBill)
		         {
		        	 float custCreditAmount = GetCustomerCreditAmountById.getCustomerCreditAmountById(this.getBillInfoDAO().getCustId(), this.getSessionMap());
		        	 Row totalDetailsRow2 = Row.builder()
				                .add(TextCell.builder().text("Total OutStanding Amount").colSpan(4).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(0.5F).build())				                
				                .add(TextCell.builder().text(df.format(custCreditAmount)).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(0.5F).build())
				                .backgroundColor(Color.WHITE)
				                .textColor(Color.BLACK)
				                .font(PDType1Font.HELVETICA_BOLD)
				                .fontSize(12)				              
				                .horizontalAlignment(CENTER)
				                .height(20F)	
				                .build();
		        	 tableItemInfoBuilder.addRow(totalDetailsRow2);
		         }
				
				  String convertedAmount = new NumberToWordsConverter().getConverted(""+floatTotalAmtAfterDiscount);
		      
				  Row amtInwordsRow = Row.builder()
		        		 	.add(TextCell.builder().text("Amount in Words : "+convertedAmount).colSpan(5).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				               
		        		 	.backgroundColor(WHITE)
			                .textColor(Color.BLACK)
			                .height(20F)
			                .font(fontMarathi).fontSize(12)				              
			                .horizontalAlignment(CENTER)
			                .build();
				tableItemInfoBuilder.addRow(amtInwordsRow);
				
				Row commentsRow = Row.builder()
	        		 	.add(TextCell.builder().text("Comments:"+this.getBillInfoDAO().getComments()).colSpan(5).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				               
	        		 	.backgroundColor(WHITE)
		                .textColor(Color.BLACK)
		                .height(15F)
		                .font(fontMarathi).fontSize(9)				              
		                .horizontalAlignment(LEFT)
		                .build();
			tableItemInfoBuilder.addRow(commentsRow);
	         
	         itemInfo = tableItemInfoBuilder.build();
	         
	         
	         TableBuilder signatureBuiler = Table.builder()
		                .addColumnsOfWidth(275,275)				                
		                .font(HELVETICA)
		                .borderColor(Color.BLACK)
		                .horizontalAlignment(CENTER);
	         
	         
	         Row signRow1 = Row.builder()
		                .add(TextCell.builder().text("Receiver Signature").verticalAlignment(BOTTOM).horizontalAlignment(CENTER).borderWidth(0).lineSpacing(10F).build())
		                .add(TextCell.builder().text("Authorized Signature").verticalAlignment(BOTTOM).horizontalAlignment(CENTER).borderWidth(0).lineSpacing(10F).build())					               
		                .backgroundColor(Color.WHITE)
		                .textColor(Color.BLACK)
		                .font(PDType1Font.HELVETICA_BOLD)
		                .fontSize(9)				              
		                .horizontalAlignment(CENTER)
		                .height(20F)	
		                .build();
	         signatureBuiler.addRow(signRow1);
	       
	         
	         Table signature = signatureBuiler.build();   
	         
	        
	         float currentY2 = currentY;
	         itemInfo = tableItemInfoBuilder.build();
	         
	        	float startY2 = page.getMediaBox().getHeight() - PADDING20;
	        	currentY = startY2 - 190 ; 
	        
			 TableDrawer.builder()
             .contentStream(contentStream)
             .table(itemInfo)
             .startX(PADDING20)
             .startY(currentY)
             .build()
             .draw();
			
	        
	     
	         
	         TableDrawer.builder()
             .contentStream(contentStream)
             .table(signature)
             .startX(PADDING20)
             .startY(currentY2-270)
             .build()
             .draw();
	         
	         
	         	contentStream.close();
			 	document.save(path+"/bill.pdf");
		        document.close();
		        
		        

				response.setHeader("Content-disposition", "inline; filename=bill.pdf");
				response.setContentType("application/pdf");
				FileInputStream fileInputStream = new FileInputStream(path+"/bill.pdf");
				PrintWriter out = response.getWriter();  
				int bytes;
				while ((bytes = fileInputStream.read()) != -1) {
					out.write(bytes);
				}
				fileInputStream.close();
				out.flush();
				out.close();
				ttf1.close();
				ttf2.close();
			
	         
	        
				}
		       
		        if(this.getBillType() == null)
		        {
		        	this.setBillType("A4");
		        }
		        
		   
		        
         if(this.getBillInfoDAO().getBillType().equals("TAX-INVOICE") && this.getLanguage().equals("ENGLISH") && this.getBillType().equals("A4"))
		 {
        	 String billNoPreFix = "";
        	 
        	 if(shopId.equals("46"))
        	 {
        		 billNoPreFix = "KE/2023-24/";
        	 }
        	 else if(shopId.equals("47"))
        	 {
        		 billNoPreFix = "KE/AN/2023-24/";
        	 }
        	 else
        	 {
        		 billNoPreFix = "";
        	 }
        	 
        	 @SuppressWarnings("unchecked")
			HashMap<String, String> settings = (HashMap<String, String>) this.getSessionMap().get("shop_settings");
		        boolean addQuantity2 = false;
	        	if(settings.get("add_quntity2").equals("TRUE"))
	        	{
	        		addQuantity2 = true;
	        	}
	        	
	        	@SuppressWarnings("unchecked")
				HashMap<String,String> bankDetails = (HashMap<String, String>) this.getSessionMap().get("bank_details");
	        	
	     	 if(!addQuantity2)
	     	 {
 			
         		   	 
        	 	String custMobile = "";
	        	String custAddress = "";
	        	String custGstNum = "";
	        	if(resultSet != null)
	        	{
	        		resultSet.close();
	        		resultSet = null;
	        	}
	        	
	        	if(preparedStatement != null)
	        	{
	        		preparedStatement.close();
	        		preparedStatement = null;
	        	}
	        	
	        	
	        	sql = "SELECT "
	        			+ "mobile_number,"
	        			+ "billing_address,"
	        			+ "gst_number "
	        			+ "FROM "
	        			+ "shop_customer_master "
	        			+ "WHERE "
	        			+ "customer_id = ? "
	        			+ "AND "
	        			+ "shop_id = ? "
	        			+ "AND "
	        			+ "shop_code = ?";
	        	
	        	preparedStatement = connection.prepareStatement(sql);
	        	preparedStatement.setString(1, this.getBillInfoDAO().getCustId());
	        	preparedStatement.setString(2, shopId);
	        	preparedStatement.setString(3, shopCode);
	        
	        	resultSet = preparedStatement.executeQuery();
	        	
	        	//System.out.println(preparedStatement.toString());
	        	
	        	while(resultSet.next())
	        	{
	        		custMobile = resultSet.getString(1);
	        		custAddress = resultSet.getString(2);
	        		custGstNum = resultSet.getString(3);
	        	}
	        	
        		PDDocument document = new PDDocument(); 
				PDPage page = null;
				
        	 page = new PDPage(PDRectangle.A4);
			 
			 document.addPage(page);
			 
			    PDImageXObject pdImageQRCode = null;
		         PDImageXObject pdImageLeftLogoImage = null;
		         PDImageXObject pdImageRightLogoImage = null;
		  		
		         
		         if(shopSettingsMap.get("add_left_side_logo").equals("TRUE"))
				 {
					
						if(this.getSessionMap().get("left_logo_image_array") != null)
						{
							 byte[] leftLogoBytes =(byte[]) this.getSessionMap().get("left_logo_image_array");
							 pdImageLeftLogoImage = PDImageXObject.createFromByteArray(document, leftLogoBytes, "leftLogo");
						}
					 
					
				 }
				 if(shopSettingsMap.get("add_right_side_logo").equals("TRUE"))
				 {
					 if(this.getSessionMap().get("right_logo_image_array") != null)
						{
							 byte[] rightLogoBytes =(byte[]) this.getSessionMap().get("right_logo_image_array");
							 pdImageRightLogoImage = PDImageXObject.createFromByteArray(document, rightLogoBytes, "rightLogo");
						}
				 }
				 
		 
	         PDPageContentStream contentStream = new PDPageContentStream(document, page);
	         
	         String gstNumber = (String)this.getSessionMap().get("shopgstnumber");
	         String panNumber = (String)this.getSessionMap().get("shoppannumber");
	         String declaration = (String)this.getSessionMap().get("shopdeclaration");
        	 
        		String gstDetails = "GSTIN : "+gstNumber+"                       PAN NO. : "+panNumber+"";
       	  
        		
        	 float startY = page.getMediaBox().getHeight() - PADDING20;
		        
 		       
   	         float yCordinate = page.getCropBox().getUpperRightY() - 72;
   	         float startX = page.getCropBox().getLowerLeftX() + 10;
   	         float endX = page.getCropBox().getUpperRightX() - 10;
   	         float currentY = startY;
   	         
   	      //   System.out.println("currentY upper : "+currentY);
   	         
	         Table header;
	         Table billNumberTable;
	         Table customerDetails;				      
	         Table productDetails;
	         Table totalAmountDetails;
	         Table bottomInfo;
	         Table signature;
	         
	         
	         
	         
	          TableBuilder tableHeaderBuilder = Table.builder()
		                .addColumnsOfWidth(550)				                
		                .font(HELVETICA)
		                .borderColor(Color.BLACK)
		                .horizontalAlignment(CENTER);
	       
	          //System.out.println("Bill Type -"+sagarBillDAO.getTypeOfBill());
	          Row taxInvoice = Row.builder()
		                .add(TextCell.builder().text("TAX-INVOICE").horizontalAlignment(CENTER).borderWidth(0).lineSpacing(10F).build())				               
		                .backgroundColor(WHITE)
		                .textColor(Color.BLACK)
		                .font(PDType1Font.HELVETICA_BOLD).fontSize(12)				              
		                .horizontalAlignment(CENTER)
		                .build();
	         
	          
		         Row headerRow  = Row.builder()
			                .add(TextCell.builder().text(this.getHeaderShopName()).fontSize(24).horizontalAlignment(CENTER).borderWidth(0.0F).lineSpacing(1F).build())				               
			                .backgroundColor(WHITE)
			                .font(PDType1Font.HELVETICA_BOLD)	
			                .textColor(Color.BLACK)
			                .build();
		         
		         Row addressRow  = Row.builder()
			                .add(TextCell.builder().text((String)this.getSessionMap().get("shoponelineaddress")).fontSize(10).horizontalAlignment(CENTER).borderWidth(0.0F).lineSpacing(1F).build())				               
			                .backgroundColor(WHITE)
			                .font(PDType1Font.HELVETICA_BOLD)	
			                .textColor(Color.BLACK)
			                .build();
		         
		         Row mobileRow  = Row.builder()
			                .add(TextCell.builder().text("Contact : "+(String)this.getSessionMap().get("shopcustcarenumber")).fontSize(10).horizontalAlignment(CENTER).borderWidthBottom(1.0F).lineSpacing(1F).build())				               
			                .backgroundColor(WHITE)
			                .font(PDType1Font.HELVETICA_BOLD)	
			                .textColor(Color.BLACK)
			                .build();
	          
	          Row gstRow = Row.builder()
		                .add(TextCell.builder().text(gstDetails).borderWidthBottom(0.5F).horizontalAlignment(CENTER).build())				               
		                .backgroundColor(WHITE)
		                .textColor(Color.BLACK)
		                .font(PDType1Font.HELVETICA_BOLD).fontSize(10)
		                .horizontalAlignment(CENTER)
		                .build();
	          
	          
	         tableHeaderBuilder.addRow(taxInvoice);
	         tableHeaderBuilder.addRow(headerRow);
	         tableHeaderBuilder.addRow(addressRow);
	         tableHeaderBuilder.addRow(mobileRow);
	         tableHeaderBuilder.addRow(gstRow);
	         
	         header = tableHeaderBuilder.build();
	         
	         
	         TableDrawer.builder()
	            .contentStream(contentStream)
	            .table(header)
	            .startX(PADDING30)
	            .startY(startY)
	            .build()
	            .draw();
		       
	         
	      
	         TableBuilder billNumberDate = Table.builder()
		                .addColumnsOfWidth(139,137,137,137)				                
		                .font(HELVETICA)
		                .borderWidth(1)
		                .borderColor(Color.BLACK);
	         
	         
	         Row billNumberDateRow1 = Row.builder()
		                .add(TextCell.builder().text("Invoice Number").horizontalAlignment(LEFT).borderWidth(0.5F).fontSize(8).lineSpacing(1F).build())				               
		                .add(TextCell.builder().text(billNoPreFix+""+this.getBillInfoDAO().getBillNumber()).horizontalAlignment(LEFT).fontSize(10).borderWidth(0.5F).lineSpacing(1F).build())
		                .add(TextCell.builder().text("Invoice Date").horizontalAlignment(RIGHT).borderWidth(0.5F).fontSize(8).lineSpacing(1F).build())				               
		                .add(TextCell.builder().text(""+this.getBillInfoDAO().getBillDate()).horizontalAlignment(LEFT).fontSize(10).borderWidth(0.5F).lineSpacing(1F).build())
		                .backgroundColor(WHITE)
		                .textColor(Color.BLACK)
		                .font(PDType1Font.HELVETICA_BOLD)				              
		                .horizontalAlignment(CENTER)
		                .build();
	         
	         Row billNumberDateRow2 = Row.builder()
		                .add(TextCell.builder().text("Mode Of Payment").horizontalAlignment(LEFT).borderWidth(0.5F).fontSize(8).lineSpacing(1F).build())				               
		                .add(TextCell.builder().text(this.getBillInfoDAO().getPaymentType()).horizontalAlignment(LEFT).borderWidth(0.5F).fontSize(8).lineSpacing(1F).build())				               
		                .add(TextCell.builder().text("Buyer Order Number").horizontalAlignment(RIGHT).borderWidth(0.5F).fontSize(8).lineSpacing(1F).build())				               
		                .add(TextCell.builder().text(""+this.getBillInfoDAO().getBuyerOrderNumber()).horizontalAlignment(LEFT).borderWidth(0.5F).fontSize(8).lineSpacing(1F).build())		               
			            .backgroundColor(WHITE)
		                .textColor(Color.BLACK)
		                .font(PDType1Font.HELVETICA_BOLD)				              
		                .horizontalAlignment(CENTER)
		                .build();
	         Row billNumberDateRow3 = Row.builder()
		                .add(TextCell.builder().text("State: Maharatshtra ").horizontalAlignment(LEFT).borderWidth(0.5F).fontSize(10).lineSpacing(1F).build())				               
		                .add(TextCell.builder().text("Code : 27").horizontalAlignment(LEFT).borderWidth(0.5F).fontSize(10).lineSpacing(1F).build())
		                .add(TextCell.builder().text("Dispatch Doc. Number").horizontalAlignment(RIGHT).borderWidth(0.5F).fontSize(8).lineSpacing(1F).build())
		                .add(TextCell.builder().text(""+this.getBillInfoDAO().getDispatchDocNumber()).horizontalAlignment(LEFT).fontSize(8).borderWidth(0.5F).lineSpacing(1F).build())
		                .backgroundColor(WHITE)
		                .textColor(Color.BLACK)
		                .font(PDType1Font.HELVETICA_BOLD).fontSize(10)				              
		                .horizontalAlignment(CENTER)
		                .build();
	         
	         
	         if(this.getBillInfoDAO().getVehicleNumber() == null)
	         {
	        	 this.getBillInfoDAO().setVehicleNumber("NA");
	         }
	         
	         Row billNumberDateRow4 = Row.builder()
		                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).fontSize(10).lineSpacing(1F).build())				               
		                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).fontSize(10).lineSpacing(1F).build())
		                .add(TextCell.builder().text("Vehicle Number").horizontalAlignment(RIGHT).borderWidth(0.5F).fontSize(8).lineSpacing(1F).build())
		                .add(TextCell.builder().text(""+this.getBillInfoDAO().getVehicleNumber()).horizontalAlignment(LEFT).fontSize(8).borderWidth(0.5F).lineSpacing(1F).build())
		                .backgroundColor(WHITE)
		                .textColor(Color.BLACK)
		                .font(PDType1Font.HELVETICA_BOLD).fontSize(10)				              
		                .horizontalAlignment(CENTER)
		                .build();
	         
	         billNumberDate.addRow(billNumberDateRow1);
	         billNumberDate.addRow(billNumberDateRow2);
	         billNumberDate.addRow(billNumberDateRow3);
	         billNumberDate.addRow(billNumberDateRow4);
	         billNumberTable =billNumberDate.build();
	       
	         
	         	currentY = currentY - header.getHeight()-10;
	         	
		        TableDrawer.builder()
	            .contentStream(contentStream)
	            .table(billNumberTable)
	            .startX(PADDING30)
	            .startY(currentY)
	            .build()
	            .draw();
		      
	         
	         TableBuilder tableCustDetailsBuilder = Table.builder()
		                .addColumnsOfWidth(435,115)				                
		                .font(HELVETICA)
		                .borderColor(Color.BLACK)
		                .horizontalAlignment(CENTER);
	         
	         Row custDetailsRow1 = Row.builder()
		                .add(TextCell.builder().text("Details Of Receiver (Billed To)").colSpan(2).horizontalAlignment(CENTER).borderWidth(0).lineSpacing(1F).build())				                
		                .backgroundColor(WHITE)
		                .textColor(Color.BLACK)
		                .font(PDType1Font.HELVETICA_BOLD).fontSize(10)				              
		                .horizontalAlignment(CENTER)
		                .build();
	         
	         String custStateCode = "";
	         
	         try
	         {
	        	 custStateCode = custGstNum.substring(0,2);
	         }catch (Exception e) {custStateCode = "NA";}
	         
	         Row custDetailsRow2 = Row.builder()
		                .add(TextCell.builder().text("Customer Name:  "+this.getBillInfoDAO().getCustomerName()).horizontalAlignment(LEFT).borderWidth(0).borderWidthBottom(0.5F).lineSpacing(1F).build())				                
		                .add(TextCell.builder().text("State Code:  "+custStateCode).horizontalAlignment(LEFT).borderWidth(0).borderWidthBottom(0.5F).lineSpacing(1F).build())				                
				       .backgroundColor(WHITE)
		                .textColor(Color.BLACK)
		                .font(PDType1Font.HELVETICA_BOLD).fontSize(9)				              
		                .horizontalAlignment(CENTER)
		                .build();
	         
	         Row custDetailsRow3 = Row.builder()
		                .add(TextCell.builder().text("Address:  "+custAddress).horizontalAlignment(LEFT).borderWidth(0).borderWidthBottom(0.5F).lineSpacing(1F).build())
		                .add(TextCell.builder().text("GST No:  "+custGstNum).horizontalAlignment(LEFT).borderWidth(0).borderWidthBottom(0.5F).lineSpacing(1F).build())				                
		                .backgroundColor(WHITE)
		                .textColor(Color.BLACK)
		                .font(PDType1Font.HELVETICA_BOLD).fontSize(8)				              
		                .horizontalAlignment(CENTER)
		                .build();
	         
	         Row custDetailsRow4 = Row.builder()
		                .add(TextCell.builder().text("Mobile:  "+custMobile).horizontalAlignment(LEFT).borderWidth(0).borderWidthBottom(0.5F).lineSpacing(1F).build())				                
		                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0).borderWidthBottom(0.5F).lineSpacing(1F).build())				                
			            .backgroundColor(WHITE)
		                .textColor(Color.BLACK)
		                .font(PDType1Font.HELVETICA_BOLD).fontSize(9)				              
		                .horizontalAlignment(CENTER)
		                .build();
	         
	        
	         tableCustDetailsBuilder.addRow(custDetailsRow1);
	         tableCustDetailsBuilder.addRow(custDetailsRow2);
	         tableCustDetailsBuilder.addRow(custDetailsRow3);
	         tableCustDetailsBuilder.addRow(custDetailsRow4);
	      
	         
	         customerDetails = tableCustDetailsBuilder.build();
	         

	         	currentY = currentY - billNumberTable.getHeight()-10;
		      
	         	
		        TableDrawer.builder()
	            .contentStream(contentStream)
	            .table(customerDetails)
	            .startX(PADDING30)
	            .startY(currentY)
	            .build()
	            .draw();
		        
	   
		        float newCurrentY = currentY - customerDetails.getHeight() - 10;
		        
		        
		     //   System.out.println("newCurrentY Upper : "+newCurrentY);
		        
		     TableBuilder tableproductDetailsBuilder ;
	         Row productDetailsRow1;
	         
	         if(addMakingLaborColumn.equals("FALSE"))
	         {
	         tableproductDetailsBuilder = Table.builder()
		                .addColumnsOfWidth(20,170,45,35,55,35,50,35,50,55)				                
		                .font(HELVETICA)
		                .borderWidth(0.5F)
		                .borderColor(Color.BLACK);
	         
	         if(isBillTypeIGST)
        	 {
	        	 productDetailsRow1 = Row.builder()
			                .add(TextCell.builder().text("Sr.").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
			                .add(TextCell.builder().text("Description Of Goods | HSN Code").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("Unit Price").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("Qty").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
			                .add(TextCell.builder().text("Taxable Amount").rowSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("IGST").colSpan(4).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("Total Amount").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
			                .backgroundColor(tableHedaerLightBlue)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD).fontSize(8)				              
			                .horizontalAlignment(CENTER)
			                .build();
        	 }
	         else
	         {
		         productDetailsRow1 = Row.builder()
			                .add(TextCell.builder().text("Sr.").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
			                .add(TextCell.builder().text("Description Of Goods | HSN Code").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("Unit Price").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("Qty").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
			                .add(TextCell.builder().text("Taxable Amount").rowSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("SGST").colSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("CGST").colSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("Total Amount").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
			                .backgroundColor(tableHedaerLightBlue)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD).fontSize(8)				              
			                .horizontalAlignment(CENTER)
			                .build();
	         }
	         
	         }else
	         {
	        	 tableproductDetailsBuilder = Table.builder()
			                .addColumnsOfWidth(20,150,35,50,40,35,45,35,45,50,50)				                
			                .font(HELVETICA)
			                .borderWidth(0.5F)
			                .borderColor(Color.BLACK);
	        	 
	        
	        	 productDetailsRow1 = Row.builder()
			                .add(TextCell.builder().text("Sr.").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
			                .add(TextCell.builder().text("Description Of Goods | HSN Code").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("Unit Price").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("Qty").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
			                .add(TextCell.builder().text("Taxable Amount").rowSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("SGST").colSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("CGST").colSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("Making/Labor Charges").fontSize(7).rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("Total Amount").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
			                .backgroundColor(tableHedaerLightBlue)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD).fontSize(8)				              
			                .horizontalAlignment(CENTER)
			                .build();
		         
	         }
	         
	         
	         tableproductDetailsBuilder.addRow(productDetailsRow1);
	         
	         
	         Row taxNameRow1 = null;
	         if(isBillTypeIGST)
        	 {
	        	 	taxNameRow1 = Row.builder()
		              	.add(TextCell.builder().text("Rate %").colSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
		                .add(TextCell.builder().text("Amount").colSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
		                .backgroundColor(tableHedaerLightBlue)
		                .textColor(Color.BLACK)
		                .font(PDType1Font.HELVETICA_BOLD).fontSize(8)				              
		                .horizontalAlignment(CENTER)
		                .build();
        	 }
	         else
	         {
	        	  taxNameRow1 = Row.builder()
			              	.add(TextCell.builder().text("Rate %").horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("Amount").horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
			            	.add(TextCell.builder().text("Rate %").horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("Amount").horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())				               
			                .backgroundColor(tableHedaerLightBlue)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD).fontSize(8)				              
			                .horizontalAlignment(CENTER)
			                .build();
	         }
	         
	         
	         tableproductDetailsBuilder.addRow(taxNameRow1);
	         
         int srNo = 1;
	         
	         float allUnitTotalAmount = 0.0F;
	         float totalBasicAmount = 0.0F;
	         float totalCgstAmount = 0.0F;
	         float totalSgstAmount = 0.0f;
	         float totalIgstAmount = 0.0F;
	         float totalMakingCharges = 0.0F;
	         
	         int pageCount = 1;
	         
	         for(int i =0;i<this.getProductInfoList().size();i++)
				{
	        	
	        	 
	        	 if(currentY<150)
	        	 {
	        		 
	        		 Table newLine= null;
        		    TableBuilder tableNewLineBuilder = Table.builder()
    		                .addColumnsOfWidth(550)				                
    		                .font(HELVETICA)
    		                .borderColor(Color.BLACK)
    		                .horizontalAlignment(CENTER);
	        		 
	       		 
	        			Row toBeContinue =  Row.builder()
			        		 	.add(TextCell.builder().text("Page No."+pageCount+", To be continued on next page...").fontSize(9).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(1F).build())				               
			        		 	.textColor(Color.BLACK)
				                .height(20F)
				                .font(HELVETICA)
				                .build();
					
						
	        			tableNewLineBuilder.addRow(toBeContinue);
	        			
	        			newLine = tableNewLineBuilder.build();
	        			
	        			
					
						productDetails = tableproductDetailsBuilder.build();
						
						pageCount++;
						
						  newCurrentY = startY-240;
							        
							      
						
				        TableDrawer.builder()
			            .contentStream(contentStream)
			            .table(productDetails)
			            .startX(PADDING30)
			            .startY(newCurrentY)
			            .build()
			            .draw();
				        
				        
				        newCurrentY = newCurrentY - productDetails.getHeight() - 10;
				        		
				        TableDrawer.builder()
			            .contentStream(contentStream)
			            .table(newLine)
			            .startX(PADDING30)
			            .startY(newCurrentY)
			            .build()
			            .draw();
				        

					       if(pdImageLeftLogoImage != null)
				      	 {
					        	
				      		 contentStream.drawImage(pdImageLeftLogoImage, 30, 770 , 60, 60);
				      		
				      	 }
				
					         if(pdImageRightLogoImage != null)
				      	 {
					        	
				      		 contentStream.drawImage(pdImageRightLogoImage, 515, 770 , 60, 60);
				      		
				      	 }
				        
				        contentStream.close();
				        contentStream = null;
				        
				    	PDPage newPage = new PDPage(PDRectangle.A4);
			        	 
			        	 contentStream = new PDPageContentStream(document,newPage);
			        	    document.addPage( newPage );
					          
						
						startY = newPage.getMediaBox().getHeight() - PADDING20;
						currentY = startY ; 
			        	
					     
				         TableDrawer.builder()
				            .contentStream(contentStream)
				            .table(header)
				            .startX(PADDING30)
				            .startY(startY)
				            .build()
				            .draw();
					       
				         
				         	currentY = currentY - header.getHeight()-10;
					        TableDrawer.builder()
				            .contentStream(contentStream)
				            .table(billNumberTable)
				            .startX(PADDING30)
				            .startY(currentY)
				            .build()
				            .draw();
				         
					    	currentY = currentY - billNumberTable.getHeight()-10;
						      
				         	
					        TableDrawer.builder()
				            .contentStream(contentStream)
				            .table(customerDetails)
				            .startX(PADDING30)
				            .startY(currentY)
				            .build()
				            .draw();
					        
					    
					        
					         tableproductDetailsBuilder = null;
					         productDetailsRow1 = null;
					         
					         if(addMakingLaborColumn.equals("FALSE"))
					         {
					         tableproductDetailsBuilder = Table.builder()
						                .addColumnsOfWidth(20,170,45,35,55,35,50,35,50,55)				                
						                .font(HELVETICA)
						                .borderWidth(0.5F)
						                .borderColor(Color.BLACK);
					         
					         if(isBillTypeIGST)
				        	 {
					        	 productDetailsRow1 = Row.builder()
							                .add(TextCell.builder().text("Sr.").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
							                .add(TextCell.builder().text("Description Of Goods | HSN Code").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
							                .add(TextCell.builder().text("Unit Price").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
							                .add(TextCell.builder().text("Qty").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
							                .add(TextCell.builder().text("Taxable Amount").rowSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
							                .add(TextCell.builder().text("IGST").colSpan(4).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
							                .add(TextCell.builder().text("Total Amount").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
							                .backgroundColor(tableHedaerLightBlue)
							                .textColor(Color.BLACK)
							                .font(PDType1Font.HELVETICA_BOLD).fontSize(8)				              
							                .horizontalAlignment(CENTER)
							                .build();
				        	 }
					         else
					         {
						         productDetailsRow1 = Row.builder()
							                .add(TextCell.builder().text("Sr.").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
							                .add(TextCell.builder().text("Description Of Goods | HSN Code").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
							                .add(TextCell.builder().text("Unit Price").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
							                .add(TextCell.builder().text("Qty").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
							                .add(TextCell.builder().text("Taxable Amount").rowSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
							                .add(TextCell.builder().text("SGST").colSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
							                .add(TextCell.builder().text("CGST").colSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
							                .add(TextCell.builder().text("Total Amount").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
							                .backgroundColor(tableHedaerLightBlue)
							                .textColor(Color.BLACK)
							                .font(PDType1Font.HELVETICA_BOLD).fontSize(8)				              
							                .horizontalAlignment(CENTER)
							                .build();
					         }
					         
					         }else
					         {
					        	 tableproductDetailsBuilder = Table.builder()
							                .addColumnsOfWidth(20,150,35,50,40,35,45,35,45,50,50)				                
							                .font(HELVETICA)
							                .borderWidth(0.5F)
							                .borderColor(Color.BLACK);
					        	 
					        
					        	 productDetailsRow1 = Row.builder()
							                .add(TextCell.builder().text("Sr.").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
							                .add(TextCell.builder().text("Description Of Goods | HSN Code").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
							                .add(TextCell.builder().text("Unit Price").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
							                .add(TextCell.builder().text("Qty").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
							                .add(TextCell.builder().text("Taxable Amount").rowSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
							                .add(TextCell.builder().text("SGST").colSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
							                .add(TextCell.builder().text("CGST").colSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
							                .add(TextCell.builder().text("Making/Labor Charges").fontSize(7).rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
							                .add(TextCell.builder().text("Total Amount").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
							                .backgroundColor(tableHedaerLightBlue)
							                .textColor(Color.BLACK)
							                .font(PDType1Font.HELVETICA_BOLD).fontSize(8)				              
							                .horizontalAlignment(CENTER)
							                .build();
						         
					         }
					         
					         
					         tableproductDetailsBuilder.addRow(productDetailsRow1);
					         
					         
					         taxNameRow1 = null;
					         if(isBillTypeIGST)
				        	 {
					        	 	taxNameRow1 = Row.builder()
						              	.add(TextCell.builder().text("Rate %").colSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
						                .add(TextCell.builder().text("Amount").colSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
						                .backgroundColor(tableHedaerLightBlue)
						                .textColor(Color.BLACK)
						                .font(PDType1Font.HELVETICA_BOLD).fontSize(8)				              
						                .horizontalAlignment(CENTER)
						                .build();
				        	 }
					         else
					         {
					        	  taxNameRow1 = Row.builder()
							              	.add(TextCell.builder().text("Rate %").horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
							                .add(TextCell.builder().text("Amount").horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
							            	.add(TextCell.builder().text("Rate %").horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
							                .add(TextCell.builder().text("Amount").horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())				               
							                .backgroundColor(tableHedaerLightBlue)
							                .textColor(Color.BLACK)
							                .font(PDType1Font.HELVETICA_BOLD).fontSize(8)				              
							                .horizontalAlignment(CENTER)
							                .build();
					         }
					         
					         
					         tableproductDetailsBuilder.addRow(taxNameRow1);
					        
	        	 }
	        	 
	        		BillProductInfoDAO informationDAO = null;
	        	 try
	        	 {
	        		
	        		 informationDAO = this.getProductInfoList().get(i);
	        	 }
	        	 catch(Exception e)
	        	 {
	        		 informationDAO = null;
	        	 }
	        			
	        	 if(informationDAO != null)
	        	 {
	        		 
	        		
	        		 float taxableAmount = 0.0F;
	        		 float totalUnitAmount = 0.0F;
	        		 float unitCgst = 0.0F;
	        		 float unitSgst = 0.0F;
	        		 float unitIgst = 0.0F;
	        		 
	        		 float taxPercentage = 0.0F;
	        		 float halfTax = 0.0F;
	        		 float qty = informationDAO.getQuantity();
	        		 float makingLaborCharge = informationDAO.getMakingLaborCharge();
	        		 
	        		 float unitPrice = 0.0F;
	        		 try
	        		 {
	        		 
	        			
	        		 unitPrice =informationDAO.getGrossAmount()/qty;
	        		 unitCgst = informationDAO.getCgst();
	        		 unitSgst = informationDAO.getSgst();
	        		 unitIgst = informationDAO.getIgst();
	        		 
	        		 taxPercentage = informationDAO.getTaxPercentage();
	        		 if(isBillTypeIGST)
	            	 {
		        		 totalBasicAmount = totalBasicAmount + informationDAO.getGrossAmount();
		        		 totalIgstAmount = totalIgstAmount + informationDAO.getIgst();
		        		 taxableAmount = unitPrice*qty;
		        		 
		        		 totalUnitAmount = taxableAmount + unitIgst;
		        		 
		        		 allUnitTotalAmount = allUnitTotalAmount+ totalUnitAmount;
		        		 
		        		
	            	 }
	        		 else
	        		 {
	        			 totalBasicAmount = totalBasicAmount + informationDAO.getGrossAmount();
		        		 totalCgstAmount = totalCgstAmount + informationDAO.getCgst();
		        		 totalSgstAmount = totalSgstAmount + informationDAO.getSgst();
		        		 taxableAmount = unitPrice*qty;
		        		 
		        		 totalUnitAmount = taxableAmount + unitCgst + unitSgst ;
		        		 
		        		 allUnitTotalAmount = allUnitTotalAmount+ totalUnitAmount;
		        		 
		        		 halfTax  = taxPercentage/2.0F;
	        		 }
	        		 }catch(NumberFormatException e)
	        		 {}
	        		 
	        		// int qty = Integer.parseInt(informationDAO.getProductQuantity());
	        		
	        		 Row productDetailsRow;
	        		 if(addMakingLaborColumn.equals("FALSE"))
			         {
	        			 if(isBillTypeIGST)
		            	 {
	        				 
	        					if(this.getSessionMap().get("batchbased").equals("1"))
			    				{
	        						productDetailsRow = Row.builder()
	    	 				                .add(TextCell.builder().text(""+srNo).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())				                
	    	 				                .add(TextCell.builder().text(informationDAO.getProductName().toUpperCase()+" ("+informationDAO.getSerialNoBatchId()+")"+"\n[ HSN Code - "+informationDAO.getHsnCode()+" ]").fontSize(7).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(0.3F).build())
	    	 				                .add(TextCell.builder().text(df.format(unitPrice)).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
	    	 				                .add(TextCell.builder().text(df.format(informationDAO.getQuantity())).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())					                
	    	 				                .add(TextCell.builder().text(df.format(taxableAmount)).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
	    	 				                .add(TextCell.builder().text(df.format(taxPercentage)).colSpan(2).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
	    	 				                .add(TextCell.builder().text(df.format(informationDAO.getIgst())).colSpan(2).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
	    	 				                .add(TextCell.builder().text(df.format(totalUnitAmount)).horizontalAlignment(RIGHT).verticalAlignment(MIDDLE).borderWidth(0.5F).lineSpacing(1F).build())
	    	 				                .backgroundColor(Color.WHITE)
	    	 				                .textColor(Color.BLACK)
	    	 				                .font(PDType1Font.HELVETICA)
	    	 				                .fontSize(9)				              
	    	 				                .horizontalAlignment(CENTER)                
	    	 				                .build();
			    				}
	        					else
	        					{
	        						productDetailsRow = Row.builder()
	 				                .add(TextCell.builder().text(""+srNo).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())				                
	 				                .add(TextCell.builder().text(informationDAO.getProductName().toUpperCase()+" ("+informationDAO.getProductCode()+")"+"\n[ HSN Code - "+informationDAO.getHsnCode()+" ]").fontSize(7).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(0.3F).build())
	 				                .add(TextCell.builder().text(df.format(unitPrice)).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
	 				                .add(TextCell.builder().text(df.format(informationDAO.getQuantity())).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())					                
	 				                .add(TextCell.builder().text(df.format(taxableAmount)).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
	 				                .add(TextCell.builder().text(df.format(taxPercentage)).colSpan(2).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
	 				                .add(TextCell.builder().text(df.format(informationDAO.getIgst())).colSpan(2).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
	 				                .add(TextCell.builder().text(df.format(totalUnitAmount)).horizontalAlignment(RIGHT).verticalAlignment(MIDDLE).borderWidth(0.5F).lineSpacing(1F).build())
	 				                .backgroundColor(Color.WHITE)
	 				                .textColor(Color.BLACK)
	 				                .font(PDType1Font.HELVETICA)
	 				                .fontSize(9)				              
	 				                .horizontalAlignment(CENTER)	                
	 				                .build();
	        					}
		            	 }
	        			 else
	        			 {
	        				 if(this.getSessionMap().get("batchbased").equals("1"))
			    				{
	        					 productDetailsRow = Row.builder()
				                .add(TextCell.builder().text(""+srNo).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())				                
				                .add(TextCell.builder().text(informationDAO.getProductName().toUpperCase()+" ("+informationDAO.getSerialNoBatchId()+")"+"\n[ HSN Code - "+informationDAO.getHsnCode()+" ]").fontSize(7).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(0.3F).build())
				                .add(TextCell.builder().text(df.format(unitPrice)).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
				                .add(TextCell.builder().text(df.format(informationDAO.getQuantity())).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())					                
				                .add(TextCell.builder().text(df.format(taxableAmount)).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
				                .add(TextCell.builder().text(df.format(halfTax)).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
				                .add(TextCell.builder().text(df.format(informationDAO.getSgst())).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
				                .add(TextCell.builder().text(df.format(halfTax)).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
				                .add(TextCell.builder().text(df.format(informationDAO.getCgst())).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
				                .add(TextCell.builder().text(df.format(totalUnitAmount)).horizontalAlignment(RIGHT).verticalAlignment(MIDDLE).borderWidth(0.5F).lineSpacing(1F).build())
				                .backgroundColor(Color.WHITE)
				                .textColor(Color.BLACK)
				                .font(PDType1Font.HELVETICA)
				                .fontSize(9)				              
				                .horizontalAlignment(CENTER)	                
				                .build();
			    			}
	        				 else
	        				 {
	        					 productDetailsRow = Row.builder()
	     				                .add(TextCell.builder().text(""+srNo).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())				                
	     				                .add(TextCell.builder().text(informationDAO.getProductName().toUpperCase()+" ("+informationDAO.getProductCode()+")"+"\n[ HSN Code - "+informationDAO.getHsnCode()+" ]").fontSize(7).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(0.3F).build())
	     				                .add(TextCell.builder().text(df.format(unitPrice)).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
	     				                .add(TextCell.builder().text(df.format(informationDAO.getQuantity())).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())					                
	     				                .add(TextCell.builder().text(df.format(taxableAmount)).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
	     				                .add(TextCell.builder().text(df.format(halfTax)).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
	     				                .add(TextCell.builder().text(df.format(informationDAO.getSgst())).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
	     				                .add(TextCell.builder().text(df.format(halfTax)).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
	     				                .add(TextCell.builder().text(df.format(informationDAO.getCgst())).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
	     				                .add(TextCell.builder().text(df.format(totalUnitAmount)).horizontalAlignment(RIGHT).verticalAlignment(MIDDLE).borderWidth(0.5F).lineSpacing(1F).build())
	     				                .backgroundColor(Color.WHITE)
	     				                .textColor(Color.BLACK)
	     				                .font(PDType1Font.HELVETICA)
	     				                .fontSize(9)				              
	     				                .horizontalAlignment(CENTER)	                
	     				                .build();
	        				 }
	        			 }
			         
			         }
	        		 else
	        		 {
	        			
	        				 productDetailsRow = Row.builder()
					                .add(TextCell.builder().text(""+srNo).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())				                
					                .add(TextCell.builder().text(informationDAO.getProductName().toUpperCase()+" ("+informationDAO.getProductCode()+")"+"\n[ HSN Code - "+informationDAO.getHsnCode()+" ]").fontSize(7).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(0.3F).build())
					                .add(TextCell.builder().text(df.format(unitPrice)).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
					                .add(TextCell.builder().text(df.format(informationDAO.getQuantity())).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())					                
					                .add(TextCell.builder().text(df.format(taxableAmount)).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
					                .add(TextCell.builder().text(df.format(halfTax)).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
					                .add(TextCell.builder().text(df.format(informationDAO.getSgst())).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
					                .add(TextCell.builder().text(df.format(halfTax)).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
					                .add(TextCell.builder().text(df.format(informationDAO.getCgst())).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
					                .add(TextCell.builder().text(df.format(makingLaborCharge)).horizontalAlignment(RIGHT).verticalAlignment(MIDDLE).borderWidth(0.5F).lineSpacing(1F).build())
						            .add(TextCell.builder().text(df.format(totalUnitAmount)).horizontalAlignment(RIGHT).verticalAlignment(MIDDLE).borderWidth(0.5F).lineSpacing(1F).build())
					                .backgroundColor(Color.WHITE)
					                .textColor(Color.BLACK)
					                .font(PDType1Font.HELVETICA)
					                .fontSize(9)				              
					                .horizontalAlignment(CENTER)                
					                .build();
	        				 
	        				 totalMakingCharges = totalMakingCharges + makingLaborCharge;
				         
	        		 }
	        		 tableproductDetailsBuilder.addRow(productDetailsRow);
		         
	     	        
			         currentY = (float) (currentY - 23F);
			
			         srNo++;
	        	 }
	        	 
	        	 else
	        	 {
	        		 Row productDetailsRow;
	        		 if(addMakingLaborColumn.equals("FALSE"))
			         {
	        			 if(isBillTypeIGST)
		            	 {
		        	   productDetailsRow = Row.builder()
				                .add(TextCell.builder().text("").horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(10F).build())				                
				                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
				                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
				                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
				                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())						                
				                .add(TextCell.builder().text("").colSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
				                .add(TextCell.builder().text("").colSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
				                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
				                .backgroundColor(Color.WHITE)
				                .textColor(Color.BLACK)
				                .font(PDType1Font.HELVETICA)
				                .fontSize(8)				              
				                .horizontalAlignment(CENTER)
				                .build();
		            	 }
	        			 else
	        			 {
	        				 productDetailsRow = Row.builder()
	 				                .add(TextCell.builder().text("").horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(10F).build())				                
	 				                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
	 				                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
	 				                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
	 				                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())						                
	 				                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
	 				                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
	 				                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
	 				                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
	 				                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
	 				                .backgroundColor(Color.WHITE)
	 				                .textColor(Color.BLACK)
	 				                .font(PDType1Font.HELVETICA)
	 				                .fontSize(8)				              
	 				                .horizontalAlignment(CENTER)
	 				                .build();
	        			 }
			         }
	        		 else
	        		 {
	        			 productDetailsRow = Row.builder()
					                .add(TextCell.builder().text("").horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(10F).build())				                
					                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
					                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
					                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
					                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())						                
					                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
					                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
					                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
					                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
					                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
					                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
						            .backgroundColor(Color.WHITE)
					                .textColor(Color.BLACK)
					                .font(PDType1Font.HELVETICA)
					                .fontSize(8)				              
					                .horizontalAlignment(CENTER)
					                .build();
	        		 }
			         tableproductDetailsBuilder.addRow(productDetailsRow);
			         currentY = (float) (currentY -  23F);
						
			         srNo++;
	        	 }
	         
	         }
	         
	         productDetails = tableproductDetailsBuilder.build();
	         
		
			    
		        TableDrawer.builder()
	            .contentStream(contentStream)
	            .table(productDetails)
	            .startX(PADDING30)
	            .startY(startY-240)
	            .build()
	            .draw();
	         
	         TableBuilder totalDetailsBuilder = Table.builder()
		                .addColumnsOfWidth(150,100)				                
		                .font(HELVETICA)
		                .borderWidth(1)
		                .borderColor(Color.BLACK);
	         
	         
	         Row totalDetailsRow1 = Row.builder()
		                .add(TextCell.builder().text("Total Taxable Amount").horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())				                
		                .add(TextCell.builder().text(df.format(totalBasicAmount)).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())
		                .backgroundColor(Color.WHITE)
		                .textColor(Color.BLACK)
		                .font(PDType1Font.HELVETICA_BOLD)
		                .fontSize(9)				              
		                .horizontalAlignment(CENTER)
		                .height(17F)	
		                .build();
	         totalDetailsBuilder.addRow(totalDetailsRow1);        
	         
	        
	         
	         
	         Row totalDetailsRow2 = Row.builder()
		                .add(TextCell.builder().text("Total SGST Amount").horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())				                
		                .add(TextCell.builder().text(df.format(totalSgstAmount)).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())
		                .backgroundColor(Color.WHITE)
		                .textColor(Color.BLACK)
		                .font(PDType1Font.HELVETICA_BOLD)
		                .fontSize(9)				              
		                .horizontalAlignment(CENTER)
		                .height(17F)	
		                .build();
	         totalDetailsBuilder.addRow(totalDetailsRow2);
	         
	         Row totalDetailsRow3 = Row.builder()
		                .add(TextCell.builder().text("Total CGST Amount").horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())				                
		                .add(TextCell.builder().text(df.format(totalCgstAmount)).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())
		                .backgroundColor(Color.WHITE)
		                .textColor(Color.BLACK)
		                .font(PDType1Font.HELVETICA_BOLD)
		                .fontSize(9)				              
		                .horizontalAlignment(CENTER)
		                .height(17F)	
		                .build();
	         totalDetailsBuilder.addRow(totalDetailsRow3);
	         
	         
	         Row totalDetailsRow4= Row.builder()
		                .add(TextCell.builder().text("Total IGST Amount").horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())				                
		                .add(TextCell.builder().text(df.format(totalIgstAmount)).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())
		                .backgroundColor(Color.WHITE)
		                .textColor(Color.BLACK)
		                .font(PDType1Font.HELVETICA_BOLD)
		                .fontSize(9)				              
		                .horizontalAlignment(CENTER)
		                .height(17F)	
		                .build();
	         totalDetailsBuilder.addRow(totalDetailsRow4);
	         
	         
	         float totalTax = totalCgstAmount + totalSgstAmount + totalIgstAmount;
	         
	         Row totalDetailsRow5 = Row.builder()
		                .add(TextCell.builder().text("Total TAX Amount").horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())				                
		                .add(TextCell.builder().text(""+totalTax).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())
		                .backgroundColor(Color.WHITE)
		                .textColor(Color.BLACK)
		                .font(PDType1Font.HELVETICA_BOLD)
		                .fontSize(9)				              
		                .horizontalAlignment(CENTER)
		                .height(17F)	
		                .build();
	         totalDetailsBuilder.addRow(totalDetailsRow5);
	         float roundOff = 0.0F;
	         float totalBillAmountAfterTax = Float.parseFloat(this.getBillInfoDAO().getTotalBillAmount());
	         float roundOffAmount = Math.round(totalBillAmountAfterTax);
	         roundOff = roundOffAmount - totalBillAmountAfterTax;
	         
	         if(addMakingLaborColumn.equals("TRUE"))
	         {
	        	 Row totalDetailsRowMaking = Row.builder()
			                .add(TextCell.builder().text("Making / Labor Charges").horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())				                
			                .add(TextCell.builder().text(df.format(totalMakingCharges)).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())
			                .backgroundColor(Color.WHITE)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD)
			                .fontSize(9)				              
			                .horizontalAlignment(CENTER)
			                .height(16F)	
			                .build();
		         totalDetailsBuilder.addRow(totalDetailsRowMaking);
	         }
	         
	         Row totalDetailsRow6 = Row.builder()
		                .add(TextCell.builder().text("Round Off").horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())				                
		                .add(TextCell.builder().text(""+roundOff).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())
		                .backgroundColor(Color.WHITE)
		                .textColor(Color.BLACK)
		                .font(PDType1Font.HELVETICA_BOLD)
		                .fontSize(9)				              
		                .horizontalAlignment(CENTER)
		                .height(17F)	
		                .build();
	         totalDetailsBuilder.addRow(totalDetailsRow6);
	         
	         Row totalDetailsRow7 = Row.builder()
		                .add(TextCell.builder().text("Total Amount After TAX").horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())				                
		                .add(TextCell.builder().text(this.getBillInfoDAO().getTotalBillAmount()).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())
		                .backgroundColor(Color.WHITE)
		                .textColor(Color.BLACK)
		                .font(PDType1Font.HELVETICA_BOLD)
		                .fontSize(9)				              
		                .horizontalAlignment(CENTER)
		                .height(17F)	
		                .build();
	         totalDetailsBuilder.addRow(totalDetailsRow7);
	         
	         
	        
	         
	         totalAmountDetails = totalDetailsBuilder.build();
	         
	       Table bankDetailsTable = null;
	       
	       
	       TableBuilder bankDetailsTableBuilder = Table.builder()
		                .addColumnsOfWidth(149,149)				                
		                .font(HELVETICA)
		                .borderWidth(1)
		                .borderColor(Color.BLACK);
	       
	       Row bankDetailsHeader = Row.builder()
	                .add(TextCell.builder().text("BANK DETAILS").colSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(10F).build())				                
	                .backgroundColor(tableHedaerLightBlue)
	                .textColor(Color.BLACK)
	                .font(PDType1Font.HELVETICA_BOLD)
	                .fontSize(9)				              
	                .horizontalAlignment(CENTER)
	                .height(20F)	
	                .build();
	       bankDetailsTableBuilder.addRow(bankDetailsHeader);
	       
	       Row bankDetailsRow1 = Row.builder()
	                .add(TextCell.builder().text("BANKING NAME").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())				                
	                .add(TextCell.builder().text(bankDetails.get("bankingname")).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
	                .backgroundColor(Color.WHITE)
	                .textColor(Color.BLACK)
	                .font(PDType1Font.HELVETICA)
	                .fontSize(9)				              
	                .horizontalAlignment(CENTER)
	                .height(20F)	
	                .build();
	       bankDetailsTableBuilder.addRow(bankDetailsRow1);
	       
	       Row bankDetailsRow2 = Row.builder()
	                .add(TextCell.builder().text("NAME OF THE BANK").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())				                
	                .add(TextCell.builder().text(bankDetails.get("bankname")).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
	                .backgroundColor(Color.WHITE)
	                .textColor(Color.BLACK)
	                .font(PDType1Font.HELVETICA)
	                .fontSize(9)				              
	                .horizontalAlignment(CENTER)
	                .height(20F)	
	                .build();
	       bankDetailsTableBuilder.addRow(bankDetailsRow2);
	       	Row bankDetailsRow3 = Row.builder()
	                .add(TextCell.builder().text("BRANCH").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())				                
	                .add(TextCell.builder().text(bankDetails.get("branchname")).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
	                .backgroundColor(Color.WHITE)
	                .textColor(Color.BLACK)
	                .font(PDType1Font.HELVETICA)
	                .fontSize(9)				              
	                .horizontalAlignment(CENTER)
	                .height(20F)	
	                .build();
	       	bankDetailsTableBuilder.addRow(bankDetailsRow3);
	       	Row bankDetailsRow4 = Row.builder()
	                .add(TextCell.builder().text("ACCOUNT NUMBER").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())				                
	                .add(TextCell.builder().text(bankDetails.get("accnumber")).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
	                .backgroundColor(Color.WHITE)
	                .textColor(Color.BLACK)
	                .font(PDType1Font.HELVETICA)
	                .fontSize(9)				              
	                .horizontalAlignment(CENTER)
	                .height(20F)	
	                .build();
	       	bankDetailsTableBuilder.addRow(bankDetailsRow4);
	       	Row bankDetailsRow5 = Row.builder()
	                .add(TextCell.builder().text("IFSC CODE").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())				                
	                .add(TextCell.builder().text(bankDetails.get("ifsccode")).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
	                .backgroundColor(Color.WHITE)
	                .textColor(Color.BLACK)
	                .font(PDType1Font.HELVETICA)
	                .fontSize(9)				              
	                .horizontalAlignment(CENTER)
	                .height(20F)	
	                .build();
	       	bankDetailsTableBuilder.addRow(bankDetailsRow5);
        
	         bankDetailsTable = bankDetailsTableBuilder.build();
	         
	         TableBuilder tableBottomInfoBuilder = Table.builder()
		                .addColumnsOfWidth(550)				                
		                .font(HELVETICA)
		                .borderColor(Color.BLACK);
	         

	         Row bottomInfoRow1 = Row.builder()
		                .add(TextCell.builder().text("Declaration: "+declaration).horizontalAlignment(LEFT).borderWidth(0).borderWidthBottom(0.0F).verticalAlignment(BOTTOM).lineSpacing(10F).build())
		                .backgroundColor(Color.WHITE)
		                .textColor(Color.BLACK)
		                .font(PDType1Font.HELVETICA)
		                .fontSize(9)				              
		                .horizontalAlignment(CENTER)
		                .height(20F)	
		                .build();
	         
	     
	         
	         
	         float totalAmounttoConvert = Float.parseFloat(this.getBillInfoDAO().getTotalBillAmount());
	      
	         String convertedAmount = new NumberToWordsConverter().getConverted(""+totalAmounttoConvert);
	      
	       Row bottomInfoRow3 = Row.builder()
		                .add(TextCell.builder().text("Amount in words :"+convertedAmount).horizontalAlignment(LEFT).borderWidth(0.5F).build())
		                .backgroundColor(tableHedaerLightBlue)
		                .textColor(Color.BLACK)
		                .font(PDType1Font.HELVETICA_BOLD)
		                .fontSize(9)				              
		                .horizontalAlignment(CENTER)
		                .height(20F)	
		                .build();
	       
	       tableBottomInfoBuilder.addRow(bottomInfoRow3);
	       
	       
	       if(this.getBillInfoDAO().getComments() == null)
	       {
	    	   this.getBillInfoDAO().setComments("NA");
	       }
	       if(this.getBillInfoDAO().getComments().equals("NA"))
	         {
	         Row bottomInfoRowComments = Row.builder()
		                .add(TextCell.builder().text("Comments:").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(0.5F).build())
		                .backgroundColor(Color.WHITE)
		                .textColor(Color.BLACK)
		                .font(PDType1Font.HELVETICA)
		                .fontSize(10)
		                .height(30F)
		                .horizontalAlignment(CENTER)					               	
		                .build();
	         tableBottomInfoBuilder.addRow(bottomInfoRowComments);
	         
	         }
	         else
	         {
	        	 Row bottomInfoRowComments = Row.builder()
			                .add(TextCell.builder().text("Comments:"+this.getBillInfoDAO().getComments()).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(0.5F).build())
			                .backgroundColor(Color.WHITE)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA)
			                .fontSize(10)
			                .height(30F)
			                .horizontalAlignment(CENTER)					               	
			                .build();
		         tableBottomInfoBuilder.addRow(bottomInfoRowComments);
	         }
	     			        
	       tableBottomInfoBuilder.addRow(bottomInfoRow1);
	         
	         bottomInfo = tableBottomInfoBuilder.build();
	         
	         
	         
	         TableBuilder signatureBuiler = Table.builder()
		                .addColumnsOfWidth(275,275)				                
		                .font(HELVETICA)
		                .borderColor(Color.BLACK)
		                .horizontalAlignment(CENTER);
	         
	         
	         Row signRow1 = Row.builder()
		                .add(TextCell.builder().text("Receiver Signature").verticalAlignment(BOTTOM).horizontalAlignment(CENTER).borderWidth(0).lineSpacing(10F).build())
		                .add(TextCell.builder().text("For Propriter").verticalAlignment(BOTTOM).horizontalAlignment(CENTER).borderWidth(0).lineSpacing(10F).build())					               
		                .backgroundColor(Color.WHITE)
		                .textColor(Color.BLACK)
		                .font(PDType1Font.HELVETICA_BOLD)
		                .fontSize(9)				              
		                .horizontalAlignment(CENTER)
		                .height(20F)	
		                .build();
	         signatureBuiler.addRow(signRow1);
	       
	         
	         signature = signatureBuiler.build();   
        
	     
	     /*  contentStream.setLineWidth(0.6f);
	        contentStream.moveTo(startX, yCordinate);
	        contentStream.lineTo(endX, yCordinate);
	        contentStream.stroke();
	        
	        yCordinate = yCordinate - 15;
	        
	        contentStream.moveTo(startX, yCordinate);
	        contentStream.lineTo(endX, yCordinate);
	        contentStream.stroke();
	        */
	        
	    
	         // System.out.println("currentY 1: "+currentY);
	         
	         
	         float productDetailsStartY = startY - 240;
	         newCurrentY = productDetailsStartY - productDetails.getHeight() - 10;
	     
	        // System.out.println("newCurrentY : "+newCurrentY);
	         
	         // System.out.println("Total Amount height : "+bankDetailsTable.getHeight());
	         
	        // System.out.println("newCurrentY 1 "+newCurrentY);
	         
	         float bankSectionHeight = Math.max(bankDetailsTable.getHeight(), totalAmountDetails.getHeight());
	         float footerSectionHeight = bottomInfo.getHeight() + signature.getHeight() + 30;
	         float pageBottomMargin = 35;
	         
	         if((newCurrentY - bankSectionHeight) < pageBottomMargin)
	         {
	        	 contentStream.close();
	        	 contentStream = null;
	        	 
	        	 PDPage newPage = new PDPage(PDRectangle.A4);
	        	 contentStream = new PDPageContentStream(document,newPage);
	        	 document.addPage(newPage);
	        	 
	        	 startY = newPage.getMediaBox().getHeight() - PADDING20;
	        	 currentY = startY;
	        	 
		         TableDrawer.builder()
		            .contentStream(contentStream)
		            .table(header)
		            .startX(PADDING30)
		            .startY(startY)
		            .build()
		            .draw();
		         
		         currentY = currentY - header.getHeight()-10;
		         TableDrawer.builder()
		            .contentStream(contentStream)
		            .table(billNumberTable)
		            .startX(PADDING30)
		            .startY(currentY)
		            .build()
		            .draw();
		         
		         currentY = currentY - billNumberTable.getHeight()-10;
		         TableDrawer.builder()
		            .contentStream(contentStream)
		            .table(customerDetails)
		            .startX(PADDING30)
		            .startY(currentY)
		            .build()
		            .draw();
		         
		         newCurrentY = startY - 240;
	         }
	         
 	        TableDrawer.builder()
             .contentStream(contentStream)
             .table(bankDetailsTable)
             .startX(PADDING30)
             .startY(newCurrentY)
             .build()
             .draw();
 	        
 	       TableDrawer.builder()
            .contentStream(contentStream)
            .table(totalAmountDetails)
            .startX(330)
            .startY(newCurrentY)
            .build()
            .draw();
 	       
 	       newCurrentY = newCurrentY - bankSectionHeight - 10;
	         
	       if(addMakingLaborColumn.equals("TRUE"))
	         {
		        if(newCurrentY < 220)
		        {
		        	 contentStream.close();
		        	 contentStream = null;
		        	 
		        	 PDPage newPage = new PDPage(PDRectangle.A4);
		        	 contentStream = new PDPageContentStream(document,newPage);
		        	 document.addPage(newPage);
		        	 
		        	 startY = newPage.getMediaBox().getHeight() - PADDING20;
		        	 currentY = startY ; 
		        	
			         TableDrawer.builder()
			            .contentStream(contentStream)
			            .table(header)
			            .startX(PADDING30)
			            .startY(startY)
			            .build()
			            .draw();
			         
			         currentY = currentY - header.getHeight()-10;
			         TableDrawer.builder()
			            .contentStream(contentStream)
			            .table(billNumberTable)
			            .startX(PADDING30)
			            .startY(currentY)
			            .build()
			            .draw();
			         
			         currentY = currentY - billNumberTable.getHeight()-10;
			         TableDrawer.builder()
			            .contentStream(contentStream)
			            .table(customerDetails)
			            .startX(PADDING30)
			            .startY(currentY)
			            .build()
			            .draw();
		        }
		        
		        TableDrawer.builder()
		            .contentStream(contentStream)
		            .table(bottomInfo)
		            .startX(PADDING30)
		            .startY(startY-635)
		            .build()
		            .draw();
		        
		        TableDrawer.builder()
		            .contentStream(contentStream)
		            .table(signature)
		            .startX(PADDING30)
		            .startY(startY-785)
		            .build()
		            .draw();
	         }
	       	else
	         {
	       	     if((newCurrentY - footerSectionHeight) < pageBottomMargin)
	       	     {
	       	    	 contentStream.close();
	       	    	 contentStream = null;
	       	    	 
	       	    	 PDPage newPage = new PDPage(PDRectangle.A4);
	       	    	 contentStream = new PDPageContentStream(document,newPage);
	       	    	 document.addPage(newPage);
	       	    	 
	       	    	 startY = newPage.getMediaBox().getHeight() - PADDING20;
	       	    	 currentY = startY ; 
	       	    	 
	   		         TableDrawer.builder()
	   		            .contentStream(contentStream)
	   		            .table(header)
	   		            .startX(PADDING30)
	   		            .startY(startY)
	   		            .build()
	   		            .draw();
	   		         
	   		         currentY = currentY - header.getHeight()-10;
	   		         TableDrawer.builder()
	   		            .contentStream(contentStream)
	   		            .table(billNumberTable)
	   		            .startX(PADDING30)
	   		            .startY(currentY)
	   		            .build()
	   		            .draw();
	   		         
	   		         currentY = currentY - billNumberTable.getHeight()-10;
	   		         TableDrawer.builder()
	   		            .contentStream(contentStream)
	   		            .table(customerDetails)
	   		            .startX(PADDING30)
	   		            .startY(currentY)
	   		            .build()
	   		            .draw();
	   		         
	   		         newCurrentY = startY - 240;
	       	     }
	       	     
	       	   TableDrawer.builder()
	            .contentStream(contentStream)
	            .table(bottomInfo)
	            .startX(PADDING30)
	            .startY(newCurrentY)
	            .build()
	            .draw();
	       	   
	       	   newCurrentY = newCurrentY - bottomInfo.getHeight() - 30;
	   	      	 
	       	   TableDrawer.builder()
	           .contentStream(contentStream)
	           .table(signature)
	           .startX(PADDING30)
	           .startY(newCurrentY)
	           .build()
	           .draw();
	         }
	    
	       
	    
	     
		       if(pdImageLeftLogoImage != null)
	      	 {
		        	
	      		 contentStream.drawImage(pdImageLeftLogoImage, 30, 770 , 60, 60);
	      		
	      	 }
	
		         if(pdImageRightLogoImage != null)
	      	 {
		        	
	      		 contentStream.drawImage(pdImageRightLogoImage, 515, 770 , 60, 60);
	      		
	      	 }
		    contentStream.close();
	        
	       // System.out.println(path);
					
	        
	        addPageNumbers(document);
	        document.save(path+"/invoice.pdf");
	        document.close();
	        
	        

			response.setHeader("Content-disposition", "inline; filename=tax-invoice.pdf");
			response.setContentType("application/pdf");
			@SuppressWarnings("resource")
			FileInputStream fileInputStream = new FileInputStream(path+"/invoice.pdf");
			PrintWriter out = response.getWriter();  
			int bytes;
			while ((bytes = fileInputStream.read()) != -1) {
				out.write(bytes);
			}
			fileInputStream.close();
			out.flush();
			out.close();
        	 
			}
	     	 else
	     	 {

	  			
     		   	 
	        	 	String custMobile = "";
		        	String custAddress = "";
		        	
		        	if(resultSet != null)
		        	{
		        		resultSet.close();
		        		resultSet = null;
		        	}
		        	
		        	if(preparedStatement != null)
		        	{
		        		preparedStatement.close();
		        		preparedStatement = null;
		        	}
		        	
		        	
		        	sql = "SELECT "
		        			+ "mobile_number,"
		        			+ "billing_address "
		        			+ "FROM "
		        			+ "shop_customer_master "
		        			+ "WHERE "
		        			+ "customer_name = ? "
		        			+ "AND "
		        			+ "customer_id = ? "
		        			+ "AND "
		        			+ "shop_id = ? "
		        			+ "AND "
		        			+ "shop_code = ?";
		        	
		        	preparedStatement = connection.prepareStatement(sql);
		        	preparedStatement.setString(1, this.getBillInfoDAO().getCustomerName());
		        	preparedStatement.setString(2, this.getBillInfoDAO().getCustId());
		        	preparedStatement.setString(3, shopId);
		        	preparedStatement.setString(4, shopCode);
		        	
		        	resultSet = preparedStatement.executeQuery();
		        	
		        	while(resultSet.next())
		        	{
		        		custMobile = resultSet.getString(1);
		        		custAddress = resultSet.getString(2);
		        	}
	        		PDDocument document = new PDDocument(); 
					PDPage page = null;
					
	        	 page = new PDPage(PDRectangle.A4);
				 
				 document.addPage(page);
				 
			 
		         PDPageContentStream contentStream = new PDPageContentStream(document, page);
		         
		         String gstNumber = (String)this.getSessionMap().get("shopgstnumber");
		         String panNumber = (String)this.getSessionMap().get("shoppannumber");
		         String declaration = (String)this.getSessionMap().get("shopdeclaration");
	        	 
	        		String gstDetails = "GSTIN : "+gstNumber+"                       PAN NO. : "+panNumber+"";
	       	  
		         Table header;
		         Table billNumberTable;
		         Table customerDetails;				      
		         Table productDetails;
		         Table totalAmountDetails;
		         Table bottomInfo;
		         Table signature;
		         
		         
		         
		         
		          TableBuilder tableHeaderBuilder = Table.builder()
			                .addColumnsOfWidth(550)				                
			                .font(HELVETICA)
			                .borderColor(Color.BLACK)
			                .horizontalAlignment(CENTER);
		       
		          //System.out.println("Bill Type -"+sagarBillDAO.getTypeOfBill());
		          Row taxInvoice = Row.builder()
			                .add(TextCell.builder().text("TAX-INVOICE").horizontalAlignment(CENTER).borderWidth(0).lineSpacing(10F).build())				               
			                .backgroundColor(WHITE)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD).fontSize(12)				              
			                .horizontalAlignment(CENTER)
			                .build();
		         
		          
			         Row headerRow  = Row.builder()
				                .add(TextCell.builder().text(this.getHeaderShopName()).fontSize(24).horizontalAlignment(CENTER).borderWidth(0.0F).lineSpacing(1F).build())				               
				                .backgroundColor(WHITE)
				                .font(PDType1Font.HELVETICA_BOLD)	
				                .textColor(Color.BLACK)
				                .build();
			         
			         Row addressRow  = Row.builder()
				                .add(TextCell.builder().text((String)this.getSessionMap().get("shoponelineaddress")).fontSize(10).horizontalAlignment(CENTER).borderWidth(0.0F).lineSpacing(1F).build())				               
				                .backgroundColor(WHITE)
				                .font(PDType1Font.HELVETICA_BOLD)	
				                .textColor(Color.BLACK)
				                .build();
			         
			         Row mobileRow  = Row.builder()
				                .add(TextCell.builder().text((String)this.getSessionMap().get("shopcustcarenumber")).fontSize(10).horizontalAlignment(CENTER).borderWidthBottom(1.0F).lineSpacing(1F).build())				               
				                .backgroundColor(WHITE)
				                .font(PDType1Font.HELVETICA_BOLD)	
				                .textColor(Color.BLACK)
				                .build();
		          
		          Row gstRow = Row.builder()
			                .add(TextCell.builder().text(gstDetails).borderWidthBottom(0.5F).horizontalAlignment(CENTER).build())				               
			                .backgroundColor(WHITE)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD).fontSize(10)
			                .horizontalAlignment(CENTER)
			                .build();
		          
		          
		         tableHeaderBuilder.addRow(taxInvoice);
		         tableHeaderBuilder.addRow(headerRow);
		         tableHeaderBuilder.addRow(addressRow);
		         tableHeaderBuilder.addRow(mobileRow);
		         tableHeaderBuilder.addRow(gstRow);
		         
		         header = tableHeaderBuilder.build();
		         
		         
		        
		         
		      
		         TableBuilder billNumberDate = Table.builder()
			                .addColumnsOfWidth(139,137,137,137)				                
			                .font(HELVETICA)
			                .borderWidth(1)
			                .borderColor(Color.BLACK);
		         
		         
		         Row billNumberDateRow1 = Row.builder()
			                .add(TextCell.builder().text("Invoice Number").horizontalAlignment(LEFT).borderWidth(0.5F).fontSize(8).lineSpacing(1F).build())				               
			                .add(TextCell.builder().text(this.getBillInfoDAO().getBillNumber()).horizontalAlignment(LEFT).fontSize(10).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("Invoice Date").horizontalAlignment(RIGHT).borderWidth(0.5F).fontSize(8).lineSpacing(1F).build())				               
			                .add(TextCell.builder().text(this.getBillInfoDAO().getBillDate()).horizontalAlignment(LEFT).fontSize(10).borderWidth(0.5F).lineSpacing(1F).build())
			                .backgroundColor(WHITE)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD)				              
			                .horizontalAlignment(CENTER)
			                .build();
		         
		         Row billNumberDateRow2 = Row.builder()
			                .add(TextCell.builder().text("Mode Of Payment").horizontalAlignment(LEFT).borderWidth(0.5F).fontSize(8).lineSpacing(1F).build())				               
			                .add(TextCell.builder().text(this.getBillInfoDAO().getPaymentType()).horizontalAlignment(LEFT).borderWidth(0.5F).fontSize(8).lineSpacing(1F).build())				               
			                .add(TextCell.builder().text("Buyer Order Number").horizontalAlignment(RIGHT).borderWidth(0.5F).fontSize(8).lineSpacing(1F).build())				               
			                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).fontSize(8).lineSpacing(1F).build())		               
				            .backgroundColor(WHITE)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD)				              
			                .horizontalAlignment(CENTER)
			                .build();
		         Row billNumberDateRow3 = Row.builder()
			                .add(TextCell.builder().text("State: Maharatshtra ").horizontalAlignment(LEFT).borderWidth(0.5F).fontSize(10).lineSpacing(1F).build())				               
			                .add(TextCell.builder().text("Code : 27").horizontalAlignment(LEFT).borderWidth(0.5F).fontSize(10).lineSpacing(1F).build())
			                .add(TextCell.builder().text("Dispatch Doc. Number").horizontalAlignment(RIGHT).borderWidth(0.5F).fontSize(8).lineSpacing(1F).build())
			                .add(TextCell.builder().text("").horizontalAlignment(LEFT).fontSize(10).borderWidth(0.5F).lineSpacing(1F).build())
			                .backgroundColor(WHITE)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD).fontSize(10)				              
			                .horizontalAlignment(CENTER)
			                .build();
		         
		         billNumberDate.addRow(billNumberDateRow1);
		         billNumberDate.addRow(billNumberDateRow2);
		         billNumberDate.addRow(billNumberDateRow3);
		         billNumberTable =billNumberDate.build();
		       
		         
		         
		         TableBuilder tableCustDetailsBuilder = Table.builder()
			                .addColumnsOfWidth(510)				                
			                .font(HELVETICA)
			                .borderColor(Color.BLACK)
			                .horizontalAlignment(CENTER);
		         
		         Row custDetailsRow1 = Row.builder()
			                .add(TextCell.builder().text("Details Of Receiver (Billed To)").horizontalAlignment(CENTER).borderWidth(0).lineSpacing(1F).build())				                
			                .backgroundColor(WHITE)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD).fontSize(10)				              
			                .horizontalAlignment(CENTER)
			                .build();
		         
		         Row custDetailsRow2 = Row.builder()
			                .add(TextCell.builder().text("Customer Name:  "+this.getBillInfoDAO().getCustomerName()).horizontalAlignment(LEFT).borderWidth(0).borderWidthBottom(0.5F).lineSpacing(1F).build())				                
			                .backgroundColor(WHITE)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD).fontSize(9)				              
			                .horizontalAlignment(CENTER)
			                .build();
		         
		         Row custDetailsRow3 = Row.builder()
			                .add(TextCell.builder().text("Address:  "+custAddress).horizontalAlignment(LEFT).borderWidth(0).borderWidthBottom(0.5F).lineSpacing(1F).build())				                
			                .backgroundColor(WHITE)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD).fontSize(8)				              
			                .horizontalAlignment(CENTER)
			                .build();
		         
		         Row custDetailsRow4 = Row.builder()
			                .add(TextCell.builder().text("Mobile:  "+custMobile).horizontalAlignment(LEFT).borderWidth(0).borderWidthBottom(0.5F).lineSpacing(1F).build())				                
			                .backgroundColor(WHITE)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD).fontSize(9)				              
			                .horizontalAlignment(CENTER)
			                .build();
		         
		        
		         tableCustDetailsBuilder.addRow(custDetailsRow1);
		         tableCustDetailsBuilder.addRow(custDetailsRow2);
		         tableCustDetailsBuilder.addRow(custDetailsRow3);
		         tableCustDetailsBuilder.addRow(custDetailsRow4);
		      
		         
		         customerDetails = tableCustDetailsBuilder.build();
		        
		   
		         TableBuilder tableproductDetailsBuilder ;
		         Row productDetailsRow1;
		         
		         if(addMakingLaborColumn.equals("FALSE"))
		         {
		         tableproductDetailsBuilder = Table.builder()
			                .addColumnsOfWidth(20,145,55,25,25,55,35,50,35,50,55)				                
			                .font(HELVETICA)
			                .borderWidth(0.5F)
			                .borderColor(Color.BLACK);
		         
		         productDetailsRow1 = Row.builder()
			                .add(TextCell.builder().text("Sr.").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
			                .add(TextCell.builder().text("Description Of Goods | HSN Code").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("Unit Price").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("Qty").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
			                .add(TextCell.builder().text("Nos/Pcs").fontSize(6).rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
			                .add(TextCell.builder().text("Taxable Amount").rowSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("SGST").colSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("CGST").colSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("Total Amount").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
			                .backgroundColor(tableHedaerLightBlue)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD).fontSize(8)				              
			                .horizontalAlignment(CENTER)
			                .build();
		         
		         }else
		         {
		        	 tableproductDetailsBuilder = Table.builder()
				                .addColumnsOfWidth(20,135,45,25,25,50,35,45,35,45,50,50)				                
				                .font(HELVETICA)
				                .borderWidth(0.5F)
				                .borderColor(Color.BLACK);
		        	 productDetailsRow1 = Row.builder()
				                .add(TextCell.builder().text("Sr.").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
				                .add(TextCell.builder().text("Description Of Goods | HSN Code").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
				                .add(TextCell.builder().text("Unit Price").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
				                .add(TextCell.builder().text("Qty").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
				                .add(TextCell.builder().text("Nos/Psc").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())				                
				                .add(TextCell.builder().text("Taxable Amount").rowSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
				                .add(TextCell.builder().text("SGST").colSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
				                .add(TextCell.builder().text("CGST").colSpan(2).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
				                .add(TextCell.builder().text("Making/Labor Charges").fontSize(7).rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
				                .add(TextCell.builder().text("Total Amount").rowSpan(2).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(1F).build())
				                .backgroundColor(tableHedaerLightBlue)
				                .textColor(Color.BLACK)
				                .font(PDType1Font.HELVETICA_BOLD).fontSize(8)				              
				                .horizontalAlignment(CENTER)
				                .build();
			         
		         }
		         
		         tableproductDetailsBuilder.addRow(productDetailsRow1);
		         Row taxNameRow1 = Row.builder()
			              	.add(TextCell.builder().text("Rate %").horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("Amount").horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
			            	.add(TextCell.builder().text("Rate %").horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())
			                .add(TextCell.builder().text("Amount").horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())				               
			                .backgroundColor(tableHedaerLightBlue)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD).fontSize(8)				              
			                .horizontalAlignment(CENTER)
			                .build();
		         
		         tableproductDetailsBuilder.addRow(taxNameRow1);
		         
	         int srNo = 1;
		         
		         float allUnitTotalAmount = 0.0F;
		         float totalBasicAmount = 0.0F;
		         float totalCgstAmount = 0.0F;
		         float totalSgstAmount = 0.0f;
		         float totalMakingCharges = 0.0F;
		         for(int i =0;i<10;i++)
					{
		        	
		        	 
		        		BillProductInfoDAO informationDAO = null;
		        	 try
		        	 {
		        		 informationDAO =this.getProductInfoList().get(i);
		        	 }
		        	 catch(Exception e)
		        	 {
		        		 informationDAO = null;
		        	 }
		        			
		        	 if(informationDAO != null)
		        	 {
		        		 
		        		 float basicPrice = 0.0F;
		        		 float taxableAmount = 0.0F;
		        		 float totalUnitAmount = 0.0F;
		        		 float unitCgst = 0.0F;
		        		 float unitSgst = 0.0F;
		        		 float taxPercentage = 0.0F;
		        		 float halfTax = 0.0F;
		        		 float qty = informationDAO.getQuantity();
		        		 float makingLaborCharge = informationDAO.getMakingLaborCharge();
		        		 try
		        		 {
		        		 
		        			
		        		 basicPrice = informationDAO.getGrossAmount();
		        		 unitCgst = informationDAO.getCgst();
		        		 unitSgst = informationDAO.getSgst();
		        		 taxPercentage = informationDAO.getTaxPercentage();
		        		 
		        		 totalBasicAmount = totalBasicAmount + informationDAO.getGrossAmount();
		        		 totalCgstAmount = totalCgstAmount + informationDAO.getCgst();
		        		 totalSgstAmount = totalSgstAmount + informationDAO.getSgst();
		        		 taxableAmount = basicPrice*qty;
		        		 
		        		 totalUnitAmount = basicPrice + unitCgst + unitSgst ;
		        		 
		        		 allUnitTotalAmount = allUnitTotalAmount+ totalUnitAmount;
		        		 
		        		 halfTax  = taxPercentage/2.0F;
		        		 
		        		 }catch(NumberFormatException e)
		        		 {}
		        		 
		        		// int qty = Integer.parseInt(informationDAO.getProductQuantity());
		        		
		        		 Row productDetailsRow;
		        		 if(addMakingLaborColumn.equals("FALSE"))
				         {
		        	
		        		  productDetailsRow = Row.builder()
					                .add(TextCell.builder().text(""+srNo).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())				                
					                .add(TextCell.builder().text(informationDAO.getProductName().toUpperCase()+" ("+informationDAO.getProductCode()+")"+"\n[ HSN Code - "+informationDAO.getHsnCode()+" ]").fontSize(7).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(0.3F).build())
					                .add(TextCell.builder().text(df.format(informationDAO.getGrossAmount())).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
					                .add(TextCell.builder().text(df.format(informationDAO.getQuantity())).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())					                
					                .add(TextCell.builder().text(df.format(informationDAO.getQuantity2())).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())					                
						              
					                .add(TextCell.builder().text(df.format(taxableAmount)).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
					                .add(TextCell.builder().text(df.format(halfTax)).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
					                .add(TextCell.builder().text(df.format(informationDAO.getSgst())).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
					                .add(TextCell.builder().text(df.format(halfTax)).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
					                .add(TextCell.builder().text(df.format(informationDAO.getCgst())).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
					                .add(TextCell.builder().text(df.format(totalUnitAmount)).horizontalAlignment(RIGHT).verticalAlignment(MIDDLE).borderWidth(0.5F).lineSpacing(1F).build())
					                .backgroundColor(Color.WHITE)
					                .textColor(Color.BLACK)
					                .font(PDType1Font.HELVETICA)
					                .fontSize(9)				              
					                .horizontalAlignment(CENTER)
					                .height(22F)					                
					                .build();
				         
				         }
		        		 else
		        		 {
		        			
		        				 productDetailsRow = Row.builder()
						                .add(TextCell.builder().text(""+srNo).horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(1F).build())				                
						                .add(TextCell.builder().text(informationDAO.getProductName().toUpperCase()+" ("+informationDAO.getProductCode()+")"+"\n[ HSN Code - "+informationDAO.getHsnCode()+" ]").fontSize(7).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(0.3F).build())
						                .add(TextCell.builder().text(df.format(informationDAO.getGrossAmount())).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
						                .add(TextCell.builder().text(df.format(informationDAO.getQuantity())).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())					                
						                .add(TextCell.builder().text(df.format(informationDAO.getQuantity2())).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())					                
									    .add(TextCell.builder().text(df.format(taxableAmount)).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
						                .add(TextCell.builder().text(df.format(halfTax)).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
						                .add(TextCell.builder().text(df.format(informationDAO.getSgst())).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
						                .add(TextCell.builder().text(df.format(halfTax)).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
						                .add(TextCell.builder().text(df.format(informationDAO.getCgst())).horizontalAlignment(RIGHT).borderWidth(0.5F).verticalAlignment(MIDDLE).lineSpacing(1F).build())
						                .add(TextCell.builder().text(df.format(makingLaborCharge)).horizontalAlignment(RIGHT).verticalAlignment(MIDDLE).borderWidth(0.5F).lineSpacing(1F).build())
							            .add(TextCell.builder().text(df.format(totalUnitAmount)).horizontalAlignment(RIGHT).verticalAlignment(MIDDLE).borderWidth(0.5F).lineSpacing(1F).build())
						                .backgroundColor(Color.WHITE)
						                .textColor(Color.BLACK)
						                .font(PDType1Font.HELVETICA)
						                .fontSize(9)				              
						                .horizontalAlignment(CENTER)
						                .height(22F)					                
						                .build();
		        				 
		        				 totalMakingCharges = totalMakingCharges + makingLaborCharge;
					         
		        		 }
		        		 tableproductDetailsBuilder.addRow(productDetailsRow);
			         
			         srNo++;
		        	 }
		        	 
		        	 else
		        	 {
		        		 Row productDetailsRow;
		        		 if(addMakingLaborColumn.equals("FALSE"))
				         {

			        	   productDetailsRow = Row.builder()
					                .add(TextCell.builder().text("").horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(10F).build())				                
					                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
					                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
					                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
					                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
						            .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())						                
					                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
					                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
					                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
					                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
					                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
					                .backgroundColor(Color.WHITE)
					                .textColor(Color.BLACK)
					                .font(PDType1Font.HELVETICA)
					                .fontSize(8)				              
					                .horizontalAlignment(CENTER)
					                .height(23F)	
					                .build();
				         }
		        		 else
		        		 {
		        			 productDetailsRow = Row.builder()
						                .add(TextCell.builder().text("").horizontalAlignment(CENTER).borderWidth(0.5F).lineSpacing(10F).build())				                
						                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
						                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
						                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
						                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())						                
						                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())						                
						                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
						                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
						                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
						                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
						                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
						                .add(TextCell.builder().text("").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(10F).build())
							            .backgroundColor(Color.WHITE)
						                .textColor(Color.BLACK)
						                .font(PDType1Font.HELVETICA)
						                .fontSize(8)				              
						                .horizontalAlignment(CENTER)
						                .height(23F)	
						                .build();
		        		 }
				         tableproductDetailsBuilder.addRow(productDetailsRow);
				         
				         srNo++;
		        	 }
		         
		         }
		         
		         productDetails = tableproductDetailsBuilder.build();
		         
		         
		         
		         TableBuilder totalDetailsBuilder = Table.builder()
			                .addColumnsOfWidth(450,100)				                
			                .font(HELVETICA)
			                .borderWidth(1)
			                .borderColor(Color.BLACK);
		         
		         
		         Row totalDetailsRow1 = Row.builder()
			                .add(TextCell.builder().text("Total Taxable Amount").horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())				                
			                .add(TextCell.builder().text(df.format(totalBasicAmount)).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())
			                .backgroundColor(Color.WHITE)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD)
			                .fontSize(9)				              
			                .horizontalAlignment(CENTER)
			                .height(23F)	
			                .build();
		         totalDetailsBuilder.addRow(totalDetailsRow1);        
		         
		        
		         
		         
		         Row totalDetailsRow2 = Row.builder()
			                .add(TextCell.builder().text("Total SGST Amount").horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())				                
			                .add(TextCell.builder().text(df.format(totalSgstAmount)).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())
			                .backgroundColor(Color.WHITE)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD)
			                .fontSize(9)				              
			                .horizontalAlignment(CENTER)
			                .height(20F)	
			                .build();
		         totalDetailsBuilder.addRow(totalDetailsRow2);
		         
		         Row totalDetailsRow3 = Row.builder()
			                .add(TextCell.builder().text("Total CGST Amount").horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())				                
			                .add(TextCell.builder().text(df.format(totalCgstAmount)).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())
			                .backgroundColor(Color.WHITE)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD)
			                .fontSize(9)				              
			                .horizontalAlignment(CENTER)
			                .height(20F)	
			                .build();
		         totalDetailsBuilder.addRow(totalDetailsRow3);
		         
		         
		    
		         float totalTax = totalCgstAmount + totalSgstAmount;
		         
		         Row totalDetailsRow4 = Row.builder()
			                .add(TextCell.builder().text("Total TAX Amount").horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())				                
			                .add(TextCell.builder().text(""+totalTax).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())
			                .backgroundColor(Color.WHITE)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD)
			                .fontSize(9)				              
			                .horizontalAlignment(CENTER)
			                .height(20F)	
			                .build();
		         totalDetailsBuilder.addRow(totalDetailsRow4);
		         float roundOff = 0.0F;
		         float totalBillAmountAfterTax = Float.parseFloat(this.getBillInfoDAO().getTotalBillAmount());
		         float roundOffAmount = Math.round(totalBillAmountAfterTax);
		         roundOff = roundOffAmount - totalBillAmountAfterTax;
		         
		         if(addMakingLaborColumn.equals("TRUE"))
		         {
		        	 Row totalDetailsRowMaking = Row.builder()
				                .add(TextCell.builder().text("Making / Labor Charges").horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())				                
				                .add(TextCell.builder().text(df.format(totalMakingCharges)).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())
				                .backgroundColor(Color.WHITE)
				                .textColor(Color.BLACK)
				                .font(PDType1Font.HELVETICA_BOLD)
				                .fontSize(9)				              
				                .horizontalAlignment(CENTER)
				                .height(20F)	
				                .build();
			         totalDetailsBuilder.addRow(totalDetailsRowMaking);
		         }
		         
		         Row totalDetailsRow6 = Row.builder()
			                .add(TextCell.builder().text("Round Off").horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())				                
			                .add(TextCell.builder().text(""+roundOff).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())
			                .backgroundColor(Color.WHITE)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD)
			                .fontSize(9)				              
			                .horizontalAlignment(CENTER)
			                .height(20F)	
			                .build();
		         totalDetailsBuilder.addRow(totalDetailsRow6);
		         
		         Row totalDetailsRow5 = Row.builder()
			                .add(TextCell.builder().text("Total Amount After TAX").horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())				                
			                .add(TextCell.builder().text(this.getBillInfoDAO().getTotalBillAmount()).horizontalAlignment(RIGHT).borderWidth(0.5F).lineSpacing(10F).build())
			                .backgroundColor(Color.WHITE)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD)
			                .fontSize(9)				              
			                .horizontalAlignment(CENTER)
			                .height(20F)	
			                .build();
		         totalDetailsBuilder.addRow(totalDetailsRow5);
		         
		         
		        
		         
		         totalAmountDetails = totalDetailsBuilder.build();
		         
		       
		         
		         
		         TableBuilder tableBottomInfoBuilder = Table.builder()
			                .addColumnsOfWidth(550)				                
			                .font(HELVETICA)
			                .borderColor(Color.BLACK);
		         

		         Row bottomInfoRow1 = Row.builder()
			                .add(TextCell.builder().text("Declaration: "+declaration).horizontalAlignment(LEFT).borderWidth(0).borderWidthBottom(0.0F).verticalAlignment(BOTTOM).lineSpacing(10F).build())
			                .backgroundColor(Color.WHITE)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA)
			                .fontSize(9)				              
			                .horizontalAlignment(CENTER)
			                .height(20F)	
			                .build();
		         
		     
		         
		         
		         float totalAmounttoConvert = Float.parseFloat(this.getBillInfoDAO().getTotalBillAmount());
		      
		         String convertedAmount = new NumberToWordsConverter().getConverted(""+totalAmounttoConvert);
		      
		       Row bottomInfoRow3 = Row.builder()
			                .add(TextCell.builder().text("Amount in words :"+convertedAmount).horizontalAlignment(LEFT).borderWidth(0.5F).build())
			                .backgroundColor(Color.WHITE)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD)
			                .fontSize(9)				              
			                .horizontalAlignment(CENTER)
			                .height(20F)	
			                .build();
		       
		       tableBottomInfoBuilder.addRow(bottomInfoRow3);
		       if(this.getBillInfoDAO().getComments() == null)
		       {
		    	   this.getBillInfoDAO().setComments("NA");
		       }
		       if(this.getBillInfoDAO().getComments().equals("NA"))
		         {
		         Row bottomInfoRowComments = Row.builder()
			                .add(TextCell.builder().text("Comments:").horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(0.5F).build())
			                .backgroundColor(Color.WHITE)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA)
			                .fontSize(10)
			                .height(30F)
			                .horizontalAlignment(CENTER)					               	
			                .build();
		         tableBottomInfoBuilder.addRow(bottomInfoRowComments);
		         
		         }
		         else
		         {
		        	 Row bottomInfoRowComments = Row.builder()
				                .add(TextCell.builder().text("Comments:"+this.getBillInfoDAO().getComments()).horizontalAlignment(LEFT).borderWidth(0.5F).lineSpacing(0.5F).build())
				                .backgroundColor(Color.WHITE)
				                .textColor(Color.BLACK)
				                .font(PDType1Font.HELVETICA)
				                .fontSize(10)
				                .height(30F)
				                .horizontalAlignment(CENTER)					               	
				                .build();
			         tableBottomInfoBuilder.addRow(bottomInfoRowComments);
		         }
		     			        
		       tableBottomInfoBuilder.addRow(bottomInfoRow1);
		         
		         bottomInfo = tableBottomInfoBuilder.build();
		         
		         
		         
		         TableBuilder signatureBuiler = Table.builder()
			                .addColumnsOfWidth(275,275)				                
			                .font(HELVETICA)
			                .borderColor(Color.BLACK)
			                .horizontalAlignment(CENTER);
		         
		         
		         Row signRow1 = Row.builder()
			                .add(TextCell.builder().text("Receiver Signature").verticalAlignment(BOTTOM).horizontalAlignment(CENTER).borderWidth(0).lineSpacing(10F).build())
			                .add(TextCell.builder().text("For Propriter").verticalAlignment(BOTTOM).horizontalAlignment(CENTER).borderWidth(0).lineSpacing(10F).build())					               
			                .backgroundColor(Color.WHITE)
			                .textColor(Color.BLACK)
			                .font(PDType1Font.HELVETICA_BOLD)
			                .fontSize(9)				              
			                .horizontalAlignment(CENTER)
			                .height(20F)	
			                .build();
		         signatureBuiler.addRow(signRow1);
		       
		         
		         signature = signatureBuiler.build();   
	        
		         float startY = page.getMediaBox().getHeight() - PADDING20;
			        
			       
		         float yCordinate = page.getCropBox().getUpperRightY() - 72;
		         float startX = page.getCropBox().getLowerLeftX() + 10;
		         float endX = page.getCropBox().getUpperRightX() - 10;
		       
		     /*  contentStream.setLineWidth(0.6f);
		        contentStream.moveTo(startX, yCordinate);
		        contentStream.lineTo(endX, yCordinate);
		        contentStream.stroke();
		        
		        yCordinate = yCordinate - 15;
		        
		        contentStream.moveTo(startX, yCordinate);
		        contentStream.lineTo(endX, yCordinate);
		        contentStream.stroke();
		        */
		        
		       TableDrawer.builder()
	            .contentStream(contentStream)
	            .table(header)
	            .startX(PADDING30)
	            .startY(startY)
	            .build()
	            .draw();
		       
		        
		      
		        TableDrawer.builder()
	            .contentStream(contentStream)
	            .table(billNumberTable)
	            .startX(PADDING30)
	            .startY(startY-100)
	            .build()
	            .draw();
		        
		        TableDrawer.builder()
	            .contentStream(contentStream)
	            .table(customerDetails)
	            .startX(PADDING30)
	            .startY(startY-150)
	            .build()
	            .draw();
		        
		        TableDrawer.builder()
	            .contentStream(contentStream)
	            .table(productDetails)
	            .startX(PADDING30)
	            .startY(startY-230)
	            .build()
	            .draw();
		        
		       TableDrawer.builder()
	            .contentStream(contentStream)
	            .table(totalAmountDetails)
	            .startX(PADDING30)
	            .startY(startY-485)
	            .build()
	            .draw();
		       if(addMakingLaborColumn.equals("TRUE"))
		         {
			        TableDrawer.builder()
		            .contentStream(contentStream)
		            .table(bottomInfo)
		            .startX(PADDING30)
		            .startY(startY-625)
		            .build()
		            .draw();
			        
			        TableDrawer.builder()
		            .contentStream(contentStream)
		            .table(signature)
		            .startX(PADDING30)
		            .startY(startY-785)
		            .build()
		            .draw();
		         }
		       	else
		         {
		        	   TableDrawer.builder()
			            .contentStream(contentStream)
			            .table(bottomInfo)
			            .startX(PADDING30)
			            .startY(startY-605)
			            .build()
			            .draw();
		        	   
		        	   TableDrawer.builder()
		               .contentStream(contentStream)
		               .table(signature)
		               .startX(PADDING30)
		               .startY(startY-780)
		               .build()
		               .draw();
		        	 
		         }
		        
		     
		   
			    contentStream.close();
		        
		       // System.out.println(path);
						
		        
		        addPageNumbers(document);
		        document.save(path+"/invoice.pdf");
		        document.close();
		        
		        

				response.setHeader("Content-disposition", "inline; filename=tax-invoice.pdf");
				response.setContentType("application/pdf");
				@SuppressWarnings("resource")
				FileInputStream fileInputStream = new FileInputStream(path+"/invoice.pdf");
				PrintWriter out = response.getWriter();  
				int bytes;
				while ((bytes = fileInputStream.read()) != -1) {
					out.write(bytes);
				}
				fileInputStream.close();
				out.flush();
				out.close();
	        	 
				
	     	 }
         
		}
		         
		         
		         
	         	
				}
				
	        	}
	        	catch (SQLException e) {
	        		e.printStackTrace();
					
				} catch (IOException e) {
					e.printStackTrace();
					
				}catch (Exception e) {
					e.printStackTrace();
					
				}finally {
					if(resultSet != null)
    				{
    					try {
    						resultSet.close(); resultSet = null;
    					} catch (SQLException e) {
    						
    					}
    				}
					if(preparedStatement != null)
					{
						try {preparedStatement.close(); preparedStatement = null;} catch (SQLException e) {}
					}
					if(connection != null)
					{
						
						try {connection.close(); connection = null;}catch (SQLException e) {}
					}
					
					
	        	}
				
	   }

	private void addPageNumbers(PDDocument document) throws IOException {
		final int totalPages = document.getNumberOfPages();
		int pageNumber = 1;
		for (PDPage page : document.getPages()) {
			final String pageLabel = "Page " + pageNumber + " of " + totalPages;
			try (PDPageContentStream pageNumberStream = new PDPageContentStream(
					document, page, AppendMode.APPEND, true, true)) {
				pageNumberStream.beginText();
				pageNumberStream.setFont(PDType1Font.HELVETICA_BOLD, 8);
				pageNumberStream.newLineAtOffset(PADDING30, 8);
				pageNumberStream.showText(pageLabel);
				pageNumberStream.endText();
			}
			pageNumber++;
		}
	}

	public HttpSession getSession() {
		return session;
	}

	public void setSession(HttpSession session) {
		this.session = session;
	}

	public SessionMap<String, Object> getSessionMap() {
		return sessionMap;
	}

	public void setSessionMap(SessionMap<String, Object> sessionMap) {
		this.sessionMap = sessionMap;
	}

	public BillInformationDAO getBillInfoDAO() {
		return billInfoDAO;
	}

	public void setBillInfoDAO(BillInformationDAO billInfoDAO) {
		this.billInfoDAO = billInfoDAO;
	}

	public List<BillProductInfoDAO> getProductInfoList() {
		return productInfoList;
	}

	public void setProductInfoList(List<BillProductInfoDAO> productInfoList) {
		this.productInfoList = productInfoList;
	}


	private String getHeaderShopName() {
		String currentBillType = this.getBillInfoDAO() != null ? this.getBillInfoDAO().getBillType() : null;
		if ("QUOTATION".equals(currentBillType) || "ESTIMATE".equals(currentBillType)) {
			String estimateQuotationShopName = (String)this.getSessionMap().get("shopnameenglishestiquote");
			if (estimateQuotationShopName != null && !estimateQuotationShopName.trim().isEmpty()) {
				return estimateQuotationShopName;
			}
		}
		return (String)this.getSessionMap().get("shopnameenglish");
	}


	public void setSession(Map<String, Object> map) {  
	    sessionMap=(SessionMap<String, Object>)map;  
	}

	public HttpServletRequest getRequest() {
		return request;
	}

	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}

	public HttpServletResponse getResponse() {
		return response;
	}

	public void setResponse(HttpServletResponse response) {
		this.response = response;
	}

	public String getBillNumber() {
		return billNumber;
	}

	public void setBillNumber(String billNumber) {
		this.billNumber = billNumber;
	}

	public String getBillType() {
		return billType;
	}

	public void setBillType(String billType) {
		this.billType = billType;
	}

	public String getTypeOfBill() {
		return typeOfBill;
	}

	public void setTypeOfBill(String typeOfBill) {
		this.typeOfBill = typeOfBill;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getLanguage() {
		return language;
	}

	public void setLanguage(String language) {
		this.language = language;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public String getBillDateTime() {
		return billDateTime;
	}

	public void setBillDateTime(String billDateTime) {
		this.billDateTime = billDateTime;
	}
	
	
	
	
	

}
