| 21686 |
ashik.ali |
1 |
package com.spice.profitmandi.common.util;
|
|
|
2 |
|
|
|
3 |
|
|
|
4 |
import java.io.OutputStream;
|
| 21915 |
ashik.ali |
5 |
import java.util.Locale;
|
| 21686 |
ashik.ali |
6 |
import java.util.Set;
|
|
|
7 |
|
|
|
8 |
import org.slf4j.Logger;
|
|
|
9 |
import org.slf4j.LoggerFactory;
|
| 22068 |
ashik.ali |
10 |
import org.springframework.util.StringUtils;
|
| 21686 |
ashik.ali |
11 |
|
| 21915 |
ashik.ali |
12 |
import com.ibm.icu.text.RuleBasedNumberFormat;
|
| 21686 |
ashik.ali |
13 |
import com.itextpdf.text.Chunk;
|
|
|
14 |
import com.itextpdf.text.Document;
|
|
|
15 |
import com.itextpdf.text.DocumentException;
|
|
|
16 |
import com.itextpdf.text.Element;
|
|
|
17 |
import com.itextpdf.text.Font;
|
|
|
18 |
import com.itextpdf.text.Paragraph;
|
|
|
19 |
import com.itextpdf.text.Rectangle;
|
|
|
20 |
import com.itextpdf.text.pdf.PdfPCell;
|
|
|
21 |
import com.itextpdf.text.pdf.PdfPTable;
|
|
|
22 |
import com.itextpdf.text.pdf.PdfWriter;
|
|
|
23 |
import com.spice.profitmandi.common.model.CustomCustomer;
|
| 22858 |
ashik.ali |
24 |
import com.spice.profitmandi.common.model.CustomOrderItem;
|
| 22215 |
ashik.ali |
25 |
import com.spice.profitmandi.common.model.CustomInsurancePolicy;
|
| 21686 |
ashik.ali |
26 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
|
|
27 |
import com.spice.profitmandi.common.model.PdfModel;
|
|
|
28 |
|
|
|
29 |
public class PdfUtils {
|
|
|
30 |
|
|
|
31 |
private static final Font FONT_TITLE = new Font(Font.FontFamily.HELVETICA , 18, Font.BOLD);
|
| 21965 |
ashik.ali |
32 |
private static Font FONT_NORMAL = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL);
|
|
|
33 |
private static Font FONT_BOLD = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD);
|
| 21686 |
ashik.ali |
34 |
//private static Font fontTableHeader = new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD);
|
| 21926 |
ashik.ali |
35 |
private static final String INVOICE_TITLE = "INVOICE";
|
| 21686 |
ashik.ali |
36 |
|
| 22685 |
amit.gupta |
37 |
private static float[] igstWidthsWithDiscount = new float[]{.3f, 2.6f, 0.7f, .4f, 0.7f, 0.5f, .7f, .6f, 0.6f, 0.9f};
|
|
|
38 |
private static float[] stateWidthsWithDiscount = new float[]{.2f, 2.1f, 0.7f, .3f, 0.6f, 0.4f, .7f, .5f, .6f, .5f, .6f, .8f};
|
| 22681 |
amit.gupta |
39 |
|
| 21915 |
ashik.ali |
40 |
private static final Locale indianLocale = Locale.getDefault();
|
|
|
41 |
|
| 21686 |
ashik.ali |
42 |
private static final Logger LOGGER = LoggerFactory.getLogger(PdfUtils.class);
|
|
|
43 |
|
|
|
44 |
public static void generateAndWrite(PdfModel pdfModel, OutputStream outputStream){
|
|
|
45 |
Document document = new Document();
|
| 21926 |
ashik.ali |
46 |
document.setMargins(0, 0, 25, 0);
|
| 21686 |
ashik.ali |
47 |
try {
|
|
|
48 |
CustomCustomer customer = pdfModel.getCustomer();
|
|
|
49 |
CustomRetailer retailer = pdfModel.getRetailer();
|
| 22690 |
amit.gupta |
50 |
boolean stateGst = false;
|
| 21901 |
ashik.ali |
51 |
String customerAddressStateCode = "", retailerAddressStateCode = "";
|
|
|
52 |
if(customer.getAddress().getState().equals(retailer.getAddress().getState())){
|
| 22690 |
amit.gupta |
53 |
stateGst = true;
|
| 21901 |
ashik.ali |
54 |
customerAddressStateCode = Utils.getStateCode(customer.getAddress().getState());
|
|
|
55 |
}else{
|
|
|
56 |
customerAddressStateCode = Utils.getStateCode(customer.getAddress().getState());
|
|
|
57 |
retailerAddressStateCode = Utils.getStateCode(retailer.getAddress().getState());
|
|
|
58 |
}
|
| 22858 |
ashik.ali |
59 |
Set<CustomOrderItem> orderItems = pdfModel.getOrderItems();
|
| 21686 |
ashik.ali |
60 |
|
|
|
61 |
PdfWriter.getInstance(document,outputStream);
|
|
|
62 |
|
|
|
63 |
document.open();
|
|
|
64 |
document.addTitle(pdfModel.getTitle());
|
|
|
65 |
document.addAuthor(pdfModel.getAuther());
|
|
|
66 |
|
|
|
67 |
Paragraph paragraphTitle = new Paragraph(INVOICE_TITLE, FONT_TITLE);
|
|
|
68 |
paragraphTitle.setAlignment(Element.ALIGN_CENTER);
|
|
|
69 |
|
|
|
70 |
PdfPCell blankCell = new PdfPCell();
|
|
|
71 |
blankCell.setBorder(Rectangle.NO_BORDER);
|
|
|
72 |
PdfPTable tableCustomerRetailer = new PdfPTable(3);
|
| 22025 |
ashik.ali |
73 |
tableCustomerRetailer.setWidthPercentage(90);
|
| 21686 |
ashik.ali |
74 |
tableCustomerRetailer.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
|
|
75 |
PdfPCell columnCustomerInfo = new PdfPCell();
|
| 22691 |
amit.gupta |
76 |
columnCustomerInfo.addElement(new Paragraph("Customer Details", FONT_BOLD));
|
| 22215 |
ashik.ali |
77 |
columnCustomerInfo.addElement(new Paragraph(StringUtils.capitalize(customer.getFirstName() + " " + customer.getLastName()), FONT_NORMAL));
|
| 22068 |
ashik.ali |
78 |
columnCustomerInfo.addElement(new Paragraph(StringUtils.capitalize(customer.getAddress().getLine1()) + ", " + StringUtils.capitalize(customer.getAddress().getLine2()), FONT_NORMAL));
|
|
|
79 |
columnCustomerInfo.addElement(new Paragraph(StringUtils.capitalize(customer.getAddress().getCity()) + ", " + StringUtils.capitalize(customer.getAddress().getState()) + "(" + customerAddressStateCode + ")" + "\n" + customer.getAddress().getPinCode(), FONT_NORMAL));
|
| 22691 |
amit.gupta |
80 |
columnCustomerInfo.addElement(new Paragraph("Mobile - " + customer.getMobileNumber(), FONT_NORMAL));
|
| 21686 |
ashik.ali |
81 |
columnCustomerInfo.setBorder(Rectangle.NO_BORDER);
|
|
|
82 |
PdfPCell columnRetailerInfo = new PdfPCell();
|
| 22068 |
ashik.ali |
83 |
columnRetailerInfo.addElement(new Paragraph(StringUtils.capitalize(retailer.getBusinessName()), FONT_BOLD));
|
| 22690 |
amit.gupta |
84 |
columnRetailerInfo.addElement(new Paragraph(StringUtils.capitalize(retailer.getAddress().getLine1()) + ", " + StringUtils.capitalize(retailer.getAddress().getLine2()) + ", " + StringUtils.capitalize(retailer.getAddress().getCity()) + "-" + retailer.getAddress().getPinCode() + ", " + retailer.getAddress().getState() + "(" + (stateGst? customerAddressStateCode : retailerAddressStateCode) + ")", FONT_BOLD));
|
| 21686 |
ashik.ali |
85 |
columnRetailerInfo.addElement(new Paragraph("Contact No.- "+retailer.getMobileNumber(), FONT_BOLD));
|
| 22351 |
ashik.ali |
86 |
columnRetailerInfo.addElement(new Paragraph("GST NO. " + retailer.getGstNumber(), FONT_BOLD));
|
| 21686 |
ashik.ali |
87 |
columnRetailerInfo.setBorder(Rectangle.NO_BORDER);
|
| 22687 |
amit.gupta |
88 |
|
| 21686 |
ashik.ali |
89 |
PdfPTable tableInvoiceDateRetailer = new PdfPTable(1);
|
|
|
90 |
tableInvoiceDateRetailer.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 22687 |
amit.gupta |
91 |
|
| 21686 |
ashik.ali |
92 |
PdfPTable tableInvoiceDate = new PdfPTable(2);
|
|
|
93 |
tableInvoiceDate.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 22687 |
amit.gupta |
94 |
|
| 21686 |
ashik.ali |
95 |
PdfPCell invoiceNumberKey = new PdfPCell(new Paragraph("Invoice No:", FONT_NORMAL));
|
|
|
96 |
invoiceNumberKey.setBorder(Rectangle.NO_BORDER);
|
| 22687 |
amit.gupta |
97 |
|
| 21686 |
ashik.ali |
98 |
PdfPCell invoiceNumberValue = new PdfPCell(new Paragraph(pdfModel.getInvoiceNumber(), FONT_NORMAL));
|
|
|
99 |
invoiceNumberValue.setBorder(Rectangle.NO_BORDER);
|
| 22687 |
amit.gupta |
100 |
|
| 21686 |
ashik.ali |
101 |
PdfPCell dateKey = new PdfPCell(new Paragraph("Date:", FONT_NORMAL));
|
|
|
102 |
dateKey.setBorder(Rectangle.NO_BORDER);
|
| 22687 |
amit.gupta |
103 |
|
|
|
104 |
PdfPCell dateValue = new PdfPCell(new Paragraph(pdfModel.getInvoiceDate(), FONT_NORMAL));
|
| 21686 |
ashik.ali |
105 |
dateValue.setBorder(Rectangle.NO_BORDER);
|
|
|
106 |
tableInvoiceDate.addCell(invoiceNumberKey);
|
|
|
107 |
//tableInvoiceDate.addCell(blankCell);
|
|
|
108 |
tableInvoiceDate.addCell(invoiceNumberValue);
|
|
|
109 |
tableInvoiceDate.addCell(dateKey);
|
|
|
110 |
//tableInvoiceDate.addCell(blankCell);
|
|
|
111 |
tableInvoiceDate.addCell(dateValue);
|
|
|
112 |
tableInvoiceDateRetailer.addCell(tableInvoiceDate);
|
|
|
113 |
tableInvoiceDateRetailer.addCell(columnRetailerInfo);
|
|
|
114 |
|
|
|
115 |
tableCustomerRetailer.addCell(columnCustomerInfo);
|
|
|
116 |
tableCustomerRetailer.addCell(blankCell);
|
|
|
117 |
tableCustomerRetailer.addCell(tableInvoiceDateRetailer);
|
|
|
118 |
|
| 21901 |
ashik.ali |
119 |
PdfPTable orders = null;
|
| 22690 |
amit.gupta |
120 |
if(stateGst){
|
|
|
121 |
orders = new PdfPTable(stateWidthsWithDiscount.length);
|
|
|
122 |
orders.setWidths(stateWidthsWithDiscount);
|
|
|
123 |
}else{
|
| 22685 |
amit.gupta |
124 |
orders = new PdfPTable(igstWidthsWithDiscount.length);
|
|
|
125 |
orders.setWidths(igstWidthsWithDiscount);
|
| 21901 |
ashik.ali |
126 |
}
|
| 22025 |
ashik.ali |
127 |
orders.setWidthPercentage(90);
|
| 22684 |
amit.gupta |
128 |
orders.addCell(new Paragraph("Sl", FONT_BOLD));
|
| 21686 |
ashik.ali |
129 |
orders.addCell(new Paragraph("Description", FONT_BOLD));
|
| 22668 |
amit.gupta |
130 |
orders.addCell(new Paragraph("HSN", FONT_BOLD));
|
| 22025 |
ashik.ali |
131 |
orders.addCell(new Paragraph("Qty", FONT_BOLD));
|
| 22684 |
amit.gupta |
132 |
orders.addCell(new Paragraph("Rate\n(Per pc)", FONT_BOLD));
|
|
|
133 |
orders.addCell(new Paragraph("Disc.", FONT_BOLD));
|
| 22690 |
amit.gupta |
134 |
orders.addCell(new Paragraph("Total\nTaxable", FONT_BOLD));
|
|
|
135 |
if(!stateGst){
|
| 22684 |
amit.gupta |
136 |
orders.addCell(new Paragraph("IGST\n%", FONT_BOLD));
|
| 22669 |
amit.gupta |
137 |
orders.addCell(new Paragraph("IGST", FONT_BOLD));
|
| 22025 |
ashik.ali |
138 |
//orders.setWidths(new float[]{1, 3, 1, 1, 1, 1, 1, 1});
|
| 22681 |
amit.gupta |
139 |
//total 8f
|
| 21901 |
ashik.ali |
140 |
}else{
|
| 22669 |
amit.gupta |
141 |
orders.addCell(new Paragraph("CGST %", FONT_BOLD));
|
|
|
142 |
orders.addCell(new Paragraph("CGST", FONT_BOLD));
|
|
|
143 |
orders.addCell(new Paragraph("SGST %", FONT_BOLD));
|
|
|
144 |
orders.addCell(new Paragraph("SGST", FONT_BOLD));
|
| 22025 |
ashik.ali |
145 |
//orders.setWidths(new float[]{1, 3, 1, 1, 1, 1, 1, 1, 1, 1});
|
| 22684 |
amit.gupta |
146 |
//total 8f
|
| 21901 |
ashik.ali |
147 |
}
|
| 22684 |
amit.gupta |
148 |
orders.addCell(new Paragraph("Total", FONT_BOLD));
|
| 21901 |
ashik.ali |
149 |
|
|
|
150 |
//orders.addCell(new Paragraph("Item Total (Rs)", FONT_BOLD));
|
|
|
151 |
|
| 21686 |
ashik.ali |
152 |
orders.setHeaderRows(1);
|
|
|
153 |
//orders.setSkipFirstHeader(true);
|
| 21901 |
ashik.ali |
154 |
|
| 21926 |
ashik.ali |
155 |
float igstTotalAmount = 0, cgstTotalAmount = 0, sgstTotalAmount = 0;
|
| 21686 |
ashik.ali |
156 |
int index = 1;
|
| 22858 |
ashik.ali |
157 |
for(CustomOrderItem orderItem : orderItems){
|
| 21686 |
ashik.ali |
158 |
orders.addCell(new Paragraph(String.valueOf(index++), FONT_NORMAL));
|
|
|
159 |
orders.addCell(new Paragraph(orderItem.getDescription(), FONT_NORMAL));
|
| 21901 |
ashik.ali |
160 |
orders.addCell(new Paragraph(orderItem.getHsnCode(), FONT_NORMAL));
|
| 21686 |
ashik.ali |
161 |
orders.addCell(new Paragraph(String.valueOf(orderItem.getQuantity()), FONT_NORMAL));
|
| 22025 |
ashik.ali |
162 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getRate()), FONT_NORMAL));
|
| 22668 |
amit.gupta |
163 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getDiscount()), FONT_NORMAL));
|
| 21926 |
ashik.ali |
164 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getAmount()), FONT_NORMAL));
|
| 22690 |
amit.gupta |
165 |
if(!stateGst){
|
| 21926 |
ashik.ali |
166 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getIgstRate()), FONT_NORMAL));
|
|
|
167 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getIgstAmount()), FONT_NORMAL));
|
|
|
168 |
igstTotalAmount = igstTotalAmount + orderItem.getIgstAmount();
|
| 21901 |
ashik.ali |
169 |
}else{
|
| 21926 |
ashik.ali |
170 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getCgstRate()), FONT_NORMAL));
|
|
|
171 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getCgstAmount()), FONT_NORMAL));
|
|
|
172 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getSgstRate()), FONT_NORMAL));
|
|
|
173 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getSgstAmount()), FONT_NORMAL));
|
|
|
174 |
cgstTotalAmount = cgstTotalAmount + orderItem.getCgstAmount();
|
|
|
175 |
sgstTotalAmount = sgstTotalAmount + orderItem.getSgstAmount();
|
| 21901 |
ashik.ali |
176 |
}
|
| 22684 |
amit.gupta |
177 |
orders.addCell(new Paragraph(String.format("%.0f", orderItem.getNetAmount()), FONT_NORMAL));
|
| 22025 |
ashik.ali |
178 |
//orders.addCell(new Paragraph(String.format("%.2f", orderItem.getItemTotal()), FONT_NORMAL));
|
| 21686 |
ashik.ali |
179 |
}
|
| 22215 |
ashik.ali |
180 |
|
|
|
181 |
for(CustomInsurancePolicy insurancePolicy : pdfModel.getInsurancePolicies()){
|
|
|
182 |
orders.addCell(new Paragraph(String.valueOf(index++), FONT_NORMAL));
|
|
|
183 |
orders.addCell(new Paragraph(insurancePolicy.getDescription(), FONT_NORMAL));
|
|
|
184 |
orders.addCell(new Paragraph(insurancePolicy.getHsnCode(), FONT_NORMAL));
|
|
|
185 |
orders.addCell(new Paragraph("1", FONT_NORMAL));
|
|
|
186 |
orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getRate()), FONT_NORMAL));
|
| 22671 |
amit.gupta |
187 |
orders.addCell(new Paragraph("-", FONT_NORMAL));
|
| 22215 |
ashik.ali |
188 |
orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getRate()), FONT_NORMAL));
|
| 22690 |
amit.gupta |
189 |
if(!stateGst){
|
| 22215 |
ashik.ali |
190 |
orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getIgstRate()), FONT_NORMAL));
|
|
|
191 |
orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getIgstAmount()), FONT_NORMAL));
|
|
|
192 |
igstTotalAmount = igstTotalAmount + insurancePolicy.getIgstAmount();
|
|
|
193 |
}else{
|
|
|
194 |
orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getCgstRate()), FONT_NORMAL));
|
|
|
195 |
orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getCgstAmount()), FONT_NORMAL));
|
|
|
196 |
orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getSgstRate()), FONT_NORMAL));
|
|
|
197 |
orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getSgstAmount()), FONT_NORMAL));
|
|
|
198 |
cgstTotalAmount = cgstTotalAmount + insurancePolicy.getCgstAmount();
|
|
|
199 |
sgstTotalAmount = sgstTotalAmount + insurancePolicy.getSgstAmount();
|
|
|
200 |
}
|
| 22684 |
amit.gupta |
201 |
orders.addCell(new Paragraph(String.format("%.0f", insurancePolicy.getNetAmount()), FONT_NORMAL));
|
| 22215 |
ashik.ali |
202 |
}
|
| 22889 |
amit.gupta |
203 |
|
|
|
204 |
document.add(paragraphTitle);
|
| 21686 |
ashik.ali |
205 |
document.add(Chunk.NEWLINE);
|
|
|
206 |
document.add(Chunk.NEWLINE);
|
|
|
207 |
document.add(tableCustomerRetailer);
|
|
|
208 |
|
|
|
209 |
document.add(Chunk.NEWLINE);
|
|
|
210 |
document.add(orders);
|
| 21926 |
ashik.ali |
211 |
|
| 21965 |
ashik.ali |
212 |
PdfPTable grandTotalTable = new PdfPTable(3);
|
| 22690 |
amit.gupta |
213 |
if(stateGst){
|
| 22691 |
amit.gupta |
214 |
grandTotalTable.setWidths(new float[]{6.6f, .6f, .8f});
|
|
|
215 |
}else{
|
| 22690 |
amit.gupta |
216 |
grandTotalTable.setWidths(new float[]{6.5f, .6f, .9f});
|
| 21901 |
ashik.ali |
217 |
}
|
| 22025 |
ashik.ali |
218 |
grandTotalTable.setWidthPercentage(90);
|
| 21901 |
ashik.ali |
219 |
|
| 21686 |
ashik.ali |
220 |
Paragraph grandTotalParagraph = new Paragraph("Grand total", FONT_BOLD);
|
|
|
221 |
grandTotalParagraph.setIndentationRight(20);
|
|
|
222 |
grandTotalTable.addCell(grandTotalParagraph);
|
|
|
223 |
Paragraph rsParagraph = new Paragraph("Rs.", FONT_BOLD);
|
|
|
224 |
grandTotalTable.addCell(rsParagraph);
|
| 21926 |
ashik.ali |
225 |
Paragraph amountParagraph = new Paragraph(String.format("%.2f", pdfModel.getTotalAmount()), FONT_BOLD);
|
| 21686 |
ashik.ali |
226 |
grandTotalTable.addCell(amountParagraph);
|
|
|
227 |
|
| 21926 |
ashik.ali |
228 |
|
| 21686 |
ashik.ali |
229 |
document.add(grandTotalTable);
|
|
|
230 |
|
|
|
231 |
PdfPTable amountInWordsTable = new PdfPTable(3);
|
| 22690 |
amit.gupta |
232 |
if(!stateGst){
|
| 22684 |
amit.gupta |
233 |
amountInWordsTable.setWidths(new float[]{2, 5.1f, 0.9f});
|
| 21965 |
ashik.ali |
234 |
}else{
|
| 22684 |
amit.gupta |
235 |
amountInWordsTable.setWidths(new float[]{2, 5.2f, 0.8f});
|
| 21965 |
ashik.ali |
236 |
}
|
| 22025 |
ashik.ali |
237 |
amountInWordsTable.setWidthPercentage(90);
|
| 21686 |
ashik.ali |
238 |
amountInWordsTable.addCell(new Paragraph("Amount in Words:", FONT_BOLD));
|
| 21915 |
ashik.ali |
239 |
|
|
|
240 |
String amountInWords = toAmountInWords(pdfModel.getTotalAmount());
|
|
|
241 |
amountInWordsTable.addCell(new Paragraph(amountInWords.toString(), FONT_BOLD));
|
| 21686 |
ashik.ali |
242 |
amountInWordsTable.addCell(new Paragraph("E & O.E", FONT_NORMAL));
|
| 21915 |
ashik.ali |
243 |
document.add(amountInWordsTable);
|
| 21686 |
ashik.ali |
244 |
|
| 22692 |
amit.gupta |
245 |
StringBuffer sb = new StringBuffer();
|
|
|
246 |
sb.append("I agree that goods received are in good working condition");
|
| 22706 |
amit.gupta |
247 |
sb.append("\nGoods once sold cannot be exchanged or taken back");
|
|
|
248 |
sb.append("\nWarranty for the goods received by me is the responsibility of the manufacturer only.");
|
| 22692 |
amit.gupta |
249 |
if(pdfModel.getInsurancePolicies() != null && pdfModel.getInsurancePolicies().size() > 0) {
|
| 22706 |
amit.gupta |
250 |
sb.append("\nDamage protection provided is the responisibility of Protection Provider only");
|
| 22692 |
amit.gupta |
251 |
}
|
|
|
252 |
Paragraph warningParagraph = new Paragraph(sb.toString(), FONT_NORMAL);
|
| 22025 |
ashik.ali |
253 |
warningParagraph.setIndentationLeft(40);
|
| 21686 |
ashik.ali |
254 |
document.add(Chunk.NEWLINE);
|
|
|
255 |
document.add(warningParagraph);
|
|
|
256 |
|
|
|
257 |
document.close(); // no need to close PDFwriter?
|
|
|
258 |
|
|
|
259 |
} catch (DocumentException e) {
|
|
|
260 |
LOGGER.error("Unable to write data to pdf file : ", e);
|
| 21901 |
ashik.ali |
261 |
} catch (Exception e) {
|
|
|
262 |
// TODO Auto-generated catch block
|
|
|
263 |
e.printStackTrace();
|
|
|
264 |
}
|
| 21686 |
ashik.ali |
265 |
}
|
| 21915 |
ashik.ali |
266 |
|
| 22889 |
amit.gupta |
267 |
//
|
|
|
268 |
private static void generatePdfInvoice(InvoiceModel model, OutputStream outputStream) {
|
|
|
269 |
Document document = new Document();
|
|
|
270 |
document.setMargins(0, 0, 25, 0);
|
|
|
271 |
|
|
|
272 |
}
|
|
|
273 |
|
| 21915 |
ashik.ali |
274 |
private static String toAmountInWords(float amount){
|
|
|
275 |
RuleBasedNumberFormat amountInWordsFormat = new RuleBasedNumberFormat(indianLocale, RuleBasedNumberFormat.SPELLOUT);
|
|
|
276 |
StringBuilder amountInWords = new StringBuilder("Rs. ");
|
| 22068 |
ashik.ali |
277 |
amountInWords.append(StringUtils.capitalize(amountInWordsFormat.format((int)amount)));
|
| 21915 |
ashik.ali |
278 |
amountInWords.append(" and ");
|
| 22068 |
ashik.ali |
279 |
amountInWords.append(StringUtils.capitalize(amountInWordsFormat.format((int)(amount*100)%100)));
|
| 21915 |
ashik.ali |
280 |
amountInWords.append(" paise");
|
|
|
281 |
return amountInWords.toString();
|
|
|
282 |
}
|
| 21686 |
ashik.ali |
283 |
}
|