| Line 28... |
Line 28... |
| 28 |
import org.apache.commons.lang3.text.*;
|
28 |
import org.apache.commons.lang3.text.*;
|
| 29 |
|
29 |
|
| 30 |
public class PdfUtils {
|
30 |
public class PdfUtils {
|
| 31 |
|
31 |
|
| 32 |
private static final Font FONT_TITLE = new Font(Font.FontFamily.HELVETICA , 18, Font.BOLD);
|
32 |
private static final Font FONT_TITLE = new Font(Font.FontFamily.HELVETICA , 18, Font.BOLD);
|
| 33 |
private static Font FONT_NORMAL = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.NORMAL);
|
33 |
private static Font FONT_NORMAL = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL);
|
| 34 |
private static Font FONT_BOLD = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.BOLD);
|
34 |
private static Font FONT_BOLD = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD);
|
| 35 |
//private static Font fontTableHeader = new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD);
|
35 |
//private static Font fontTableHeader = new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD);
|
| 36 |
private static final String INVOICE_TITLE = "INVOICE";
|
36 |
private static final String INVOICE_TITLE = "INVOICE";
|
| 37 |
|
37 |
|
| 38 |
private static final Locale indianLocale = Locale.getDefault();
|
38 |
private static final Locale indianLocale = Locale.getDefault();
|
| 39 |
|
39 |
|
| Line 69... |
Line 69... |
| 69 |
blankCell.setBorder(Rectangle.NO_BORDER);
|
69 |
blankCell.setBorder(Rectangle.NO_BORDER);
|
| 70 |
PdfPTable tableCustomerRetailer = new PdfPTable(3);
|
70 |
PdfPTable tableCustomerRetailer = new PdfPTable(3);
|
| 71 |
tableCustomerRetailer.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
71 |
tableCustomerRetailer.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 72 |
PdfPCell columnCustomerInfo = new PdfPCell();
|
72 |
PdfPCell columnCustomerInfo = new PdfPCell();
|
| 73 |
columnCustomerInfo.addElement(new Paragraph(customer.getName(), FONT_NORMAL));
|
73 |
columnCustomerInfo.addElement(new Paragraph(customer.getName(), FONT_NORMAL));
|
| 74 |
columnCustomerInfo.addElement(new Paragraph(customer.getAddress().getLine1() + customer.getAddress().getLine2(), FONT_NORMAL));
|
74 |
columnCustomerInfo.addElement(new Paragraph(customer.getAddress().getLine1() + ", " + customer.getAddress().getLine2(), FONT_NORMAL));
|
| 75 |
columnCustomerInfo.addElement(new Paragraph(customer.getAddress().getCity() + ", " + customer.getAddress().getState() + "(" + customerAddressStateCode + ")" + "\n" + customer.getAddress().getPinCode(), FONT_NORMAL));
|
75 |
columnCustomerInfo.addElement(new Paragraph(customer.getAddress().getCity() + ", " + customer.getAddress().getState() + "(" + customerAddressStateCode + ")" + "\n" + customer.getAddress().getPinCode(), FONT_NORMAL));
|
| 76 |
columnCustomerInfo.addElement(new Paragraph(customer.getMobileNumber(), FONT_NORMAL));
|
76 |
columnCustomerInfo.addElement(new Paragraph(customer.getMobileNumber(), FONT_NORMAL));
|
| 77 |
columnCustomerInfo.setBorder(Rectangle.NO_BORDER);
|
77 |
columnCustomerInfo.setBorder(Rectangle.NO_BORDER);
|
| 78 |
PdfPCell columnRetailerInfo = new PdfPCell();
|
78 |
PdfPCell columnRetailerInfo = new PdfPCell();
|
| 79 |
//columnRetailerInfo.addElement(new Paragraph("Invoice No:"));
|
79 |
//columnRetailerInfo.addElement(new Paragraph("Invoice No:"));
|
| Line 190... |
Line 190... |
| 190 |
document.add(Chunk.NEWLINE);
|
190 |
document.add(Chunk.NEWLINE);
|
| 191 |
document.add(Chunk.NEWLINE);
|
191 |
document.add(Chunk.NEWLINE);
|
| 192 |
//document.add(paragraphRetailerName);
|
192 |
//document.add(paragraphRetailerName);
|
| 193 |
document.add(tableCustomerRetailer);
|
193 |
document.add(tableCustomerRetailer);
|
| 194 |
|
194 |
|
| 195 |
document.add(Chunk.NEWLINE);
|
195 |
//document.add(Chunk.NEWLINE);
|
| 196 |
document.add(Chunk.NEWLINE);
|
196 |
//document.add(Chunk.NEWLINE);
|
| 197 |
document.add(Chunk.NEWLINE);
|
197 |
document.add(Chunk.NEWLINE);
|
| 198 |
document.add(orders);
|
198 |
document.add(orders);
|
| 199 |
|
199 |
|
| 200 |
|
200 |
|
| 201 |
|
201 |
|
| Line 228... |
Line 228... |
| 228 |
}
|
228 |
}
|
| 229 |
|
229 |
|
| 230 |
//grandTotalCell.setColspan(6);
|
230 |
//grandTotalCell.setColspan(6);
|
| 231 |
document.add(gstTotalTable);
|
231 |
document.add(gstTotalTable);
|
| 232 |
|
232 |
|
| 233 |
PdfPTable grandTotalTable = null;
|
233 |
PdfPTable grandTotalTable = new PdfPTable(3);
|
| 234 |
if(gstWithInState){
|
234 |
if(gstWithInState){
|
| 235 |
grandTotalTable = new PdfPTable(3);
|
- |
|
| 236 |
grandTotalTable.setWidths(new int[]{8, 1, 1});
|
235 |
grandTotalTable.setWidths(new int[]{8, 1, 1});
|
| 237 |
}else{
|
236 |
}else{
|
| 238 |
grandTotalTable = new PdfPTable(5);
|
- |
|
| 239 |
grandTotalTable.setWidths(new int[]{8, 1, 1, 1, 1});
|
237 |
grandTotalTable.setWidths(new int[]{10, 1, 1});
|
| 240 |
}
|
238 |
}
|
| 241 |
|
239 |
|
| 242 |
/*for(int i = 0; i < 6; i++){
|
- |
|
| 243 |
grandTotalTable.addCell(new Paragraph());
|
- |
|
| 244 |
}*/
|
240 |
|
| 245 |
//PdfPCell grandTotalCell = new PdfPCell(new Paragraph("Grand total", fontBold));
|
- |
|
| 246 |
//grandTotalCell.setVerticalAlignment(Element.ALIGN_RIGHT);
|
- |
|
| 247 |
Paragraph grandTotalParagraph = new Paragraph("Grand total", FONT_BOLD);
|
241 |
Paragraph grandTotalParagraph = new Paragraph("Grand total", FONT_BOLD);
|
| 248 |
grandTotalParagraph.setIndentationRight(20);
|
242 |
grandTotalParagraph.setIndentationRight(20);
|
| 249 |
grandTotalTable.addCell(grandTotalParagraph);
|
243 |
grandTotalTable.addCell(grandTotalParagraph);
|
| 250 |
Paragraph rsParagraph = new Paragraph("Rs.", FONT_BOLD);
|
244 |
Paragraph rsParagraph = new Paragraph("Rs.", FONT_BOLD);
|
| 251 |
grandTotalTable.addCell(rsParagraph);
|
245 |
grandTotalTable.addCell(rsParagraph);
|
| Line 254... |
Line 248... |
| 254 |
|
248 |
|
| 255 |
|
249 |
|
| 256 |
document.add(grandTotalTable);
|
250 |
document.add(grandTotalTable);
|
| 257 |
|
251 |
|
| 258 |
PdfPTable amountInWordsTable = new PdfPTable(3);
|
252 |
PdfPTable amountInWordsTable = new PdfPTable(3);
|
| - |
|
253 |
if(gstWithInState){
|
| 259 |
amountInWordsTable.setWidths(new int[]{1, 6, 3});
|
254 |
amountInWordsTable.setWidths(new int[]{1, 6, 3});
|
| - |
|
255 |
}else{
|
| - |
|
256 |
amountInWordsTable.setWidths(new int[]{1, 8, 3});
|
| - |
|
257 |
}
|
| 260 |
amountInWordsTable.addCell(new Paragraph("Amount in Words:", FONT_BOLD));
|
258 |
amountInWordsTable.addCell(new Paragraph("Amount in Words:", FONT_BOLD));
|
| 261 |
|
259 |
|
| 262 |
String amountInWords = toAmountInWords(pdfModel.getTotalAmount());
|
260 |
String amountInWords = toAmountInWords(pdfModel.getTotalAmount());
|
| 263 |
amountInWordsTable.addCell(new Paragraph(amountInWords.toString(), FONT_BOLD));
|
261 |
amountInWordsTable.addCell(new Paragraph(amountInWords.toString(), FONT_BOLD));
|
| 264 |
amountInWordsTable.addCell(new Paragraph("E & O.E", FONT_NORMAL));
|
262 |
amountInWordsTable.addCell(new Paragraph("E & O.E", FONT_NORMAL));
|
| 265 |
document.add(amountInWordsTable);
|
263 |
document.add(amountInWordsTable);
|
| 266 |
|
264 |
|
| 267 |
Paragraph warningParagraph = new Paragraph("Goods once sold will not be taken back.\nAll Disputes subject to "+pdfModel.getRetailer().getAddress().getState()+" Jurisdiction.\nThis is a Computer Generated Invoice.", FONT_NORMAL);
|
265 |
Paragraph warningParagraph = new Paragraph("Goods once sold will not be taken back.\nThis is a Computer Generated Invoice.", FONT_NORMAL);
|
| 268 |
warningParagraph.setIndentationLeft(50);
|
266 |
warningParagraph.setIndentationLeft(50);
|
| 269 |
document.add(Chunk.NEWLINE);
|
267 |
document.add(Chunk.NEWLINE);
|
| 270 |
document.add(warningParagraph);
|
268 |
document.add(warningParagraph);
|
| 271 |
document.add(Chunk.NEWLINE);
|
269 |
document.add(Chunk.NEWLINE);
|
| 272 |
document.add(Chunk.NEWLINE);
|
270 |
document.add(Chunk.NEWLINE);
|