| Line 20... |
Line 20... |
| 20 |
import com.itextpdf.text.DocumentException;
|
20 |
import com.itextpdf.text.DocumentException;
|
| 21 |
import com.itextpdf.text.Element;
|
21 |
import com.itextpdf.text.Element;
|
| 22 |
import com.itextpdf.text.Font;
|
22 |
import com.itextpdf.text.Font;
|
| 23 |
import com.itextpdf.text.Font.FontFamily;
|
23 |
import com.itextpdf.text.Font.FontFamily;
|
| 24 |
import com.itextpdf.text.Image;
|
24 |
import com.itextpdf.text.Image;
|
| - |
|
25 |
import com.itextpdf.text.PageSize;
|
| 25 |
import com.itextpdf.text.Paragraph;
|
26 |
import com.itextpdf.text.Paragraph;
|
| 26 |
import com.itextpdf.text.Phrase;
|
27 |
import com.itextpdf.text.Phrase;
|
| 27 |
import com.itextpdf.text.Rectangle;
|
28 |
import com.itextpdf.text.Rectangle;
|
| 28 |
import com.itextpdf.text.pdf.PdfContentByte;
|
29 |
import com.itextpdf.text.pdf.PdfContentByte;
|
| 29 |
import com.itextpdf.text.pdf.PdfGState;
|
30 |
import com.itextpdf.text.pdf.PdfGState;
|
| 30 |
import com.itextpdf.text.pdf.PdfPCell;
|
31 |
import com.itextpdf.text.pdf.PdfPCell;
|
| 31 |
import com.itextpdf.text.pdf.PdfPTable;
|
32 |
import com.itextpdf.text.pdf.PdfPTable;
|
| 32 |
import com.itextpdf.text.pdf.PdfReader;
|
33 |
import com.itextpdf.text.pdf.PdfReader;
|
| 33 |
import com.itextpdf.text.pdf.PdfStamper;
|
34 |
import com.itextpdf.text.pdf.PdfStamper;
|
| 34 |
import com.itextpdf.text.pdf.PdfWriter;
|
35 |
import com.itextpdf.text.pdf.PdfWriter;
|
| - |
|
36 |
import com.microsoft.schemas.office.visio.x2012.main.PagesDocument;
|
| 35 |
import com.spice.profitmandi.common.model.CreditNotePdfModel;
|
37 |
import com.spice.profitmandi.common.model.CreditNotePdfModel;
|
| 36 |
import com.spice.profitmandi.common.model.CustomCustomer;
|
38 |
import com.spice.profitmandi.common.model.CustomCustomer;
|
| 37 |
import com.spice.profitmandi.common.model.CustomInsurancePolicy;
|
39 |
import com.spice.profitmandi.common.model.CustomInsurancePolicy;
|
| 38 |
import com.spice.profitmandi.common.model.CustomOrderItem;
|
40 |
import com.spice.profitmandi.common.model.CustomOrderItem;
|
| 39 |
import com.spice.profitmandi.common.model.CustomPaymentOption;
|
41 |
import com.spice.profitmandi.common.model.CustomPaymentOption;
|
| Line 70... |
Line 72... |
| 70 |
private static final URL iconUrl = PdfUtils.class.getClassLoader().getResource("sdicon.png");
|
72 |
private static final URL iconUrl = PdfUtils.class.getClassLoader().getResource("sdicon.png");
|
| 71 |
private static Image iconImg = null;
|
73 |
private static Image iconImg = null;
|
| 72 |
static {
|
74 |
static {
|
| 73 |
try {
|
75 |
try {
|
| 74 |
iconImg = Image.getInstance(iconUrl);
|
76 |
iconImg = Image.getInstance(iconUrl);
|
| 75 |
iconImg.setAbsolutePosition(30, 30);
|
- |
|
| 76 |
iconImg.scalePercent(50);
|
- |
|
| 77 |
} catch (Exception e) {
|
77 |
} catch (Exception e) {
|
| 78 |
e.printStackTrace();
|
78 |
e.printStackTrace();
|
| 79 |
}
|
79 |
}
|
| 80 |
}
|
80 |
}
|
| 81 |
|
81 |
|
| Line 259... |
Line 259... |
| 259 |
cgstTotalAmount = cgstTotalAmount + insurancePolicy.getCgstAmount();
|
259 |
cgstTotalAmount = cgstTotalAmount + insurancePolicy.getCgstAmount();
|
| 260 |
sgstTotalAmount = sgstTotalAmount + insurancePolicy.getSgstAmount();
|
260 |
sgstTotalAmount = sgstTotalAmount + insurancePolicy.getSgstAmount();
|
| 261 |
}
|
261 |
}
|
| 262 |
orders.addCell(new Paragraph(String.format("%.0f", insurancePolicy.getNetAmount()), FONT_NORMAL));
|
262 |
orders.addCell(new Paragraph(String.format("%.0f", insurancePolicy.getNetAmount()), FONT_NORMAL));
|
| 263 |
}
|
263 |
}
|
| - |
|
264 |
Rectangle rectangle = document.getPageSize();
|
| - |
|
265 |
iconImg.setAbsolutePosition(30, rectangle.getHeight()-30);
|
| - |
|
266 |
iconImg.scalePercent(50);
|
| 264 |
document.add(iconImg);
|
267 |
document.add(iconImg);
|
| 265 |
document.add(paragraphTitle);
|
268 |
document.add(paragraphTitle);
|
| 266 |
document.add(Chunk.NEWLINE);
|
269 |
document.add(Chunk.NEWLINE);
|
| 267 |
document.add(Chunk.NEWLINE);
|
270 |
document.add(Chunk.NEWLINE);
|
| 268 |
document.add(tableCustomerRetailer);
|
271 |
document.add(tableCustomerRetailer);
|
| Line 388... |
Line 391... |
| 388 |
float hWatermark = imgWatermark.getScaledHeight() / 2;
|
391 |
float hWatermark = imgWatermark.getScaledHeight() / 2;
|
| 389 |
// transparency
|
392 |
// transparency
|
| 390 |
PdfGState gs1 = new PdfGState();
|
393 |
PdfGState gs1 = new PdfGState();
|
| 391 |
gs1.setFillOpacity(0.5f);
|
394 |
gs1.setFillOpacity(0.5f);
|
| 392 |
PdfGState gs2 = new PdfGState();
|
395 |
PdfGState gs2 = new PdfGState();
|
| 393 |
gs2.setFillOpacity(0.3f);
|
396 |
gs2.setFillOpacity(0.25f);
|
| 394 |
// properties
|
397 |
// properties
|
| 395 |
PdfContentByte over;
|
398 |
PdfContentByte over;
|
| 396 |
Rectangle pagesize;
|
399 |
Rectangle pagesize;
|
| 397 |
float x, y;
|
400 |
float x, y;
|
| 398 |
|
401 |
|
| 399 |
// loop over every page
|
402 |
// loop over every page
|
| 400 |
for (int i = 1; i <= n; i++) {
|
403 |
for (int i = 1; i <= n; i++) {
|
| - |
|
404 |
pagesize = pdfReader.getPageSize(i);
|
| - |
|
405 |
x = (pagesize.getLeft() + pagesize.getRight()) / 2;
|
| - |
|
406 |
y = (pagesize.getTop() + pagesize.getBottom()) / 2;
|
| - |
|
407 |
over = pdfStamper.getOverContent(i);
|
| - |
|
408 |
over.saveState();
|
| 401 |
if (cancelledPage.get(i - 1) == 1) {
|
409 |
if (cancelledPage.get(i - 1) == 1) {
|
| 402 |
pagesize = pdfReader.getPageSize(i);
|
- |
|
| 403 |
x = (pagesize.getLeft() + pagesize.getRight()) / 2;
|
- |
|
| 404 |
y = (pagesize.getTop() + pagesize.getBottom()) / 2;
|
- |
|
| 405 |
over = pdfStamper.getOverContent(i);
|
- |
|
| 406 |
over.saveState();
|
- |
|
| 407 |
over.setGState(gs1);
|
410 |
over.setGState(gs1);
|
| 408 |
over.addImage(imgCancelled, w, 0, 0, h, x - (w / 2), y - (h / 2));
|
411 |
over.addImage(imgCancelled, w, 0, 0, h, x - (w / 2), y - (h / 2));
|
| 409 |
over.restoreState();
|
412 |
over.restoreState();
|
| 410 |
} else {
|
413 |
} else {
|
| 411 |
pagesize = pdfReader.getPageSize(i);
|
- |
|
| 412 |
x = (pagesize.getLeft() + pagesize.getRight()) / 2;
|
- |
|
| 413 |
y = (pagesize.getTop() + pagesize.getBottom()) / 2;
|
- |
|
| 414 |
over = pdfStamper.getOverContent(i);
|
- |
|
| 415 |
over.saveState();
|
- |
|
| 416 |
over.setGState(gs2);
|
- |
|
| 417 |
over.addImage(imgWatermark, wWaterMark, 0, 0, hWatermark, x - (wWaterMark / 2), y - (hWatermark / 2));
|
- |
|
| 418 |
over.restoreState();
|
- |
|
| 419 |
x = (pagesize.getLeft() + pagesize.getRight()) / 2;
|
- |
|
| 420 |
y = (pagesize.getTop() + pagesize.getBottom()) / 2;
|
- |
|
| 421 |
over = pdfStamper.getOverContent(i);
|
- |
|
| 422 |
over.saveState();
|
- |
|
| 423 |
over.setGState(gs2);
|
414 |
over.setGState(gs2);
|
| 424 |
over.addImage(imgWatermark, wWaterMark, 0, 0, hWatermark, x - (wWaterMark / 2), y - (hWatermark / 2));
|
415 |
over.addImage(imgWatermark, wWaterMark, 0, 0, hWatermark, x - (wWaterMark / 2), y - (hWatermark / 2));
|
| 425 |
over.restoreState();
|
416 |
over.restoreState();
|
| 426 |
}
|
417 |
}
|
| 427 |
}
|
418 |
}
|