View Javadoc

1   package org.kuali.ole.deliver.loan.printSlip;
2   
3   
4   
5   import com.lowagie.text.*;
6   import com.lowagie.text.Font;
7   import com.lowagie.text.pdf.*;
8   import org.apache.log4j.Logger;
9   import org.kuali.ole.OLEConstants;
10  import org.kuali.ole.deliver.circulationdesk.bo.OleCirculationDesk;
11  import org.kuali.ole.deliver.loan.LoanProcessor;
12  import org.kuali.ole.deliver.loan.bo.OleLoanDocument;
13  import org.kuali.ole.deliver.request.bo.OleDeliverRequestBo;
14  import org.kuali.ole.docstore.model.xmlpojo.work.instance.oleml.Item;
15  import org.kuali.ole.location.bo.OleLocation;
16  import org.kuali.ole.patron.bo.OlePatronDocument;
17  import org.kuali.rice.kim.impl.identity.name.EntityNameBo;
18  
19  import javax.servlet.ServletOutputStream;
20  import javax.servlet.http.HttpServletResponse;
21  import java.awt.*;
22  import java.io.ByteArrayOutputStream;
23  import java.io.OutputStream;
24  import java.text.SimpleDateFormat;
25  import java.util.*;
26  import java.util.List;
27  
28  /**
29   * The OlePrintSlip  class used to create pdf document .
30   */
31  public class OlePrintSlip extends PdfPageEventHelper {
32  
33      private static final Logger LOG = Logger.getLogger(OlePrintSlip.class);
34  
35      private Map<String, Font> printFontMap = new HashMap<String, Font>();
36  
37      private Map<String, Font> fontMap = new HashMap<String, Font>();
38      private Map<String, Color> colorMap = new HashMap<String, Color>();
39      private Map<String, Color> printColorMap = new HashMap<String, Color>();
40  
41  
42      public void populateFontMap() {
43          fontMap.put("COURIER", new Font(Font.COURIER));
44          fontMap.put("BOLD", new Font(Font.BOLD));
45          fontMap.put("BOLDITALIC", new Font(Font.BOLDITALIC));
46          fontMap.put("DEFAULTSIZE", new Font(Font.DEFAULTSIZE));
47          fontMap.put("HELVETICA", new Font(Font.HELVETICA));
48          fontMap.put("ITALIC", new Font(Font.ITALIC));
49          fontMap.put("NORMAL", new Font(Font.NORMAL));
50          fontMap.put("STRIKETHRU", new Font(Font.STRIKETHRU));
51          fontMap.put("SYMBOL", new Font(Font.SYMBOL));
52          fontMap.put("TIMES_ROMAN", new Font(Font.TIMES_ROMAN));
53          fontMap.put("UNDEFINED", new Font(Font.UNDEFINED));
54          fontMap.put("UNDERLINE", new Font(Font.UNDERLINE));
55          fontMap.put("ZAPFDINGBATS", new Font(Font.ZAPFDINGBATS));
56  
57      }
58  
59      public void populateColorMap() {
60          colorMap.put("WHITE", Color.WHITE);
61          colorMap.put("YELLOW", Color.YELLOW);
62          colorMap.put("BLACK", Color.BLACK);
63          colorMap.put("BLUE", Color.BLUE);
64          colorMap.put("CYAN", Color.CYAN);
65          colorMap.put("DARK_GRAY", Color.DARK_GRAY);
66          colorMap.put("GRAY", Color.GRAY);
67          colorMap.put("GREEN", Color.GREEN);
68          colorMap.put("LIGHT_GRAY", Color.LIGHT_GRAY);
69          colorMap.put("MAGENTA", Color.MAGENTA);
70          colorMap.put("ORANGE", Color.ORANGE);
71          colorMap.put("PINK", Color.PINK);
72          colorMap.put("RED", Color.RED);
73          colorMap.put("PINK", Color.PINK);
74      }
75  
76  
77      /**
78       *  Used to create pdf document for hold slip
79       * @param oleLoanDocument
80       * @return Void
81       */
82      public void createPdfForPrintingSlip( OleLoanDocument oleLoanDocument,HttpServletResponse response) {
83          LOG.debug("Initialize Normal pdf Template");
84          OlePatronDocument olePatronDocument = oleLoanDocument!=null?oleLoanDocument.getOlePatron():null;
85          if(olePatronDocument!=null){
86              EntityNameBo nameBo = olePatronDocument!=null?olePatronDocument.getEntity().getNames().get(0):null;
87              String patronName = nameBo!=null? nameBo.getFirstName()+","+nameBo.getLastName():null;
88              Date expirationDate =  olePatronDocument!=null?olePatronDocument.getExpirationDate():null;
89              LoanProcessor loanProcessor = new LoanProcessor();
90              OleLocation oleLocation=null;
91              OleCirculationDesk oleCirculationDesk = null;
92              try {
93                  if(oleLoanDocument.getCirculationLocationId() != null){
94                      oleCirculationDesk = loanProcessor.getOleCirculationDesk(oleLoanDocument.getCirculationLocationId());
95                      oleLocation =oleCirculationDesk!=null?oleCirculationDesk.getOleCirculationDeskLocations().get(0).getLocation():null;
96                  }
97                  String locationName = oleLocation!=null?oleLocation.getLocationName():null;
98                  String itemBarcode = oleLoanDocument.getItemId();
99                  String itemCallNumber = null;
100                 String copyNumber=null;
101                 Item oleItem = oleLoanDocument.getOleItem();
102                 if(oleItem!=null){
103                     itemCallNumber = loanProcessor.getItemCallNumber(oleItem,oleLoanDocument.getInstanceUuid());
104                     copyNumber = oleItem.getCopyNumber();
105 
106                 }else{
107                     Map itemUuid = loanProcessor.getItemDetails(itemBarcode);
108                     Map bibInformation = loanProcessor.getTitleAndAuthorfromBib((String) itemUuid.get(OLEConstants.BIB_UUID));
109                     String itemXml = null;
110                     oleLoanDocument.setInstanceUuid((String) itemUuid.get(OLEConstants.INSTANCE_UUID));
111                     oleLoanDocument.setItemUuid((String) itemUuid.get(OLEConstants.ITEM_UUID));
112                     oleLoanDocument.setTitle((String)bibInformation.get(OLEConstants.TITLE));
113                     oleLoanDocument.setAuthor((String)bibInformation.get(OLEConstants.AUTHOR));
114                     itemXml = loanProcessor.getItemXML(oleLoanDocument.getItemUuid());
115                     oleItem = loanProcessor.getItemPojo(itemXml);
116                     itemCallNumber = loanProcessor.getItemCallNumber(oleItem,oleLoanDocument.getInstanceUuid());
117                     copyNumber = oleItem.getCopyNumber();
118                 }
119                 String itemTitle = oleLoanDocument.getTitle();
120                 OleDeliverRequestBo oleDeliverRequestBo = oleLoanDocument.getOleDeliverRequestBo();
121                 String requestedBy =null;
122                 if(oleDeliverRequestBo!=null){
123                     requestedBy= oleDeliverRequestBo.getBorrowerName();
124                 }
125                 String itemStatus = oleLoanDocument.getItemStatus()!=null?oleLoanDocument.getItemStatus():"";
126                 boolean holdSlip = itemStatus.equalsIgnoreCase(OLEConstants.ITEM_STATUS_ON_HOLD);
127                 boolean inTransitSlip = itemStatus.equalsIgnoreCase(OLEConstants.ITEM_STATUS_IN_TRANSIT);
128                 boolean inTransitForHold = itemStatus.equalsIgnoreCase(OLEConstants.ITEM_STATUS_IN_TRANSIT_HOLD);
129                 boolean inTransitPerStaff = itemStatus.equalsIgnoreCase(OLEConstants.ITEM_STATUS_IN_TRANSIT_STAFF);
130                 boolean missingPieceCheck = itemStatus.equalsIgnoreCase(OLEConstants.ITEM_STATUS_RETURNED_MISSING);
131                 boolean returnedDamaged = itemStatus.equalsIgnoreCase(OLEConstants.ITEM_STATUS_RETURNED_DAMAGED);
132                 boolean claimsReturned = oleLoanDocument.isNoticeForClaimsReturned();
133                 ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
134                 populateColorMap();
135                 populateFontMap();
136                 response.setContentType("application/pdf");
137                 OutputStream os = null;
138                 Document document = this.getDocument(0, 0, 5, 5);
139                 if(missingPieceCheck){
140                     os = response.getOutputStream();
141                     PdfWriter.getInstance(document, os);
142                 }
143                 document.open();
144                 document.newPage();
145                 Font boldFont = new Font(Font.TIMES_ROMAN, 15, Font.BOLD);
146                 PdfPTable pdfTable =new PdfPTable(3);
147                 Paragraph paraGraph = new Paragraph();
148                 paraGraph.setAlignment(Element.ALIGN_CENTER);
149                 if(holdSlip){
150                     paraGraph.add(new Chunk("Hold Slip",boldFont));
151                 }else if(inTransitSlip){
152                     paraGraph.add(new Chunk("Routing Slip In-Transit",boldFont));
153                 }else if(inTransitForHold){
154                     paraGraph.add(new Chunk("Routing Slip In-Transit For Hold",boldFont));
155                 }else if(inTransitPerStaff){
156                     paraGraph.add(new Chunk("Routing Slip In-Transit Per Staff Request",boldFont));
157                 }else if(missingPieceCheck){
158                     paraGraph.add(new Chunk("Missing Pieces Notice",boldFont));
159                 }else if (returnedDamaged){
160                     paraGraph.add(new Chunk("Returned Damaged",boldFont));
161                 }else if(claimsReturned){
162                     paraGraph.add(new Chunk("Claims Returned Notice",boldFont));
163                 }else {
164                     paraGraph.add(new Chunk("Receipt(CheckIn) Slip",boldFont));
165                 }
166                 paraGraph.add(Chunk.NEWLINE);
167                 paraGraph.add(Chunk.NEWLINE);
168                 paraGraph.add(Chunk.NEWLINE);
169                 if(holdSlip){
170                     pdfTable.addCell(getPdfPCellInJustified("Patron Name"));
171                     pdfTable.addCell(getPdfPCellInLeft(":"));
172                     pdfTable.addCell(getPdfPCellInJustified(patronName));
173 
174                     pdfTable.addCell(getPdfPCellInJustified("Expiration Date"));
175                     pdfTable.addCell(getPdfPCellInLeft(":"));
176                     pdfTable.addCell(getPdfPCellInJustified(expirationDate.toString()));
177 
178                 } else if(inTransitSlip){
179 
180                     pdfTable.addCell(getPdfPCellInJustified("Route To"));
181                     pdfTable.addCell(getPdfPCellInLeft(":"));
182                     pdfTable.addCell(getPdfPCellInJustified(oleLoanDocument.getItemLocation()));
183 
184                     pdfTable.addCell(getPdfPCellInJustified("Date/Time "));
185                     pdfTable.addCell(getPdfPCellInLeft(":"));
186                     pdfTable.addCell(getPdfPCellInJustified(oleLoanDocument.getCheckInDate().toString()));
187 
188                 } else if(inTransitForHold){
189 
190                     pdfTable.addCell(getPdfPCellInJustified("Route To"));
191                     pdfTable.addCell(getPdfPCellInLeft(":"));
192                     pdfTable.addCell(getPdfPCellInJustified(oleLoanDocument.getItemLocation()));
193 
194                     pdfTable.addCell(getPdfPCellInJustified("Place on hold for"));
195                     pdfTable.addCell(getPdfPCellInLeft(":"));
196                     pdfTable.addCell(getPdfPCellInJustified(requestedBy));
197 
198 
199                     pdfTable.addCell(getPdfPCellInJustified("Date/Time "));
200                     pdfTable.addCell(getPdfPCellInLeft(":"));
201                     pdfTable.addCell(getPdfPCellInJustified(oleLoanDocument.getCheckInDate().toString()));
202 
203                 } else if(inTransitPerStaff){
204 
205                     pdfTable.addCell(getPdfPCellInJustified("Route To"));
206                     pdfTable.addCell(getPdfPCellInLeft(":"));
207                     pdfTable.addCell(getPdfPCellInJustified(oleLoanDocument.getItemLocation()));
208 
209                     pdfTable.addCell(getPdfPCellInJustified("Requested By"));
210                     pdfTable.addCell(getPdfPCellInLeft(":"));
211                     pdfTable.addCell(getPdfPCellInJustified(requestedBy));
212 
213 
214                     pdfTable.addCell(getPdfPCellInJustified("Date/Time "));
215                     pdfTable.addCell(getPdfPCellInLeft(":"));
216                     pdfTable.addCell(getPdfPCellInJustified(oleLoanDocument.getCheckInDate().toString()));
217 
218                 } else if (missingPieceCheck){
219                     document.add(paraGraph);
220                     //Circulation Desk
221                     pdfTable.addCell(getPdfPCellInJustified("Circulation Location / Library Name"));
222                     pdfTable.addCell(getPdfPCellInLeft(":"));
223                     pdfTable.addCell(getPdfPCellInJustified(oleCirculationDesk.getCirculationDeskPublicName()));
224 
225                     pdfTable.addCell(getPdfPCellInJustified("Address"));
226                     pdfTable.addCell(getPdfPCellInLeft(":"));
227                     pdfTable.addCell(getPdfPCellInJustified(oleLocation.getLocationName()));
228 
229                     pdfTable.addCell(getPdfPCellInJustified("Email"));
230                     pdfTable.addCell(getPdfPCellInLeft(":"));
231                     pdfTable.addCell(getPdfPCellInJustified("kuali.ole@org.com"));
232 
233                     pdfTable.addCell(getPdfPCellInJustified("Phone #"));
234                     pdfTable.addCell(getPdfPCellInLeft(":"));
235                     pdfTable.addCell(getPdfPCellInJustified("111-5555"));
236 
237                     document.add(pdfTable);
238                     paraGraph = new Paragraph();
239                     paraGraph.add(Chunk.NEWLINE);
240                     document.add(paraGraph);
241 
242                     //Patron
243                     paraGraph = new Paragraph();
244                     paraGraph.add(new Chunk("Addressee",boldFont));
245                     paraGraph.add(Chunk.NEWLINE);
246                     document.add(paraGraph);
247 
248                     pdfTable =new PdfPTable(3);
249                     pdfTable.addCell(getPdfPCellInJustified("Borrower Name"));
250                     pdfTable.addCell(getPdfPCellInLeft(":"));
251                     pdfTable.addCell(getPdfPCellInJustified(patronName));
252 
253                     pdfTable.addCell(getPdfPCellInJustified("Address"));
254                     pdfTable.addCell(getPdfPCellInLeft(":"));
255                     pdfTable.addCell(getPdfPCellInJustified(""));
256 
257                     pdfTable.addCell(getPdfPCellInJustified("Email"));
258                     pdfTable.addCell(getPdfPCellInLeft(":"));
259                     pdfTable.addCell(getPdfPCellInJustified(olePatronDocument.getEmailAddress()!=null?olePatronDocument.getEmailAddress():""));
260 
261                     pdfTable.addCell(getPdfPCellInJustified("Phone #"));
262                     pdfTable.addCell(getPdfPCellInLeft(":"));
263                     pdfTable.addCell(getPdfPCellInJustified(olePatronDocument.getPhoneNumber()!=null?olePatronDocument.getPhoneNumber():""));
264 
265                     document.add(pdfTable );
266                     //Notice Type
267                     paraGraph = new Paragraph();
268                     paraGraph.add(new Chunk("Return with Missing Piece(s) Notice",boldFont));
269                     paraGraph.setAlignment(Element.ALIGN_CENTER);
270                     paraGraph.add(Chunk.NEWLINE);
271                     document.add(paraGraph);
272 
273 
274                     //Notice-specific text
275                     paraGraph = new Paragraph();
276                     paraGraph.add(new Chunk("The following item(s) returned by you is missing one or more of its pieces.Please return the missing piece(s) to the library shown above or contact the library about this matter to avoid incurring any penalties.",boldFont));
277                     paraGraph.setAlignment(Element.ALIGN_CENTER);
278                     paraGraph.add(Chunk.NEWLINE);
279                     document.add(paraGraph);
280 
281                     //Title/item information
282                     paraGraph = new Paragraph();
283                     paraGraph.add(new Chunk("Title/item information",boldFont));
284                     paraGraph.add(Chunk.NEWLINE);
285                     document.add(paraGraph);
286 
287                     pdfTable =new PdfPTable(3);
288                     pdfTable.addCell(getPdfPCellInJustified("Title"));
289                     pdfTable.addCell(getPdfPCellInLeft(":"));
290                     pdfTable.addCell(getPdfPCellInJustified(itemTitle));
291 
292                     pdfTable.addCell(getPdfPCellInJustified("Author"));
293                     pdfTable.addCell(getPdfPCellInLeft(":"));
294                     pdfTable.addCell(getPdfPCellInJustified(oleLoanDocument.getAuthor()));
295 
296                     pdfTable.addCell(getPdfPCellInJustified("Volume/Issue/Copy #"));
297                     pdfTable.addCell(getPdfPCellInLeft(":"));
298                     pdfTable.addCell(getPdfPCellInJustified(copyNumber));
299 
300                     pdfTable.addCell(getPdfPCellInJustified("Library shelving location "));
301                     pdfTable.addCell(getPdfPCellInLeft(":"));
302                     pdfTable.addCell(getPdfPCellInJustified(oleLocation.getLocationName()));
303 
304                     pdfTable.addCell(getPdfPCellInJustified("Call #"));
305                     pdfTable.addCell(getPdfPCellInLeft(":"));
306                     pdfTable.addCell(getPdfPCellInJustified(itemCallNumber));
307 
308                     pdfTable.addCell(getPdfPCellInJustified("Item barcode"));
309                     pdfTable.addCell(getPdfPCellInLeft(":"));
310                     pdfTable.addCell(getPdfPCellInJustified(itemBarcode));
311                     document.add(pdfTable);
312 
313                 }
314                 if (!missingPieceCheck){
315                     pdfTable.addCell(getPdfPCellInJustified("Circulation Location"));
316                     pdfTable.addCell(getPdfPCellInLeft(":"));
317                     pdfTable.addCell(getPdfPCellInJustified(locationName));
318 
319                     pdfTable.addCell(getPdfPCellInJustified("Item Barcode"));
320                     pdfTable.addCell(getPdfPCellInLeft(":"));
321                     pdfTable.addCell(getPdfPCellInJustified(itemBarcode));
322 
323                     pdfTable.addCell(getPdfPCellInJustified("Title"));
324                     pdfTable.addCell(getPdfPCellInLeft(":"));
325                     pdfTable.addCell(getPdfPCellInJustified(itemTitle));
326 
327                     pdfTable.addCell(getPdfPCellInJustified("Call Number"));
328                     pdfTable.addCell(getPdfPCellInLeft(":"));
329                     pdfTable.addCell(getPdfPCellInJustified(itemCallNumber));
330 
331                     pdfTable.addCell(getPdfPCellInJustified("Copy Number"));
332                     pdfTable.addCell(getPdfPCellInLeft(":"));
333                     pdfTable.addCell(getPdfPCellInJustified(copyNumber));
334                     if(!(holdSlip | inTransitSlip | inTransitForHold | inTransitPerStaff)){
335                         pdfTable.addCell(getPdfPCellInJustified("Check-in Date"));
336                         pdfTable.addCell(getPdfPCellInLeft(":"));
337                         pdfTable.addCell(getPdfPCellInJustified(oleLoanDocument.getCheckInDate().toString()));
338 
339                         pdfTable.addCell(getPdfPCellInJustified("Patron Barcode"));
340                         pdfTable.addCell(getPdfPCellInLeft(":"));
341                         pdfTable.addCell(getPdfPCellInJustified(olePatronDocument.getBarcode()));
342                     }
343                 }
344                 response.setContentType("application/pdf");
345                 if (!missingPieceCheck){
346                     os =response.getOutputStream();
347                     PdfWriter.getInstance(document, os);
348                     document.open();
349                     document.add(paraGraph);
350                     document.add(pdfTable);
351                     document.close();
352                 }  else {
353                     document.close();
354                 }
355                 byteArrayOutputStream.flush();
356                 byteArrayOutputStream.close();
357                 os.flush();
358                 os.close();
359             } catch (Exception e) {
360                 e.printStackTrace();
361             }
362         }
363     }
364 
365 
366     public void createDueDateSlipPdf(List<OleLoanDocument> oleLoanDocument, HttpServletResponse response) {
367         ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
368 
369         try {
370             populateColorMap();
371             populateFontMap();
372             SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yy");
373             String date = simpleDateFormat.format(System.currentTimeMillis());
374             response.setContentType("application/pdf");
375             Document document = this.getDocument(0, 0, 5, 5);
376             PdfWriter writer = PdfWriter.getInstance(document, byteArrayOutputStream);
377             document.open();
378             document.newPage();
379             Font boldFont = new Font(Font.TIMES_ROMAN, 15, Font.BOLD);
380             PdfPTable pdfTable =new PdfPTable(3);
381             Paragraph paraGraph = new Paragraph();
382             paraGraph.setAlignment(Element.ALIGN_CENTER);
383             paraGraph.add(new Chunk("Due Date Slip",boldFont));
384             paraGraph.add(Chunk.NEWLINE);
385             paraGraph.add(Chunk.NEWLINE);
386             paraGraph.add(Chunk.NEWLINE);
387             LoanProcessor loanProcessor = new LoanProcessor();
388             OleLocation oleLocation=null;
389             try {
390                 OleCirculationDesk oleCirculationDesk = null;
391                 if(oleLoanDocument.get(0).getCirculationLocationId() != null){
392                    oleCirculationDesk = loanProcessor.getOleCirculationDesk(oleLoanDocument.get(0).getCirculationLocationId());
393                 }
394                 oleLocation = oleCirculationDesk.getOleCirculationDeskLocations().get(0).getLocation();
395                // oleLocation = loanProcessor.getLocationByLocationId(oleLoanDocument.get(0).getCirculationLocationId());
396             } catch (Exception e) {
397                 e.printStackTrace();
398             }
399             String locationName = oleLocation!=null?oleLocation.getLocationName():null;
400 
401 
402             for(int dueDateSlip=0;dueDateSlip<oleLoanDocument.size();dueDateSlip++){
403 
404                 pdfTable.addCell(getPdfPCellInJustified("Circulation Location/Library Name"));
405                 pdfTable.addCell(getPdfPCellInLeft(":"));
406                 pdfTable.addCell(getPdfPCellInJustified(locationName));
407 
408                 pdfTable.addCell(getPdfPCellInJustified("Item Barcode"));
409                 pdfTable.addCell(getPdfPCellInLeft(":"));
410                 pdfTable.addCell(getPdfPCellInJustified(oleLoanDocument.get(dueDateSlip).getItemId()));
411 
412                 pdfTable.addCell(getPdfPCellInJustified("Title"));
413                 pdfTable.addCell(getPdfPCellInLeft(":"));
414                 pdfTable.addCell(getPdfPCellInJustified(oleLoanDocument.get(dueDateSlip).getTitle()));
415 
416                 pdfTable.addCell(getPdfPCellInJustified("Call Number"));
417                 pdfTable.addCell(getPdfPCellInLeft(":"));
418                 pdfTable.addCell(getPdfPCellInJustified(oleLoanDocument.get(dueDateSlip).getItemCallNumber()));
419 
420                 pdfTable.addCell(getPdfPCellInJustified("Copy Number"));
421                 pdfTable.addCell(getPdfPCellInLeft(":"));
422                 pdfTable.addCell(getPdfPCellInJustified(oleLoanDocument.get(dueDateSlip).getItemCopyNumber()));
423 
424                 pdfTable.addCell(getPdfPCellInJustified("Due Date"));
425                 pdfTable.addCell(getPdfPCellInLeft(":"));
426                 pdfTable.addCell(getPdfPCellInJustified(oleLoanDocument.get(dueDateSlip).getLoanDueDate().toString()));
427 
428                 pdfTable.addCell(getPdfPCellInJustified("Patron Barcode"));
429                 pdfTable.addCell(getPdfPCellInLeft(":"));
430                 pdfTable.addCell(getPdfPCellInJustified(oleLoanDocument.get(dueDateSlip).getPatronBarcode()));
431 
432 
433 
434                 /*paraGraph.add(Chunk.NEWLINE);
435                 paraGraph.add(Chunk.NEWLINE);
436 */
437                 pdfTable.addCell(getEmptyCell());
438                 pdfTable.addCell(getEmptyCell());
439                 pdfTable.addCell(getEmptyCell());
440 
441                 pdfTable.addCell(getEmptyCell());
442                 pdfTable.addCell(getEmptyCell());
443                 pdfTable.addCell(getEmptyCell());
444             }
445             response.setContentType("application/pdf");
446             ServletOutputStream sos = response.getOutputStream();
447             PdfWriter.getInstance(document, sos);
448             document.open();
449             document.add(paraGraph);
450             document.add(pdfTable);
451             document.close();
452             String fileName = "Due date slip_"+date;
453             ///OutputStream outputStream = new FileOutputStream(""+fileName+".pdf");
454             // byteArrayOutputStream.writeTo(outputStream);
455             byteArrayOutputStream.flush();
456             byteArrayOutputStream.close();
457             sos.flush();
458             sos.close();
459             // outputStream.close();
460         } catch (Exception e) {
461             e.printStackTrace();
462         }
463     }
464 
465     private PdfPCell getEmptyCell(){
466         PdfPCell pdfPCell = new PdfPCell(new Paragraph(Chunk.NEWLINE));
467         pdfPCell.setBorder(pdfPCell.NO_BORDER);
468         pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
469         return pdfPCell;
470     }
471 
472     private PdfPCell getPdfPCellInJustified(String chunk){
473         PdfPCell pdfPCell = new PdfPCell(new Paragraph(new Chunk(chunk)));
474         pdfPCell.setBorder(pdfPCell.NO_BORDER);
475         pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
476         return pdfPCell;
477     }
478     private PdfPCell getPdfPCellInLeft(String chunk){
479         PdfPCell pdfPCell = new PdfPCell(new Paragraph(new Chunk(chunk)));
480         pdfPCell.setBorder(pdfPCell.NO_BORDER);
481         pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
482         return pdfPCell;
483     }
484     public Document getDocument(float f1, float f2, float f3, float f4) {
485         Document document = new Document(PageSize.A4);
486         document.setMargins(f1, f2, f3, f4);
487         return document;
488     }
489 }
490 
491