| 21686 |
ashik.ali |
1 |
package com.spice.profitmandi.common.util;
|
|
|
2 |
|
| 24506 |
amit.gupta |
3 |
import java.io.ByteArrayInputStream;
|
|
|
4 |
import java.io.ByteArrayOutputStream;
|
|
|
5 |
import java.io.IOException;
|
| 21686 |
ashik.ali |
6 |
import java.io.OutputStream;
|
| 24506 |
amit.gupta |
7 |
import java.net.URL;
|
| 24854 |
amit.gupta |
8 |
import java.util.ArrayList;
|
| 23001 |
amit.gupta |
9 |
import java.util.List;
|
| 21915 |
ashik.ali |
10 |
import java.util.Locale;
|
| 21686 |
ashik.ali |
11 |
import java.util.Set;
|
|
|
12 |
|
| 24506 |
amit.gupta |
13 |
import org.apache.logging.log4j.LogManager;
|
| 23568 |
govind |
14 |
import org.apache.logging.log4j.Logger;
|
| 22068 |
ashik.ali |
15 |
import org.springframework.util.StringUtils;
|
| 21686 |
ashik.ali |
16 |
|
| 21915 |
ashik.ali |
17 |
import com.ibm.icu.text.RuleBasedNumberFormat;
|
| 21686 |
ashik.ali |
18 |
import com.itextpdf.text.Chunk;
|
|
|
19 |
import com.itextpdf.text.Document;
|
|
|
20 |
import com.itextpdf.text.DocumentException;
|
|
|
21 |
import com.itextpdf.text.Element;
|
|
|
22 |
import com.itextpdf.text.Font;
|
| 24506 |
amit.gupta |
23 |
import com.itextpdf.text.Font.FontFamily;
|
|
|
24 |
import com.itextpdf.text.Image;
|
| 21686 |
ashik.ali |
25 |
import com.itextpdf.text.Paragraph;
|
| 24506 |
amit.gupta |
26 |
import com.itextpdf.text.Phrase;
|
| 21686 |
ashik.ali |
27 |
import com.itextpdf.text.Rectangle;
|
| 24506 |
amit.gupta |
28 |
import com.itextpdf.text.pdf.PdfContentByte;
|
|
|
29 |
import com.itextpdf.text.pdf.PdfGState;
|
| 21686 |
ashik.ali |
30 |
import com.itextpdf.text.pdf.PdfPCell;
|
|
|
31 |
import com.itextpdf.text.pdf.PdfPTable;
|
| 24506 |
amit.gupta |
32 |
import com.itextpdf.text.pdf.PdfReader;
|
|
|
33 |
import com.itextpdf.text.pdf.PdfStamper;
|
| 21686 |
ashik.ali |
34 |
import com.itextpdf.text.pdf.PdfWriter;
|
| 23654 |
amit.gupta |
35 |
import com.spice.profitmandi.common.model.CreditNotePdfModel;
|
| 21686 |
ashik.ali |
36 |
import com.spice.profitmandi.common.model.CustomCustomer;
|
| 23001 |
amit.gupta |
37 |
import com.spice.profitmandi.common.model.CustomInsurancePolicy;
|
| 22858 |
ashik.ali |
38 |
import com.spice.profitmandi.common.model.CustomOrderItem;
|
| 23558 |
amit.gupta |
39 |
import com.spice.profitmandi.common.model.CustomPaymentOption;
|
| 21686 |
ashik.ali |
40 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 23509 |
amit.gupta |
41 |
import com.spice.profitmandi.common.model.DebitNotePdfModel;
|
| 21686 |
ashik.ali |
42 |
import com.spice.profitmandi.common.model.PdfModel;
|
|
|
43 |
|
|
|
44 |
public class PdfUtils {
|
| 23509 |
amit.gupta |
45 |
|
|
|
46 |
private static final Font FONT_TITLE = new Font(Font.FontFamily.HELVETICA, 18, Font.BOLD);
|
| 21965 |
ashik.ali |
47 |
private static Font FONT_NORMAL = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL);
|
|
|
48 |
private static Font FONT_BOLD = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD);
|
| 23509 |
amit.gupta |
49 |
// private static Font fontTableHeader = new
|
|
|
50 |
// Font(Font.FontFamily.TIMES_ROMAN, 14, Font.BOLD);
|
| 24215 |
amit.gupta |
51 |
public static final String INVOICE_TITLE = "TAX INVOICE";
|
|
|
52 |
public static final String DEBIT_NOTE_TITLE = "DEBIT NOTE";
|
|
|
53 |
public static final String SECURITY_DEPOSIT = "SECURITY DEPOSIT RECEIPT";
|
| 23509 |
amit.gupta |
54 |
|
| 23654 |
amit.gupta |
55 |
private static float[] igstWidthsWithDiscount = new float[] { .3f, 2.6f, 0.7f, .4f, 0.7f, 0.5f, .7f, .6f, 0.6f,
|
|
|
56 |
0.9f };
|
| 23549 |
amit.gupta |
57 |
private static float[] stateWidthsWithDiscount = new float[] { .3f, 2.1f, 0.7f, .3f, 0.6f, 0.4f, .7f, .5f, .6f, .5f,
|
| 23509 |
amit.gupta |
58 |
.6f, .8f };
|
|
|
59 |
|
| 27249 |
amit.gupta |
60 |
private static float[] igstWidths = new float[] { .6f, 2.6f, 0.7f, .4f, 0.7f, .6f, 0.6f, 0.9f };
|
|
|
61 |
private static float[] stateWidths = new float[] { .6f, 2.1f, 0.7f, .3f, 0.6f, .5f, .6f, .5f, .6f, .8f };
|
| 23533 |
amit.gupta |
62 |
|
| 23654 |
amit.gupta |
63 |
private static float[] igstWidthsCrNote = new float[] { 2.6f, 0.7f, .4f, 0.7f, .7f, .6f, 0.6f, 0.9f };
|
|
|
64 |
private static float[] stateWidthsCrNote = new float[] { 2.1f, 0.7f, .3f, 0.6f, .7f, .5f, .6f, .5f, .6f, .8f };
|
|
|
65 |
|
| 21915 |
ashik.ali |
66 |
private static final Locale indianLocale = Locale.getDefault();
|
| 23509 |
amit.gupta |
67 |
|
| 23568 |
govind |
68 |
private static final Logger LOGGER = LogManager.getLogger(PdfUtils.class);
|
| 23509 |
amit.gupta |
69 |
|
| 27247 |
amit.gupta |
70 |
private static final URL iconUrl = PdfUtils.class.getClassLoader().getResource("sdlogo.png");
|
| 25463 |
amit.gupta |
71 |
private static Image iconImg = null;
|
|
|
72 |
static {
|
|
|
73 |
try {
|
|
|
74 |
iconImg = Image.getInstance(iconUrl);
|
|
|
75 |
} catch (Exception e) {
|
|
|
76 |
e.printStackTrace();
|
|
|
77 |
}
|
|
|
78 |
}
|
| 25840 |
amit.gupta |
79 |
|
|
|
80 |
//Debit Note generation logic has been changed
|
|
|
81 |
//Debit Note considers price drops so amount in debit note is current price of item.
|
|
|
82 |
//From 16Nov 2019 onwards all debit notes will be as per actuall billing value, all pricedrops
|
|
|
83 |
//shall be rolledback or cancelled once the debit note is generated.
|
|
|
84 |
|
| 25463 |
amit.gupta |
85 |
|
| 24854 |
amit.gupta |
86 |
public static void generateAndWrite(List<PdfModel> pdfModels, ByteArrayOutputStream outputStream) {
|
| 23509 |
amit.gupta |
87 |
try {
|
| 24854 |
amit.gupta |
88 |
List<Integer> caneclledPageList = new ArrayList<>();
|
| 24845 |
amit.gupta |
89 |
Document document = new Document();
|
|
|
90 |
document.setMargins(0, 0, 25, 0);
|
| 24854 |
amit.gupta |
91 |
PdfWriter.getInstance(document, outputStream);
|
|
|
92 |
document.open();
|
| 24845 |
amit.gupta |
93 |
for (PdfModel pdfModel : pdfModels) {
|
|
|
94 |
CustomCustomer customer = pdfModel.getCustomer();
|
|
|
95 |
CustomRetailer retailer = pdfModel.getRetailer();
|
|
|
96 |
boolean stateGst = false;
|
|
|
97 |
if (customer.getAddress().getState().equals(retailer.getAddress().getState())) {
|
|
|
98 |
stateGst = true;
|
|
|
99 |
}
|
|
|
100 |
Set<CustomOrderItem> orderItems = pdfModel.getOrderItems();
|
|
|
101 |
if (pdfModel.isCancelled()) {
|
| 24854 |
amit.gupta |
102 |
caneclledPageList.add(1);
|
| 24845 |
amit.gupta |
103 |
} else {
|
| 24854 |
amit.gupta |
104 |
caneclledPageList.add(0);
|
| 24845 |
amit.gupta |
105 |
}
|
|
|
106 |
document.addTitle(pdfModel.getTitle());
|
|
|
107 |
document.addAuthor(pdfModel.getAuther());
|
| 22889 |
amit.gupta |
108 |
|
| 24845 |
amit.gupta |
109 |
Paragraph paragraphTitle = new Paragraph(INVOICE_TITLE, FONT_TITLE);
|
|
|
110 |
paragraphTitle.setAlignment(Element.ALIGN_CENTER);
|
| 21686 |
ashik.ali |
111 |
|
| 24845 |
amit.gupta |
112 |
PdfPCell blankCell = new PdfPCell();
|
|
|
113 |
blankCell.setBorder(Rectangle.NO_BORDER);
|
|
|
114 |
PdfPTable tableCustomerRetailer = new PdfPTable(3);
|
|
|
115 |
tableCustomerRetailer.setWidthPercentage(90);
|
|
|
116 |
tableCustomerRetailer.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
|
|
117 |
PdfPCell columnCustomerInfo = new PdfPCell();
|
|
|
118 |
columnCustomerInfo.addElement(new Paragraph("Customer Details", FONT_BOLD));
|
|
|
119 |
columnCustomerInfo.addElement(new Paragraph(
|
| 26821 |
amit.gupta |
120 |
StringUtils.capitalize(customer.getAddress().getName() +
|
|
|
121 |
(customer.getAddress().getLastName()==null?"" : " " + customer.getAddress().getLastName())),
|
|
|
122 |
FONT_NORMAL));
|
| 24845 |
amit.gupta |
123 |
columnCustomerInfo.addElement(new Paragraph(StringUtils.capitalize(customer.getAddress().getLine1())
|
|
|
124 |
+ ", " + StringUtils.capitalize(customer.getAddress().getLine2()), FONT_NORMAL));
|
| 25463 |
amit.gupta |
125 |
columnCustomerInfo.addElement(new Paragraph(StringUtils.capitalize(customer.getAddress().getCity())
|
|
|
126 |
+ ", " + StringUtils.capitalize(customer.getAddress().getState()) + "("
|
|
|
127 |
+ pdfModel.getCustomerAddressStateCode() + ")" + "\n" + customer.getAddress().getPinCode(),
|
| 24845 |
amit.gupta |
128 |
FONT_NORMAL));
|
| 26442 |
amit.gupta |
129 |
columnCustomerInfo.addElement(new Paragraph("Mobile - " + customer.getAddress().getPhoneNumber(), FONT_NORMAL));
|
| 24845 |
amit.gupta |
130 |
if (customer.getGstNumber() != null && !customer.getGstNumber().isEmpty()) {
|
|
|
131 |
columnCustomerInfo
|
|
|
132 |
.addElement(new Paragraph("GST Number - " + customer.getGstNumber(), FONT_NORMAL));
|
|
|
133 |
}
|
|
|
134 |
columnCustomerInfo.setBorder(Rectangle.NO_BORDER);
|
|
|
135 |
PdfPCell columnRetailerInfo = new PdfPCell();
|
|
|
136 |
columnRetailerInfo
|
|
|
137 |
.addElement(new Paragraph(StringUtils.capitalize(retailer.getAddress().getName()), FONT_BOLD));
|
|
|
138 |
columnRetailerInfo.addElement(new Paragraph(StringUtils.capitalize(retailer.getAddress().getLine1())
|
|
|
139 |
+ ", " + StringUtils.capitalize(retailer.getAddress().getLine2()) + ", "
|
|
|
140 |
+ StringUtils.capitalize(retailer.getAddress().getCity()) + "-"
|
|
|
141 |
+ retailer.getAddress().getPinCode() + ", " + retailer.getAddress().getState() + "("
|
| 25463 |
amit.gupta |
142 |
+ (stateGst ? pdfModel.getCustomerAddressStateCode() : pdfModel.getPartnerAddressStateCode())
|
|
|
143 |
+ ")", FONT_BOLD));
|
| 24845 |
amit.gupta |
144 |
columnRetailerInfo
|
|
|
145 |
.addElement(new Paragraph("Contact No.- " + retailer.getAddress().getPhoneNumber(), FONT_BOLD));
|
|
|
146 |
columnRetailerInfo.addElement(new Paragraph("GST NO. " + retailer.getGstNumber(), FONT_BOLD));
|
|
|
147 |
columnRetailerInfo.setBorder(Rectangle.NO_BORDER);
|
| 23509 |
amit.gupta |
148 |
|
| 24845 |
amit.gupta |
149 |
PdfPTable tableInvoiceDateRetailer = new PdfPTable(1);
|
|
|
150 |
tableInvoiceDateRetailer.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 23509 |
amit.gupta |
151 |
|
| 24845 |
amit.gupta |
152 |
PdfPTable tableInvoiceDate = new PdfPTable(2);
|
|
|
153 |
tableInvoiceDate.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 23509 |
amit.gupta |
154 |
|
| 24845 |
amit.gupta |
155 |
PdfPCell invoiceNumberKey = new PdfPCell(new Paragraph("Invoice No:", FONT_NORMAL));
|
|
|
156 |
invoiceNumberKey.setBorder(Rectangle.NO_BORDER);
|
| 23509 |
amit.gupta |
157 |
|
| 24845 |
amit.gupta |
158 |
PdfPCell invoiceNumberValue = new PdfPCell(new Paragraph(pdfModel.getInvoiceNumber(), FONT_NORMAL));
|
|
|
159 |
invoiceNumberValue.setBorder(Rectangle.NO_BORDER);
|
| 23509 |
amit.gupta |
160 |
|
| 24845 |
amit.gupta |
161 |
PdfPCell dateKey = new PdfPCell(new Paragraph("Date:", FONT_NORMAL));
|
|
|
162 |
dateKey.setBorder(Rectangle.NO_BORDER);
|
| 23509 |
amit.gupta |
163 |
|
| 24845 |
amit.gupta |
164 |
PdfPCell dateValue = new PdfPCell(new Paragraph(pdfModel.getInvoiceDate(), FONT_NORMAL));
|
|
|
165 |
dateValue.setBorder(Rectangle.NO_BORDER);
|
|
|
166 |
tableInvoiceDate.addCell(invoiceNumberKey);
|
|
|
167 |
// tableInvoiceDate.addCell(blankCell);
|
|
|
168 |
tableInvoiceDate.addCell(invoiceNumberValue);
|
|
|
169 |
tableInvoiceDate.addCell(dateKey);
|
|
|
170 |
// tableInvoiceDate.addCell(blankCell);
|
|
|
171 |
tableInvoiceDate.addCell(dateValue);
|
|
|
172 |
tableInvoiceDateRetailer.addCell(tableInvoiceDate);
|
|
|
173 |
tableInvoiceDateRetailer.addCell(columnRetailerInfo);
|
| 23509 |
amit.gupta |
174 |
|
| 24845 |
amit.gupta |
175 |
tableCustomerRetailer.addCell(columnCustomerInfo);
|
|
|
176 |
tableCustomerRetailer.addCell(blankCell);
|
|
|
177 |
tableCustomerRetailer.addCell(tableInvoiceDateRetailer);
|
| 23509 |
amit.gupta |
178 |
|
| 24845 |
amit.gupta |
179 |
PdfPTable orders = null;
|
|
|
180 |
if (stateGst) {
|
|
|
181 |
orders = new PdfPTable(stateWidthsWithDiscount.length);
|
|
|
182 |
orders.setWidths(stateWidthsWithDiscount);
|
| 23509 |
amit.gupta |
183 |
} else {
|
| 24845 |
amit.gupta |
184 |
orders = new PdfPTable(igstWidthsWithDiscount.length);
|
|
|
185 |
orders.setWidths(igstWidthsWithDiscount);
|
| 23509 |
amit.gupta |
186 |
}
|
| 24845 |
amit.gupta |
187 |
orders.setWidthPercentage(90);
|
|
|
188 |
orders.addCell(new Paragraph("Sl", FONT_BOLD));
|
|
|
189 |
orders.addCell(new Paragraph("Description", FONT_BOLD));
|
|
|
190 |
orders.addCell(new Paragraph("HSN", FONT_BOLD));
|
|
|
191 |
orders.addCell(new Paragraph("Qty", FONT_BOLD));
|
|
|
192 |
orders.addCell(new Paragraph("Rate\n(Per pc)", FONT_BOLD));
|
| 27247 |
amit.gupta |
193 |
//orders.addCell(new Paragraph("Disc.", FONT_BOLD));
|
| 24845 |
amit.gupta |
194 |
orders.addCell(new Paragraph("Total\nTaxable", FONT_BOLD));
|
| 23509 |
amit.gupta |
195 |
if (!stateGst) {
|
| 24845 |
amit.gupta |
196 |
orders.addCell(new Paragraph("IGST\n%", FONT_BOLD));
|
|
|
197 |
orders.addCell(new Paragraph("IGST", FONT_BOLD));
|
|
|
198 |
// orders.setWidths(new float[]{1, 3, 1, 1, 1, 1, 1, 1});
|
|
|
199 |
// total 8f
|
| 23509 |
amit.gupta |
200 |
} else {
|
| 24845 |
amit.gupta |
201 |
orders.addCell(new Paragraph("CGST %", FONT_BOLD));
|
|
|
202 |
orders.addCell(new Paragraph("CGST", FONT_BOLD));
|
|
|
203 |
orders.addCell(new Paragraph("SGST %", FONT_BOLD));
|
|
|
204 |
orders.addCell(new Paragraph("SGST", FONT_BOLD));
|
|
|
205 |
// orders.setWidths(new float[]{1, 3, 1, 1, 1, 1, 1, 1, 1, 1});
|
|
|
206 |
// total 8f
|
| 23509 |
amit.gupta |
207 |
}
|
| 24845 |
amit.gupta |
208 |
orders.addCell(new Paragraph("Total", FONT_BOLD));
|
| 23509 |
amit.gupta |
209 |
|
| 24845 |
amit.gupta |
210 |
// orders.addCell(new Paragraph("Item Total (Rs)", FONT_BOLD));
|
| 23509 |
amit.gupta |
211 |
|
| 24845 |
amit.gupta |
212 |
orders.setHeaderRows(1);
|
|
|
213 |
// orders.setSkipFirstHeader(true);
|
| 23509 |
amit.gupta |
214 |
|
| 24845 |
amit.gupta |
215 |
float igstTotalAmount = 0, cgstTotalAmount = 0, sgstTotalAmount = 0;
|
|
|
216 |
int index = 1;
|
|
|
217 |
for (CustomOrderItem orderItem : orderItems) {
|
|
|
218 |
orders.addCell(new Paragraph(String.valueOf(index++), FONT_NORMAL));
|
|
|
219 |
orders.addCell(new Paragraph(orderItem.getDescription(), FONT_NORMAL));
|
|
|
220 |
orders.addCell(new Paragraph(orderItem.getHsnCode(), FONT_NORMAL));
|
|
|
221 |
orders.addCell(new Paragraph(String.valueOf(orderItem.getQuantity()), FONT_NORMAL));
|
|
|
222 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getRate()), FONT_NORMAL));
|
| 27247 |
amit.gupta |
223 |
//orders.addCell(new Paragraph(String.format("%.2f", orderItem.getDiscount()), FONT_NORMAL));
|
| 24845 |
amit.gupta |
224 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getAmount()), FONT_NORMAL));
|
|
|
225 |
if (!stateGst) {
|
|
|
226 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getIgstRate()), FONT_NORMAL));
|
|
|
227 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getIgstAmount()), FONT_NORMAL));
|
|
|
228 |
igstTotalAmount = igstTotalAmount + orderItem.getIgstAmount();
|
|
|
229 |
} else {
|
|
|
230 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getCgstRate()), FONT_NORMAL));
|
|
|
231 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getCgstAmount()), FONT_NORMAL));
|
|
|
232 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getSgstRate()), FONT_NORMAL));
|
|
|
233 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getSgstAmount()), FONT_NORMAL));
|
|
|
234 |
cgstTotalAmount = cgstTotalAmount + orderItem.getCgstAmount();
|
|
|
235 |
sgstTotalAmount = sgstTotalAmount + orderItem.getSgstAmount();
|
|
|
236 |
}
|
|
|
237 |
orders.addCell(new Paragraph(String.format("%.0f", orderItem.getNetAmount()), FONT_NORMAL));
|
|
|
238 |
// orders.addCell(new Paragraph(String.format("%.2f",
|
|
|
239 |
// orderItem.getItemTotal()), FONT_NORMAL));
|
|
|
240 |
}
|
| 23654 |
amit.gupta |
241 |
|
| 24845 |
amit.gupta |
242 |
for (CustomInsurancePolicy insurancePolicy : pdfModel.getInsurancePolicies()) {
|
|
|
243 |
orders.addCell(new Paragraph(String.valueOf(index++), FONT_NORMAL));
|
|
|
244 |
orders.addCell(new Paragraph(insurancePolicy.getDescription(), FONT_NORMAL));
|
|
|
245 |
orders.addCell(new Paragraph(insurancePolicy.getHsnCode(), FONT_NORMAL));
|
|
|
246 |
orders.addCell(new Paragraph("1", FONT_NORMAL));
|
|
|
247 |
orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getRate()), FONT_NORMAL));
|
|
|
248 |
orders.addCell(new Paragraph("-", FONT_NORMAL));
|
|
|
249 |
orders.addCell(new Paragraph(String.format("%.2f", insurancePolicy.getRate()), FONT_NORMAL));
|
|
|
250 |
if (!stateGst) {
|
|
|
251 |
orders.addCell(
|
|
|
252 |
new Paragraph(String.format("%.2f", insurancePolicy.getIgstRate()), FONT_NORMAL));
|
|
|
253 |
orders.addCell(
|
|
|
254 |
new Paragraph(String.format("%.2f", insurancePolicy.getIgstAmount()), FONT_NORMAL));
|
|
|
255 |
igstTotalAmount = igstTotalAmount + insurancePolicy.getIgstAmount();
|
|
|
256 |
} else {
|
|
|
257 |
orders.addCell(
|
|
|
258 |
new Paragraph(String.format("%.2f", insurancePolicy.getCgstRate()), FONT_NORMAL));
|
|
|
259 |
orders.addCell(
|
|
|
260 |
new Paragraph(String.format("%.2f", insurancePolicy.getCgstAmount()), FONT_NORMAL));
|
|
|
261 |
orders.addCell(
|
|
|
262 |
new Paragraph(String.format("%.2f", insurancePolicy.getSgstRate()), FONT_NORMAL));
|
|
|
263 |
orders.addCell(
|
|
|
264 |
new Paragraph(String.format("%.2f", insurancePolicy.getSgstAmount()), FONT_NORMAL));
|
|
|
265 |
cgstTotalAmount = cgstTotalAmount + insurancePolicy.getCgstAmount();
|
|
|
266 |
sgstTotalAmount = sgstTotalAmount + insurancePolicy.getSgstAmount();
|
|
|
267 |
}
|
|
|
268 |
orders.addCell(new Paragraph(String.format("%.0f", insurancePolicy.getNetAmount()), FONT_NORMAL));
|
|
|
269 |
}
|
| 25467 |
amit.gupta |
270 |
Rectangle rectangle = document.getPageSize();
|
| 25477 |
amit.gupta |
271 |
iconImg.setAbsolutePosition(25, rectangle.getHeight() - 100);
|
| 25476 |
amit.gupta |
272 |
iconImg.scalePercent(30);
|
| 25463 |
amit.gupta |
273 |
document.add(iconImg);
|
| 24845 |
amit.gupta |
274 |
document.add(paragraphTitle);
|
|
|
275 |
document.add(Chunk.NEWLINE);
|
|
|
276 |
document.add(Chunk.NEWLINE);
|
|
|
277 |
document.add(tableCustomerRetailer);
|
| 23509 |
amit.gupta |
278 |
|
| 24845 |
amit.gupta |
279 |
document.add(Chunk.NEWLINE);
|
|
|
280 |
document.add(orders);
|
| 23509 |
amit.gupta |
281 |
|
| 24845 |
amit.gupta |
282 |
PdfPTable grandTotalTable = new PdfPTable(3);
|
|
|
283 |
PdfPTable paymentsTable = new PdfPTable(2);
|
|
|
284 |
paymentsTable.setWidthPercentage(95);
|
|
|
285 |
paymentsTable.setWidths(new float[] { 8f, 2f });
|
| 23509 |
amit.gupta |
286 |
|
| 24845 |
amit.gupta |
287 |
if (stateGst) {
|
|
|
288 |
grandTotalTable.setWidths(new float[] { 6.6f, .6f, .8f });
|
|
|
289 |
} else {
|
|
|
290 |
grandTotalTable.setWidths(new float[] { 6.5f, .6f, .9f });
|
|
|
291 |
}
|
|
|
292 |
grandTotalTable.setWidthPercentage(90);
|
| 23654 |
amit.gupta |
293 |
|
| 24845 |
amit.gupta |
294 |
Paragraph grandTotalParagraph = new Paragraph("Grand total", FONT_BOLD);
|
|
|
295 |
grandTotalParagraph.setIndentationRight(20);
|
|
|
296 |
grandTotalTable.addCell(grandTotalParagraph);
|
|
|
297 |
Paragraph rsParagraph = new Paragraph("Rs.", FONT_BOLD);
|
|
|
298 |
grandTotalTable.addCell(rsParagraph);
|
|
|
299 |
Paragraph amountParagraph = new Paragraph(String.format("%.2f", pdfModel.getTotalAmount()), FONT_BOLD);
|
|
|
300 |
grandTotalTable.addCell(amountParagraph);
|
|
|
301 |
|
|
|
302 |
document.add(grandTotalTable);
|
|
|
303 |
|
|
|
304 |
PdfPTable amountInWordsTable = new PdfPTable(3);
|
|
|
305 |
amountInWordsTable.setWidthPercentage(90);
|
|
|
306 |
amountInWordsTable.addCell(new Paragraph("Amount in Words:", FONT_BOLD));
|
| 23558 |
amit.gupta |
307 |
if (!stateGst) {
|
| 24845 |
amit.gupta |
308 |
amountInWordsTable.setWidths(new float[] { 2, 5.1f, 0.9f });
|
| 23558 |
amit.gupta |
309 |
} else {
|
| 24845 |
amit.gupta |
310 |
amountInWordsTable.setWidths(new float[] { 2, 5.2f, 0.8f });
|
| 23558 |
amit.gupta |
311 |
}
|
| 23509 |
amit.gupta |
312 |
|
| 24845 |
amit.gupta |
313 |
String amountInWords = toAmountInWords(pdfModel.getTotalAmount());
|
|
|
314 |
amountInWordsTable.addCell(new Paragraph(amountInWords.toString(), FONT_BOLD));
|
|
|
315 |
amountInWordsTable.addCell(new Paragraph("E & O.E", FONT_NORMAL));
|
|
|
316 |
document.add(amountInWordsTable);
|
| 23654 |
amit.gupta |
317 |
|
| 24845 |
amit.gupta |
318 |
if (pdfModel.getPaymentOptions() != null) {
|
|
|
319 |
PdfPTable paidAmountTable = new PdfPTable(2);
|
|
|
320 |
paidAmountTable.setWidthPercentage(90);
|
|
|
321 |
if (!stateGst) {
|
|
|
322 |
paidAmountTable.setWidths(new float[] { 7.1f, 0.9f });
|
|
|
323 |
} else {
|
|
|
324 |
paidAmountTable.setWidths(new float[] { 7.2f, 0.8f });
|
|
|
325 |
}
|
|
|
326 |
float totalPaidValue = 0;
|
|
|
327 |
for (CustomPaymentOption paymentOption : pdfModel.getPaymentOptions()) {
|
|
|
328 |
PdfPCell cell = new PdfPCell(
|
|
|
329 |
new Paragraph(10, "Paid Through " + paymentOption.getPaymentOption(), FONT_BOLD));
|
|
|
330 |
cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
|
|
331 |
cell.setPadding(5);
|
|
|
332 |
paidAmountTable.addCell(cell);
|
| 23654 |
amit.gupta |
333 |
|
| 24845 |
amit.gupta |
334 |
PdfPCell cell1 = new PdfPCell(new Paragraph(10,
|
|
|
335 |
FormattingUtils.formatDecimalTwoDigits(paymentOption.getAmount()), FONT_BOLD));
|
|
|
336 |
cell1.setPadding(5);
|
|
|
337 |
paidAmountTable.addCell(cell1);
|
|
|
338 |
totalPaidValue += paymentOption.getAmount();
|
| 23654 |
amit.gupta |
339 |
|
| 24845 |
amit.gupta |
340 |
}
|
|
|
341 |
PdfPCell totalPaidCell = new PdfPCell(new Paragraph(10, "Total Paid", FONT_BOLD));
|
|
|
342 |
totalPaidCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
|
|
|
343 |
totalPaidCell.setPadding(5);
|
|
|
344 |
paidAmountTable.addCell(totalPaidCell);
|
| 23558 |
amit.gupta |
345 |
|
| 24845 |
amit.gupta |
346 |
PdfPCell totalPaidValueCell = new PdfPCell(
|
|
|
347 |
new Paragraph(10, FormattingUtils.formatDecimalTwoDigits(totalPaidValue), FONT_BOLD));
|
|
|
348 |
totalPaidValueCell.setPadding(5);
|
|
|
349 |
paidAmountTable.addCell(totalPaidValueCell);
|
| 23509 |
amit.gupta |
350 |
|
| 24845 |
amit.gupta |
351 |
document.add(paidAmountTable);
|
|
|
352 |
}
|
|
|
353 |
|
|
|
354 |
StringBuffer sb = new StringBuffer();
|
|
|
355 |
List<String> tncs = pdfModel.getTncs();
|
|
|
356 |
for (String tnc : tncs) {
|
|
|
357 |
sb.append(tnc).append("\n");
|
|
|
358 |
}
|
|
|
359 |
|
|
|
360 |
Paragraph warningParagraph = new Paragraph(sb.toString(), FONT_NORMAL);
|
|
|
361 |
warningParagraph.setIndentationLeft(40);
|
|
|
362 |
document.add(Chunk.NEWLINE);
|
|
|
363 |
document.add(warningParagraph);
|
|
|
364 |
document.newPage();
|
| 24506 |
amit.gupta |
365 |
}
|
| 24854 |
amit.gupta |
366 |
document.close(); // no need to close PDFwriter?
|
|
|
367 |
stampCancelled(outputStream, caneclledPageList);
|
| 23509 |
amit.gupta |
368 |
|
|
|
369 |
} catch (DocumentException e) {
|
|
|
370 |
LOGGER.error("Unable to write data to pdf file : ", e);
|
|
|
371 |
} catch (Exception e) {
|
| 21901 |
ashik.ali |
372 |
// TODO Auto-generated catch block
|
|
|
373 |
e.printStackTrace();
|
|
|
374 |
}
|
| 24506 |
amit.gupta |
375 |
|
| 21686 |
ashik.ali |
376 |
}
|
| 23509 |
amit.gupta |
377 |
|
| 25463 |
amit.gupta |
378 |
private static void stampCancelled(ByteArrayOutputStream byteStream, List<Integer> cancelledPage)
|
|
|
379 |
throws IOException, DocumentException {
|
| 24506 |
amit.gupta |
380 |
ByteArrayInputStream bais = new ByteArrayInputStream(byteStream.toByteArray());
|
| 24845 |
amit.gupta |
381 |
PdfReader pdfReader = new PdfReader(bais);
|
|
|
382 |
int n = pdfReader.getNumberOfPages();
|
| 24854 |
amit.gupta |
383 |
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
384 |
PdfStamper pdfStamper = new PdfStamper(pdfReader, baos);
|
| 24845 |
amit.gupta |
385 |
pdfStamper.setRotateContents(false);
|
|
|
386 |
// text watermark
|
|
|
387 |
Font f = new Font(FontFamily.HELVETICA, 30);
|
|
|
388 |
Phrase p = new Phrase("My watermark (text)", f);
|
|
|
389 |
URL cancelledImgUrl = PdfUtils.class.getClassLoader().getResource("cancelled.png");
|
| 25460 |
amit.gupta |
390 |
URL waterMarkImgUrl = PdfUtils.class.getClassLoader().getResource("sd1.jpg");
|
|
|
391 |
Image imgCancelled = Image.getInstance(cancelledImgUrl);
|
|
|
392 |
Image imgWatermark = Image.getInstance(waterMarkImgUrl);
|
| 25471 |
amit.gupta |
393 |
imgWatermark.scaleAbsolute(imgWatermark.getScaledWidth() * 2.5f, imgWatermark.getScaledHeight() * 2.5f);
|
| 25460 |
amit.gupta |
394 |
float w = imgCancelled.getScaledWidth() / 2;
|
|
|
395 |
float h = imgCancelled.getScaledHeight() / 2;
|
|
|
396 |
float wWaterMark = imgWatermark.getScaledWidth() / 2;
|
|
|
397 |
float hWatermark = imgWatermark.getScaledHeight() / 2;
|
| 24845 |
amit.gupta |
398 |
// transparency
|
|
|
399 |
PdfGState gs1 = new PdfGState();
|
|
|
400 |
gs1.setFillOpacity(0.5f);
|
| 25463 |
amit.gupta |
401 |
PdfGState gs2 = new PdfGState();
|
| 25478 |
amit.gupta |
402 |
gs2.setFillOpacity(0.1f);
|
| 24845 |
amit.gupta |
403 |
// properties
|
|
|
404 |
PdfContentByte over;
|
|
|
405 |
Rectangle pagesize;
|
|
|
406 |
float x, y;
|
| 24506 |
amit.gupta |
407 |
|
| 24845 |
amit.gupta |
408 |
// loop over every page
|
|
|
409 |
for (int i = 1; i <= n; i++) {
|
| 25467 |
amit.gupta |
410 |
pagesize = pdfReader.getPageSize(i);
|
|
|
411 |
x = (pagesize.getLeft() + pagesize.getRight()) / 2;
|
|
|
412 |
y = (pagesize.getTop() + pagesize.getBottom()) / 2;
|
|
|
413 |
over = pdfStamper.getOverContent(i);
|
|
|
414 |
over.saveState();
|
| 24854 |
amit.gupta |
415 |
if (cancelledPage.get(i - 1) == 1) {
|
|
|
416 |
over.setGState(gs1);
|
| 25460 |
amit.gupta |
417 |
over.addImage(imgCancelled, w, 0, 0, h, x - (w / 2), y - (h / 2));
|
| 24854 |
amit.gupta |
418 |
over.restoreState();
|
| 25460 |
amit.gupta |
419 |
} else {
|
| 25463 |
amit.gupta |
420 |
over.setGState(gs2);
|
| 25462 |
amit.gupta |
421 |
over.addImage(imgWatermark, wWaterMark, 0, 0, hWatermark, x - (wWaterMark / 2), y - (hWatermark / 2));
|
| 25460 |
amit.gupta |
422 |
over.restoreState();
|
| 24854 |
amit.gupta |
423 |
}
|
| 24845 |
amit.gupta |
424 |
}
|
|
|
425 |
pdfStamper.close();
|
|
|
426 |
pdfReader.close();
|
| 24854 |
amit.gupta |
427 |
baos.writeTo(byteStream);
|
| 24845 |
amit.gupta |
428 |
|
| 24506 |
amit.gupta |
429 |
}
|
|
|
430 |
|
| 23509 |
amit.gupta |
431 |
public static void generateAndWriteDebitNote(List<DebitNotePdfModel> debitNotePdfModels,
|
|
|
432 |
OutputStream outputStream) {
|
|
|
433 |
Document document = new Document();
|
|
|
434 |
document.setMargins(0, 0, 25, 0);
|
|
|
435 |
try {
|
|
|
436 |
for (DebitNotePdfModel debitNotePdfModel : debitNotePdfModels) {
|
|
|
437 |
|
|
|
438 |
PdfModel pdfModel = debitNotePdfModel.getPdfModel();
|
|
|
439 |
CustomCustomer customer = pdfModel.getCustomer();
|
|
|
440 |
CustomRetailer retailer = pdfModel.getRetailer();
|
|
|
441 |
boolean stateGst = false;
|
|
|
442 |
String customerAddressStateCode = "", retailerAddressStateCode = "";
|
|
|
443 |
if (customer.getAddress().getState().equals(retailer.getAddress().getState())) {
|
|
|
444 |
stateGst = true;
|
|
|
445 |
customerAddressStateCode = Utils.getStateCode(customer.getAddress().getState());
|
| 23549 |
amit.gupta |
446 |
retailerAddressStateCode = customerAddressStateCode;
|
| 23509 |
amit.gupta |
447 |
} else {
|
|
|
448 |
customerAddressStateCode = Utils.getStateCode(customer.getAddress().getState());
|
|
|
449 |
retailerAddressStateCode = Utils.getStateCode(retailer.getAddress().getState());
|
|
|
450 |
}
|
|
|
451 |
Set<CustomOrderItem> orderItems = pdfModel.getOrderItems();
|
|
|
452 |
|
|
|
453 |
PdfWriter.getInstance(document, outputStream);
|
|
|
454 |
|
|
|
455 |
document.open();
|
|
|
456 |
document.addTitle(pdfModel.getTitle());
|
|
|
457 |
document.addAuthor(pdfModel.getAuther());
|
|
|
458 |
|
| 23654 |
amit.gupta |
459 |
Paragraph paragraphTitle = new Paragraph(pdfModel.getTitle(), FONT_TITLE);
|
| 23509 |
amit.gupta |
460 |
paragraphTitle.setAlignment(Element.ALIGN_CENTER);
|
|
|
461 |
|
|
|
462 |
PdfPCell blankCell = new PdfPCell();
|
|
|
463 |
blankCell.setBorder(Rectangle.NO_BORDER);
|
|
|
464 |
PdfPTable tableCustomerRetailer = new PdfPTable(3);
|
| 23533 |
amit.gupta |
465 |
tableCustomerRetailer.setWidthPercentage(95);
|
| 23532 |
amit.gupta |
466 |
PdfPCell partnerInfo = new PdfPCell();
|
| 23549 |
amit.gupta |
467 |
partnerInfo.addElement(new Paragraph("From Party:", FONT_BOLD));
|
| 23654 |
amit.gupta |
468 |
partnerInfo.addElement(
|
|
|
469 |
new Paragraph(StringUtils.capitalize(customer.getAddress().getName()), FONT_NORMAL));
|
|
|
470 |
partnerInfo.addElement(new Paragraph(
|
|
|
471 |
StringUtils.capitalize(customer.getAddress().getLine1()) + ", "
|
|
|
472 |
+ (customer.getAddress().getLine2() == null ? ""
|
|
|
473 |
: StringUtils.capitalize(customer.getAddress().getLine2()))
|
|
|
474 |
+ ", " + customer.getAddress().getCity() + " - " + customer.getAddress().getPinCode(),
|
|
|
475 |
FONT_NORMAL));
|
|
|
476 |
|
|
|
477 |
partnerInfo.addElement(new Paragraph(
|
|
|
478 |
StringUtils.capitalize(customer.getAddress().getState()) + "(" + customerAddressStateCode + ")",
|
|
|
479 |
FONT_NORMAL));
|
| 23532 |
amit.gupta |
480 |
partnerInfo.addElement(new Paragraph("Mobile - " + customer.getMobileNumber(), FONT_NORMAL));
|
| 23509 |
amit.gupta |
481 |
if (customer.getGstNumber() != null && !customer.getGstNumber().isEmpty()) {
|
| 23549 |
amit.gupta |
482 |
partnerInfo.addElement(new Paragraph("GST No - " + customer.getGstNumber(), FONT_BOLD));
|
| 23509 |
amit.gupta |
483 |
}
|
| 23533 |
amit.gupta |
484 |
|
| 23532 |
amit.gupta |
485 |
PdfPCell sellerParty = new PdfPCell();
|
| 23549 |
amit.gupta |
486 |
sellerParty.addElement(new Paragraph("To Party:", FONT_BOLD));
|
| 23654 |
amit.gupta |
487 |
sellerParty.addElement(
|
|
|
488 |
new Paragraph(StringUtils.capitalize(retailer.getAddress().getName()), FONT_NORMAL));
|
|
|
489 |
sellerParty.addElement(new Paragraph((retailer.getAddress().getLine1() == null ? ""
|
|
|
490 |
: StringUtils.capitalize(retailer.getAddress().getLine1()) + ", ")
|
|
|
491 |
+ (retailer.getAddress().getLine2() == null ? ""
|
|
|
492 |
: StringUtils.capitalize(retailer.getAddress().getLine2()) + ", ")
|
|
|
493 |
+ StringUtils.capitalize(retailer.getAddress().getCity()) + "-"
|
|
|
494 |
+ retailer.getAddress().getPinCode() + ", ", FONT_NORMAL));
|
| 23532 |
amit.gupta |
495 |
sellerParty.addElement(new Paragraph(
|
| 23654 |
amit.gupta |
496 |
retailer.getAddress().getState() + "(" + retailerAddressStateCode + ")", FONT_NORMAL));
|
|
|
497 |
sellerParty
|
|
|
498 |
.addElement(new Paragraph("Mobile - " + retailer.getAddress().getPhoneNumber(), FONT_NORMAL));
|
| 23549 |
amit.gupta |
499 |
sellerParty.addElement(new Paragraph("GST No - " + retailer.getGstNumber(), FONT_BOLD));
|
| 23509 |
amit.gupta |
500 |
|
|
|
501 |
PdfPTable tableInvoiceDateRetailer = new PdfPTable(1);
|
|
|
502 |
tableInvoiceDateRetailer.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
|
|
503 |
|
|
|
504 |
PdfPTable tableInvoiceDate = new PdfPTable(2);
|
|
|
505 |
tableInvoiceDate.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
| 23533 |
amit.gupta |
506 |
tableInvoiceDate.setWidthPercentage(90);
|
| 23509 |
amit.gupta |
507 |
|
| 23533 |
amit.gupta |
508 |
PdfPCell debitNoteDetails = new PdfPCell(new Paragraph("Debit Note Details", FONT_BOLD));
|
|
|
509 |
debitNoteDetails.setColspan(2);
|
|
|
510 |
debitNoteDetails.setBorder(Rectangle.NO_BORDER);
|
| 23654 |
amit.gupta |
511 |
|
| 23532 |
amit.gupta |
512 |
PdfPCell debitNoteNumberKey = new PdfPCell(new Paragraph("Debit Note No:", FONT_NORMAL));
|
|
|
513 |
debitNoteNumberKey.setBorder(Rectangle.NO_BORDER);
|
| 23654 |
amit.gupta |
514 |
PdfPCell debitNoteNumberValue = new PdfPCell(
|
|
|
515 |
new Paragraph(debitNotePdfModel.getDebitNoteNumber(), FONT_NORMAL));
|
| 23532 |
amit.gupta |
516 |
debitNoteNumberValue.setBorder(Rectangle.NO_BORDER);
|
|
|
517 |
|
|
|
518 |
PdfPCell debitNoteDateKey = new PdfPCell(new Paragraph("Debit Note Dt:", FONT_NORMAL));
|
|
|
519 |
debitNoteDateKey.setBorder(Rectangle.NO_BORDER);
|
| 23533 |
amit.gupta |
520 |
|
|
|
521 |
PdfPCell debitNoteDateValue = new PdfPCell(
|
|
|
522 |
new Paragraph(debitNotePdfModel.getDebitNoteDate(), FONT_NORMAL));
|
| 23532 |
amit.gupta |
523 |
debitNoteDateValue.setBorder(Rectangle.NO_BORDER);
|
|
|
524 |
|
| 23539 |
amit.gupta |
525 |
PdfPCell invoiceNumberKey = new PdfPCell(new Paragraph("Invoice Ref No:", FONT_NORMAL));
|
| 23509 |
amit.gupta |
526 |
invoiceNumberKey.setBorder(Rectangle.NO_BORDER);
|
|
|
527 |
PdfPCell invoiceNumberValue = new PdfPCell(new Paragraph(pdfModel.getInvoiceNumber(), FONT_NORMAL));
|
|
|
528 |
invoiceNumberValue.setBorder(Rectangle.NO_BORDER);
|
|
|
529 |
|
| 23532 |
amit.gupta |
530 |
PdfPCell dateKey = new PdfPCell(new Paragraph("Invoice Dt:", FONT_NORMAL));
|
| 23509 |
amit.gupta |
531 |
dateKey.setBorder(Rectangle.NO_BORDER);
|
| 23549 |
amit.gupta |
532 |
PdfPCell dateValue = new PdfPCell(new Paragraph(pdfModel.getInvoiceDate(), FONT_NORMAL));
|
| 23509 |
amit.gupta |
533 |
dateValue.setBorder(Rectangle.NO_BORDER);
|
| 23533 |
amit.gupta |
534 |
|
|
|
535 |
tableInvoiceDate.addCell(debitNoteDetails);
|
| 23532 |
amit.gupta |
536 |
tableInvoiceDate.addCell(debitNoteNumberKey);
|
|
|
537 |
tableInvoiceDate.addCell(debitNoteNumberValue);
|
|
|
538 |
tableInvoiceDate.addCell(debitNoteDateKey);
|
|
|
539 |
tableInvoiceDate.addCell(debitNoteDateValue);
|
| 23509 |
amit.gupta |
540 |
tableInvoiceDate.addCell(invoiceNumberKey);
|
|
|
541 |
tableInvoiceDate.addCell(invoiceNumberValue);
|
|
|
542 |
tableInvoiceDate.addCell(dateKey);
|
|
|
543 |
tableInvoiceDate.addCell(dateValue);
|
|
|
544 |
|
| 23532 |
amit.gupta |
545 |
tableCustomerRetailer.addCell(partnerInfo);
|
| 23533 |
amit.gupta |
546 |
tableCustomerRetailer.addCell(tableInvoiceDate);
|
|
|
547 |
tableCustomerRetailer.addCell(sellerParty);
|
| 23509 |
amit.gupta |
548 |
|
|
|
549 |
PdfPTable orders = null;
|
|
|
550 |
if (stateGst) {
|
| 23532 |
amit.gupta |
551 |
orders = new PdfPTable(stateWidths.length);
|
|
|
552 |
orders.setWidths(stateWidths);
|
| 23509 |
amit.gupta |
553 |
} else {
|
| 23532 |
amit.gupta |
554 |
orders = new PdfPTable(igstWidths.length);
|
|
|
555 |
orders.setWidths(igstWidths);
|
| 23509 |
amit.gupta |
556 |
}
|
| 23549 |
amit.gupta |
557 |
orders.setWidthPercentage(95);
|
| 23542 |
amit.gupta |
558 |
orders.addCell(new Paragraph("Order Id", FONT_BOLD));
|
| 23509 |
amit.gupta |
559 |
orders.addCell(new Paragraph("Description", FONT_BOLD));
|
|
|
560 |
orders.addCell(new Paragraph("HSN", FONT_BOLD));
|
|
|
561 |
orders.addCell(new Paragraph("Qty", FONT_BOLD));
|
|
|
562 |
orders.addCell(new Paragraph("Rate\n(Per pc)", FONT_BOLD));
|
|
|
563 |
orders.addCell(new Paragraph("Total\nTaxable", FONT_BOLD));
|
|
|
564 |
if (!stateGst) {
|
|
|
565 |
orders.addCell(new Paragraph("IGST\n%", FONT_BOLD));
|
|
|
566 |
orders.addCell(new Paragraph("IGST", FONT_BOLD));
|
|
|
567 |
// orders.setWidths(new float[]{1, 3, 1, 1, 1, 1, 1, 1});
|
|
|
568 |
// total 8f
|
|
|
569 |
} else {
|
|
|
570 |
orders.addCell(new Paragraph("CGST %", FONT_BOLD));
|
|
|
571 |
orders.addCell(new Paragraph("CGST", FONT_BOLD));
|
|
|
572 |
orders.addCell(new Paragraph("SGST %", FONT_BOLD));
|
|
|
573 |
orders.addCell(new Paragraph("SGST", FONT_BOLD));
|
|
|
574 |
// orders.setWidths(new float[]{1, 3, 1, 1, 1, 1, 1, 1, 1,
|
|
|
575 |
// 1});
|
|
|
576 |
// total 8f
|
|
|
577 |
}
|
|
|
578 |
orders.addCell(new Paragraph("Total", FONT_BOLD));
|
|
|
579 |
|
|
|
580 |
orders.setHeaderRows(1);
|
|
|
581 |
|
|
|
582 |
float igstTotalAmount = 0, cgstTotalAmount = 0, sgstTotalAmount = 0;
|
|
|
583 |
for (CustomOrderItem orderItem : orderItems) {
|
| 23542 |
amit.gupta |
584 |
orders.addCell(new Paragraph(String.valueOf(orderItem.getOrderId()), FONT_NORMAL));
|
| 23509 |
amit.gupta |
585 |
orders.addCell(new Paragraph(orderItem.getDescription(), FONT_NORMAL));
|
|
|
586 |
orders.addCell(new Paragraph(orderItem.getHsnCode(), FONT_NORMAL));
|
|
|
587 |
orders.addCell(new Paragraph(String.valueOf(orderItem.getQuantity()), FONT_NORMAL));
|
|
|
588 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getRate()), FONT_NORMAL));
|
|
|
589 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getAmount()), FONT_NORMAL));
|
|
|
590 |
if (!stateGst) {
|
|
|
591 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getIgstRate()), FONT_NORMAL));
|
|
|
592 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getIgstAmount()), FONT_NORMAL));
|
|
|
593 |
igstTotalAmount = igstTotalAmount + orderItem.getIgstAmount();
|
|
|
594 |
} else {
|
|
|
595 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getCgstRate()), FONT_NORMAL));
|
|
|
596 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getCgstAmount()), FONT_NORMAL));
|
|
|
597 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getSgstRate()), FONT_NORMAL));
|
|
|
598 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getSgstAmount()), FONT_NORMAL));
|
|
|
599 |
cgstTotalAmount = cgstTotalAmount + orderItem.getCgstAmount();
|
|
|
600 |
sgstTotalAmount = sgstTotalAmount + orderItem.getSgstAmount();
|
|
|
601 |
}
|
|
|
602 |
orders.addCell(new Paragraph(String.format("%.0f", orderItem.getNetAmount()), FONT_NORMAL));
|
| 23533 |
amit.gupta |
603 |
LOGGER.info("IN FOR LOOP");
|
| 23509 |
amit.gupta |
604 |
}
|
|
|
605 |
|
|
|
606 |
document.add(paragraphTitle);
|
| 23533 |
amit.gupta |
607 |
|
| 23509 |
amit.gupta |
608 |
document.add(Chunk.NEWLINE);
|
|
|
609 |
document.add(tableCustomerRetailer);
|
|
|
610 |
|
|
|
611 |
document.add(Chunk.NEWLINE);
|
|
|
612 |
document.add(orders);
|
|
|
613 |
|
|
|
614 |
PdfPTable grandTotalTable = new PdfPTable(3);
|
|
|
615 |
if (stateGst) {
|
|
|
616 |
grandTotalTable.setWidths(new float[] { 6.6f, .6f, .8f });
|
|
|
617 |
} else {
|
|
|
618 |
grandTotalTable.setWidths(new float[] { 6.5f, .6f, .9f });
|
|
|
619 |
}
|
| 23549 |
amit.gupta |
620 |
grandTotalTable.setWidthPercentage(95);
|
| 23509 |
amit.gupta |
621 |
|
|
|
622 |
Paragraph grandTotalParagraph = new Paragraph("Grand total", FONT_BOLD);
|
|
|
623 |
grandTotalParagraph.setIndentationRight(20);
|
|
|
624 |
grandTotalTable.addCell(grandTotalParagraph);
|
|
|
625 |
Paragraph rsParagraph = new Paragraph("Rs.", FONT_BOLD);
|
|
|
626 |
grandTotalTable.addCell(rsParagraph);
|
|
|
627 |
Paragraph amountParagraph = new Paragraph(String.format("%.2f", pdfModel.getTotalAmount()), FONT_BOLD);
|
|
|
628 |
grandTotalTable.addCell(amountParagraph);
|
|
|
629 |
|
|
|
630 |
document.add(grandTotalTable);
|
|
|
631 |
|
|
|
632 |
PdfPTable amountInWordsTable = new PdfPTable(3);
|
|
|
633 |
if (!stateGst) {
|
|
|
634 |
amountInWordsTable.setWidths(new float[] { 2, 5.1f, 0.9f });
|
|
|
635 |
} else {
|
|
|
636 |
amountInWordsTable.setWidths(new float[] { 2, 5.2f, 0.8f });
|
|
|
637 |
}
|
| 23549 |
amit.gupta |
638 |
amountInWordsTable.setWidthPercentage(95);
|
| 23509 |
amit.gupta |
639 |
amountInWordsTable.addCell(new Paragraph("Amount in Words:", FONT_BOLD));
|
|
|
640 |
|
|
|
641 |
String amountInWords = toAmountInWords(pdfModel.getTotalAmount());
|
|
|
642 |
amountInWordsTable.addCell(new Paragraph(amountInWords.toString(), FONT_BOLD));
|
|
|
643 |
amountInWordsTable.addCell(new Paragraph("E & O.E", FONT_NORMAL));
|
|
|
644 |
document.add(amountInWordsTable);
|
|
|
645 |
|
|
|
646 |
document.newPage();
|
|
|
647 |
}
|
|
|
648 |
document.close(); // no need to close PDFwriter?
|
|
|
649 |
} catch (DocumentException e) {
|
|
|
650 |
LOGGER.error("Unable to write data to pdf file : ", e);
|
|
|
651 |
} catch (Exception e) {
|
|
|
652 |
// TODO Auto-generated catch block
|
|
|
653 |
e.printStackTrace();
|
|
|
654 |
}
|
| 21915 |
ashik.ali |
655 |
}
|
| 23509 |
amit.gupta |
656 |
|
|
|
657 |
private static String toAmountInWords(float amount) {
|
|
|
658 |
RuleBasedNumberFormat amountInWordsFormat = new RuleBasedNumberFormat(indianLocale,
|
|
|
659 |
RuleBasedNumberFormat.SPELLOUT);
|
|
|
660 |
StringBuilder amountInWords = new StringBuilder("Rs. ");
|
|
|
661 |
amountInWords.append(StringUtils.capitalize(amountInWordsFormat.format((int) amount)));
|
|
|
662 |
amountInWords.append(" and ");
|
|
|
663 |
amountInWords.append(StringUtils.capitalize(amountInWordsFormat.format((int) (amount * 100) % 100)));
|
|
|
664 |
amountInWords.append(" paise");
|
|
|
665 |
return amountInWords.toString();
|
|
|
666 |
}
|
| 23654 |
amit.gupta |
667 |
|
| 24506 |
amit.gupta |
668 |
public static void generateAndWriteCustomerCreditNotes(List<CreditNotePdfModel> creditNotes,
|
|
|
669 |
OutputStream outputStream) {
|
| 23654 |
amit.gupta |
670 |
Document document = new Document();
|
|
|
671 |
document.setMargins(0, 0, 25, 0);
|
|
|
672 |
try {
|
|
|
673 |
PdfWriter.getInstance(document, outputStream);
|
| 24506 |
amit.gupta |
674 |
|
| 23654 |
amit.gupta |
675 |
document.open();
|
|
|
676 |
document.addTitle(creditNotes.get(0).getPdfModel().getTitle());
|
|
|
677 |
document.addAuthor(creditNotes.get(0).getPdfModel().getAuther());
|
|
|
678 |
for (CreditNotePdfModel creditNotePdfModel : creditNotes) {
|
|
|
679 |
PdfModel pdfModel = creditNotePdfModel.getPdfModel();
|
|
|
680 |
CustomCustomer customer = pdfModel.getCustomer();
|
|
|
681 |
CustomRetailer retailer = pdfModel.getRetailer();
|
|
|
682 |
boolean stateGst = false;
|
|
|
683 |
String customerAddressStateCode = "", retailerAddressStateCode = "";
|
|
|
684 |
if (customer.getAddress().getState().equals(retailer.getAddress().getState())) {
|
|
|
685 |
stateGst = true;
|
|
|
686 |
customerAddressStateCode = Utils.getStateCode(customer.getAddress().getState());
|
|
|
687 |
retailerAddressStateCode = customerAddressStateCode;
|
|
|
688 |
} else {
|
|
|
689 |
customerAddressStateCode = Utils.getStateCode(customer.getAddress().getState());
|
|
|
690 |
retailerAddressStateCode = Utils.getStateCode(retailer.getAddress().getState());
|
|
|
691 |
}
|
|
|
692 |
Set<CustomOrderItem> orderItems = pdfModel.getOrderItems();
|
|
|
693 |
|
|
|
694 |
Paragraph paragraphTitle = new Paragraph(pdfModel.getTitle(), FONT_TITLE);
|
|
|
695 |
paragraphTitle.setAlignment(Element.ALIGN_CENTER);
|
|
|
696 |
|
|
|
697 |
PdfPCell blankCell = new PdfPCell();
|
|
|
698 |
blankCell.setBorder(Rectangle.NO_BORDER);
|
|
|
699 |
PdfPTable tableCustomerRetailer = new PdfPTable(3);
|
|
|
700 |
tableCustomerRetailer.setWidthPercentage(95);
|
|
|
701 |
PdfPCell partnerInfo = new PdfPCell();
|
|
|
702 |
partnerInfo.addElement(new Paragraph("To Party:", FONT_BOLD));
|
|
|
703 |
partnerInfo.addElement(
|
|
|
704 |
new Paragraph(StringUtils.capitalize(customer.getAddress().getName()), FONT_NORMAL));
|
|
|
705 |
partnerInfo.addElement(new Paragraph(
|
|
|
706 |
StringUtils.capitalize(customer.getAddress().getLine1()) + ", "
|
|
|
707 |
+ (customer.getAddress().getLine2() == null ? ""
|
|
|
708 |
: StringUtils.capitalize(customer.getAddress().getLine2()))
|
|
|
709 |
+ ", " + customer.getAddress().getCity() + " - " + customer.getAddress().getPinCode(),
|
|
|
710 |
FONT_NORMAL));
|
|
|
711 |
|
|
|
712 |
partnerInfo.addElement(new Paragraph(
|
|
|
713 |
StringUtils.capitalize(customer.getAddress().getState()) + "(" + customerAddressStateCode + ")",
|
|
|
714 |
FONT_NORMAL));
|
|
|
715 |
partnerInfo.addElement(new Paragraph("Mobile - " + customer.getMobileNumber(), FONT_NORMAL));
|
|
|
716 |
if (customer.getGstNumber() != null && !customer.getGstNumber().isEmpty()) {
|
|
|
717 |
partnerInfo.addElement(new Paragraph("GST No - " + customer.getGstNumber(), FONT_BOLD));
|
|
|
718 |
}
|
|
|
719 |
|
|
|
720 |
PdfPCell sellerParty = new PdfPCell();
|
|
|
721 |
sellerParty.addElement(new Paragraph("From Party:", FONT_BOLD));
|
|
|
722 |
sellerParty.addElement(
|
|
|
723 |
new Paragraph(StringUtils.capitalize(retailer.getAddress().getName()), FONT_NORMAL));
|
|
|
724 |
sellerParty.addElement(new Paragraph((retailer.getAddress().getLine1() == null ? ""
|
|
|
725 |
: StringUtils.capitalize(retailer.getAddress().getLine1()) + ", ")
|
|
|
726 |
+ (retailer.getAddress().getLine2() == null ? ""
|
|
|
727 |
: StringUtils.capitalize(retailer.getAddress().getLine2()) + ", ")
|
|
|
728 |
+ StringUtils.capitalize(retailer.getAddress().getCity()) + "-"
|
|
|
729 |
+ retailer.getAddress().getPinCode() + ", ", FONT_NORMAL));
|
|
|
730 |
sellerParty.addElement(new Paragraph(
|
|
|
731 |
retailer.getAddress().getState() + "(" + retailerAddressStateCode + ")", FONT_NORMAL));
|
|
|
732 |
sellerParty
|
|
|
733 |
.addElement(new Paragraph("Mobile - " + retailer.getAddress().getPhoneNumber(), FONT_NORMAL));
|
|
|
734 |
sellerParty.addElement(new Paragraph("GST No - " + retailer.getGstNumber(), FONT_BOLD));
|
|
|
735 |
|
|
|
736 |
PdfPTable tableInvoiceDateRetailer = new PdfPTable(1);
|
|
|
737 |
tableInvoiceDateRetailer.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
|
|
738 |
|
|
|
739 |
PdfPTable tableInvoiceDate = new PdfPTable(2);
|
|
|
740 |
tableInvoiceDate.getDefaultCell().setBorder(Rectangle.NO_BORDER);
|
|
|
741 |
tableInvoiceDate.setWidthPercentage(90);
|
|
|
742 |
|
|
|
743 |
PdfPCell debitNoteDetails = new PdfPCell(new Paragraph("Credit Note Details", FONT_BOLD));
|
|
|
744 |
debitNoteDetails.setColspan(2);
|
|
|
745 |
debitNoteDetails.setBorder(Rectangle.NO_BORDER);
|
|
|
746 |
|
|
|
747 |
PdfPCell debitNoteNumberKey = new PdfPCell(new Paragraph("Credit Note No:", FONT_NORMAL));
|
|
|
748 |
debitNoteNumberKey.setBorder(Rectangle.NO_BORDER);
|
|
|
749 |
PdfPCell debitNoteNumberValue = new PdfPCell(
|
|
|
750 |
new Paragraph(creditNotePdfModel.getCreditNoteNumber(), FONT_NORMAL));
|
|
|
751 |
debitNoteNumberValue.setBorder(Rectangle.NO_BORDER);
|
|
|
752 |
|
|
|
753 |
PdfPCell debitNoteDateKey = new PdfPCell(new Paragraph("Credit Note Dt:", FONT_NORMAL));
|
|
|
754 |
debitNoteDateKey.setBorder(Rectangle.NO_BORDER);
|
|
|
755 |
|
|
|
756 |
PdfPCell debitNoteDateValue = new PdfPCell(
|
|
|
757 |
new Paragraph(creditNotePdfModel.getCreditNoteDate(), FONT_NORMAL));
|
|
|
758 |
debitNoteDateValue.setBorder(Rectangle.NO_BORDER);
|
|
|
759 |
|
|
|
760 |
PdfPCell invoiceNumberKey = new PdfPCell(new Paragraph("Invoice Ref No:", FONT_NORMAL));
|
|
|
761 |
invoiceNumberKey.setBorder(Rectangle.NO_BORDER);
|
|
|
762 |
PdfPCell invoiceNumberValue = new PdfPCell(new Paragraph(pdfModel.getInvoiceNumber(), FONT_NORMAL));
|
|
|
763 |
invoiceNumberValue.setBorder(Rectangle.NO_BORDER);
|
|
|
764 |
|
|
|
765 |
PdfPCell dateKey = new PdfPCell(new Paragraph("Invoice Dt:", FONT_NORMAL));
|
|
|
766 |
dateKey.setBorder(Rectangle.NO_BORDER);
|
|
|
767 |
PdfPCell dateValue = new PdfPCell(new Paragraph(pdfModel.getInvoiceDate(), FONT_NORMAL));
|
|
|
768 |
dateValue.setBorder(Rectangle.NO_BORDER);
|
|
|
769 |
|
|
|
770 |
tableInvoiceDate.addCell(debitNoteDetails);
|
|
|
771 |
tableInvoiceDate.addCell(debitNoteNumberKey);
|
|
|
772 |
tableInvoiceDate.addCell(debitNoteNumberValue);
|
|
|
773 |
tableInvoiceDate.addCell(debitNoteDateKey);
|
|
|
774 |
tableInvoiceDate.addCell(debitNoteDateValue);
|
|
|
775 |
tableInvoiceDate.addCell(invoiceNumberKey);
|
|
|
776 |
tableInvoiceDate.addCell(invoiceNumberValue);
|
|
|
777 |
tableInvoiceDate.addCell(dateKey);
|
|
|
778 |
tableInvoiceDate.addCell(dateValue);
|
|
|
779 |
|
|
|
780 |
tableCustomerRetailer.addCell(partnerInfo);
|
|
|
781 |
tableCustomerRetailer.addCell(tableInvoiceDate);
|
|
|
782 |
tableCustomerRetailer.addCell(sellerParty);
|
|
|
783 |
|
|
|
784 |
PdfPTable orders = null;
|
|
|
785 |
if (stateGst) {
|
|
|
786 |
orders = new PdfPTable(stateWidthsCrNote.length);
|
|
|
787 |
orders.setWidths(stateWidthsCrNote);
|
|
|
788 |
} else {
|
|
|
789 |
orders = new PdfPTable(igstWidthsCrNote.length);
|
|
|
790 |
orders.setWidths(igstWidthsCrNote);
|
|
|
791 |
}
|
|
|
792 |
orders.setWidthPercentage(95);
|
|
|
793 |
orders.addCell(new Paragraph("Description", FONT_BOLD));
|
|
|
794 |
orders.addCell(new Paragraph("HSN", FONT_BOLD));
|
|
|
795 |
orders.addCell(new Paragraph("Qty", FONT_BOLD));
|
|
|
796 |
orders.addCell(new Paragraph("Rate\n(Per pc)", FONT_BOLD));
|
|
|
797 |
orders.addCell(new Paragraph("Total\nTaxable", FONT_BOLD));
|
|
|
798 |
if (!stateGst) {
|
|
|
799 |
orders.addCell(new Paragraph("IGST%", FONT_BOLD));
|
|
|
800 |
orders.addCell(new Paragraph("IGST", FONT_BOLD));
|
|
|
801 |
// orders.setWidths(new float[]{1, 3, 1, 1, 1, 1, 1, 1});
|
|
|
802 |
// total 8f
|
|
|
803 |
} else {
|
|
|
804 |
orders.addCell(new Paragraph("CGST %", FONT_BOLD));
|
|
|
805 |
orders.addCell(new Paragraph("CGST", FONT_BOLD));
|
|
|
806 |
orders.addCell(new Paragraph("SGST %", FONT_BOLD));
|
|
|
807 |
orders.addCell(new Paragraph("SGST", FONT_BOLD));
|
|
|
808 |
// orders.setWidths(new float[]{1, 3, 1, 1, 1, 1, 1, 1, 1,
|
|
|
809 |
// 1});
|
|
|
810 |
// total 8f
|
|
|
811 |
}
|
|
|
812 |
orders.addCell(new Paragraph("Total", FONT_BOLD));
|
|
|
813 |
|
|
|
814 |
orders.setHeaderRows(1);
|
|
|
815 |
|
|
|
816 |
float igstTotalAmount = 0, cgstTotalAmount = 0, sgstTotalAmount = 0;
|
|
|
817 |
for (CustomOrderItem orderItem : orderItems) {
|
|
|
818 |
LOGGER.info("Custom Order Item - {}", orderItem);
|
|
|
819 |
orders.addCell(new Paragraph(orderItem.getDescription(), FONT_NORMAL));
|
|
|
820 |
orders.addCell(new Paragraph(orderItem.getHsnCode(), FONT_NORMAL));
|
|
|
821 |
orders.addCell(new Paragraph(String.valueOf(orderItem.getQuantity()), FONT_NORMAL));
|
|
|
822 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getRate()), FONT_NORMAL));
|
|
|
823 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getAmount()), FONT_NORMAL));
|
|
|
824 |
if (!stateGst) {
|
|
|
825 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getIgstRate()), FONT_NORMAL));
|
|
|
826 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getIgstAmount()), FONT_NORMAL));
|
|
|
827 |
igstTotalAmount = igstTotalAmount + orderItem.getIgstAmount();
|
|
|
828 |
} else {
|
|
|
829 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getCgstRate()), FONT_NORMAL));
|
|
|
830 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getCgstAmount()), FONT_NORMAL));
|
|
|
831 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getSgstRate()), FONT_NORMAL));
|
|
|
832 |
orders.addCell(new Paragraph(String.format("%.2f", orderItem.getSgstAmount()), FONT_NORMAL));
|
|
|
833 |
cgstTotalAmount = cgstTotalAmount + orderItem.getCgstAmount();
|
|
|
834 |
sgstTotalAmount = sgstTotalAmount + orderItem.getSgstAmount();
|
|
|
835 |
}
|
|
|
836 |
orders.addCell(new Paragraph(String.format("%.0f", orderItem.getNetAmount()), FONT_NORMAL));
|
|
|
837 |
LOGGER.info("IN FOR LOOP");
|
|
|
838 |
}
|
|
|
839 |
|
|
|
840 |
document.add(paragraphTitle);
|
|
|
841 |
|
|
|
842 |
document.add(Chunk.NEWLINE);
|
|
|
843 |
document.add(tableCustomerRetailer);
|
|
|
844 |
|
|
|
845 |
document.add(Chunk.NEWLINE);
|
|
|
846 |
document.add(orders);
|
|
|
847 |
|
|
|
848 |
PdfPTable grandTotalTable = new PdfPTable(3);
|
|
|
849 |
if (stateGst) {
|
|
|
850 |
grandTotalTable.setWidths(new float[] { 6.6f, .6f, .8f });
|
|
|
851 |
} else {
|
|
|
852 |
grandTotalTable.setWidths(new float[] { 6.5f, .6f, .9f });
|
|
|
853 |
}
|
|
|
854 |
grandTotalTable.setWidthPercentage(95);
|
|
|
855 |
|
|
|
856 |
Paragraph grandTotalParagraph = new Paragraph("Grand total", FONT_BOLD);
|
|
|
857 |
grandTotalParagraph.setIndentationRight(20);
|
|
|
858 |
grandTotalTable.addCell(grandTotalParagraph);
|
|
|
859 |
Paragraph rsParagraph = new Paragraph("Rs.", FONT_BOLD);
|
|
|
860 |
grandTotalTable.addCell(rsParagraph);
|
|
|
861 |
Paragraph amountParagraph = new Paragraph(String.format("%.2f", pdfModel.getTotalAmount()), FONT_BOLD);
|
|
|
862 |
grandTotalTable.addCell(amountParagraph);
|
|
|
863 |
|
|
|
864 |
document.add(grandTotalTable);
|
|
|
865 |
|
|
|
866 |
PdfPTable amountInWordsTable = new PdfPTable(3);
|
|
|
867 |
if (!stateGst) {
|
|
|
868 |
amountInWordsTable.setWidths(new float[] { 2, 5.1f, 0.9f });
|
|
|
869 |
} else {
|
|
|
870 |
amountInWordsTable.setWidths(new float[] { 2, 5.2f, 0.8f });
|
|
|
871 |
}
|
|
|
872 |
amountInWordsTable.setWidthPercentage(95);
|
|
|
873 |
amountInWordsTable.addCell(new Paragraph("Amount in Words:", FONT_BOLD));
|
|
|
874 |
|
|
|
875 |
String amountInWords = toAmountInWords(pdfModel.getTotalAmount());
|
|
|
876 |
amountInWordsTable.addCell(new Paragraph(amountInWords.toString(), FONT_BOLD));
|
|
|
877 |
amountInWordsTable.addCell(new Paragraph("E & O.E", FONT_NORMAL));
|
|
|
878 |
document.add(amountInWordsTable);
|
|
|
879 |
|
|
|
880 |
document.newPage();
|
|
|
881 |
}
|
|
|
882 |
document.close(); // no need to close PDFwriter?
|
|
|
883 |
} catch (DocumentException e) {
|
|
|
884 |
LOGGER.error("Unable to write data to pdf file : ", e);
|
|
|
885 |
} catch (Exception e) {
|
|
|
886 |
// TODO Auto-generated catch block
|
|
|
887 |
e.printStackTrace();
|
|
|
888 |
}
|
|
|
889 |
|
|
|
890 |
}
|
| 21686 |
ashik.ali |
891 |
}
|