Subversion Repositories SmartDukaan

Rev

Rev 28395 | Rev 30300 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 28395 Rev 29930
Line 1... Line 1...
1
package com.spice.profitmandi.common.util;
1
package com.spice.profitmandi.common.util;
2
 
2
 
-
 
3
import com.ibm.icu.text.RuleBasedNumberFormat;
-
 
4
import com.itextpdf.text.*;
-
 
5
import com.itextpdf.text.Font.FontFamily;
-
 
6
import com.itextpdf.text.pdf.*;
-
 
7
import com.spice.profitmandi.common.model.*;
-
 
8
import org.apache.logging.log4j.LogManager;
-
 
9
import org.apache.logging.log4j.Logger;
-
 
10
import org.springframework.util.StringUtils;
-
 
11
 
3
import java.io.ByteArrayInputStream;
12
import java.io.ByteArrayInputStream;
4
import java.io.ByteArrayOutputStream;
13
import java.io.ByteArrayOutputStream;
5
import java.io.IOException;
14
import java.io.IOException;
6
import java.io.OutputStream;
15
import java.io.OutputStream;
7
import java.net.URL;
16
import java.net.URL;
8
import java.util.ArrayList;
17
import java.util.ArrayList;
9
import java.util.List;
18
import java.util.List;
10
import java.util.Locale;
19
import java.util.Locale;
11
import java.util.Set;
20
import java.util.Set;
12
 
21
 
13
import org.apache.logging.log4j.LogManager;
-
 
14
import org.apache.logging.log4j.Logger;
-
 
15
import org.springframework.util.StringUtils;
-
 
16
 
-
 
17
import com.ibm.icu.text.RuleBasedNumberFormat;
-
 
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;
-
 
23
import com.itextpdf.text.Font.FontFamily;
-
 
24
import com.itextpdf.text.Image;
-
 
25
import com.itextpdf.text.Paragraph;
-
 
26
import com.itextpdf.text.Phrase;
-
 
27
import com.itextpdf.text.Rectangle;
-
 
28
import com.itextpdf.text.pdf.PdfContentByte;
-
 
29
import com.itextpdf.text.pdf.PdfGState;
-
 
30
import com.itextpdf.text.pdf.PdfPCell;
-
 
31
import com.itextpdf.text.pdf.PdfPTable;
-
 
32
import com.itextpdf.text.pdf.PdfReader;
-
 
33
import com.itextpdf.text.pdf.PdfStamper;
-
 
34
import com.itextpdf.text.pdf.PdfWriter;
-
 
35
import com.spice.profitmandi.common.model.CreditNotePdfModel;
-
 
36
import com.spice.profitmandi.common.model.CustomCustomer;
-
 
37
import com.spice.profitmandi.common.model.CustomInsurancePolicy;
-
 
38
import com.spice.profitmandi.common.model.CustomOrderItem;
-
 
39
import com.spice.profitmandi.common.model.CustomPaymentOption;
-
 
40
import com.spice.profitmandi.common.model.CustomRetailer;
-
 
41
import com.spice.profitmandi.common.model.DebitNotePdfModel;
-
 
42
import com.spice.profitmandi.common.model.PdfModel;
-
 
43
 
-
 
44
public class PdfUtils {
22
public class PdfUtils {
45
 
23
 
46
	private static final Font FONT_TITLE = new Font(Font.FontFamily.HELVETICA, 18, Font.BOLD);
24
	private static final Font FONT_TITLE = new Font(Font.FontFamily.HELVETICA, 18, Font.BOLD);
47
	private static Font FONT_NORMAL = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL);
25
	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);
26
	private static Font FONT_BOLD = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD);
Line 324... Line 302...
324
						cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
302
						cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
325
						cell.setPadding(5);
303
						cell.setPadding(5);
326
						paidAmountTable.addCell(cell);
304
						paidAmountTable.addCell(cell);
327
 
305
 
328
						PdfPCell cell1 = new PdfPCell(new Paragraph(10,
306
						PdfPCell cell1 = new PdfPCell(new Paragraph(10,
329
								FormattingUtils.formatDecimalTwoDigits(paymentOption.getAmount()), FONT_BOLD));
307
								FormattingUtils.formatDecimal(paymentOption.getAmount()), FONT_BOLD));
330
						cell1.setPadding(5);
308
						cell1.setPadding(5);
331
						paidAmountTable.addCell(cell1);
309
						paidAmountTable.addCell(cell1);
332
						totalPaidValue += paymentOption.getAmount();
310
						totalPaidValue += paymentOption.getAmount();
333
 
311
 
334
					}
312
					}
Line 336... Line 314...
336
					totalPaidCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
314
					totalPaidCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
337
					totalPaidCell.setPadding(5);
315
					totalPaidCell.setPadding(5);
338
					paidAmountTable.addCell(totalPaidCell);
316
					paidAmountTable.addCell(totalPaidCell);
339
 
317
 
340
					PdfPCell totalPaidValueCell = new PdfPCell(
318
					PdfPCell totalPaidValueCell = new PdfPCell(
341
							new Paragraph(10, FormattingUtils.formatDecimalTwoDigits(totalPaidValue), FONT_BOLD));
319
							new Paragraph(10, FormattingUtils.formatDecimal(totalPaidValue), FONT_BOLD));
342
					totalPaidValueCell.setPadding(5);
320
					totalPaidValueCell.setPadding(5);
343
					paidAmountTable.addCell(totalPaidValueCell);
321
					paidAmountTable.addCell(totalPaidValueCell);
344
 
322
 
345
					document.add(paidAmountTable);
323
					document.add(paidAmountTable);
346
				}
324
				}