View Javadoc
1   package org.kuali.ole.deliver.batch;
2   
3   
4   import com.itextpdf.text.*;
5   import com.itextpdf.text.Font;
6   import com.itextpdf.text.pdf.BaseFont;
7   import com.itextpdf.text.pdf.PdfPCell;
8   import com.itextpdf.text.pdf.PdfPTable;
9   import com.itextpdf.text.pdf.PdfWriter;
10  import org.apache.log4j.Logger;
11  import org.kuali.ole.OLEConstants;
12  import org.kuali.ole.deliver.bo.OleCirculationDeskDetail;
13  import org.kuali.ole.deliver.bo.OleDeliverRequestBo;
14  import org.kuali.ole.deliver.processor.LoanProcessor;
15  import org.kuali.rice.core.api.config.property.ConfigContext;
16  import org.kuali.rice.krad.service.KRADServiceLocator;
17  import org.springframework.core.io.ClassPathResource;
18  import org.springframework.core.io.Resource;
19  
20  import javax.servlet.http.HttpServletResponse;
21  import java.io.ByteArrayOutputStream;
22  import java.io.FileOutputStream;
23  import java.io.OutputStream;
24  import java.util.HashMap;
25  import java.util.Map;
26  
27  /**
28   * Created with IntelliJ IDEA.
29   * User: ?
30   * Date: 11/23/12
31   * Time: 5:24 PM
32   * To change this template use File | Settings | File Templates.
33   */
34  public class OleDeliverNoticeService {
35      private LoanProcessor loanProcessor = new LoanProcessor();
36      private static final Logger LOG = Logger.getLogger(OleShelvingLagTime.class);
37  
38      public LoanProcessor getLoanProcessor() {
39          return loanProcessor;
40      }
41  
42      public void setLoanProcessor(LoanProcessor loanProcessor) {
43          this.loanProcessor = loanProcessor;
44      }
45  
46  
47      public Font getArialFont(){
48          com.itextpdf.text.Font font = FontFactory.getFont(getFontFilePath("org/kuali/ole/deliver/batch/fonts/arial.ttf"), BaseFont.IDENTITY_H,10);
49          return font;
50      }
51  
52      public String getFontFilePath(String classpathRelativePath)  {
53          try {
54              Resource rsrc = new ClassPathResource(classpathRelativePath);
55              return rsrc.getFile().getAbsolutePath();
56          } catch(Exception e){
57              LOG.error("Error : while accessing font file "+e);
58          }
59          return null;
60      }
61  
62      public Font getBoldFont(){
63          return FontFactory.getFont(FontFactory.TIMES_ROMAN, 15, Font.BOLD);
64      }
65  
66  
67      private PdfPCell getPdfPCellInCenter(String chunk) {
68          PdfPCell pdfPCell = new PdfPCell(new Paragraph(new Chunk(chunk,getArialFont())));
69          pdfPCell.setBorder(pdfPCell.NO_BORDER);
70          pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
71          return pdfPCell;
72      }
73  
74      private PdfPCell getPdfPCellInCenter(String chunk,Font font) {
75          PdfPCell pdfPCell = new PdfPCell(new Paragraph(new Chunk(chunk,font)));
76          pdfPCell.setBorder(pdfPCell.NO_BORDER);
77          pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
78          return pdfPCell;
79      }
80  
81      private PdfPCell getPdfPCellNewLine() {
82          PdfPCell pdfPCell = new PdfPCell(new Paragraph(Chunk.NEWLINE));
83          pdfPCell.setBorder(pdfPCell.NO_BORDER);
84          return pdfPCell;
85      }
86  
87      private Paragraph getPdfParagraphNewLine() {
88          Paragraph paragraph = new Paragraph(new Paragraph(Chunk.NEWLINE));
89          return paragraph;
90      }
91  
92      public boolean createPdf(OleNoticeBo noticeBo) {
93          boolean result = false;
94          String directory = getLoanProcessor().getParameter("PDF_LOCATION");
95          OutputStream outputStream = null;
96          String fileName = noticeBo.getNoticeName() + "/" + noticeBo.getItemId();
97          try {
98              Document document = new Document(PageSize.A4);
99              outputStream = new FileOutputStream(directory + "/" + fileName + ".pdf");
100             PdfWriter writer = PdfWriter.getInstance(document, outputStream);
101             Font boldFont = FontFactory.getFont("Times-Roman", 15, Font.BOLD);
102             document.open();
103             document.newPage();
104 
105             //document.setHeader(new HeaderFooter(new Phrase(fileName), new Phrase("Footer")));
106 
107             //Circulation Desk
108             Paragraph paraGraph = new Paragraph();
109             paraGraph.add(new Chunk(noticeBo.getNoticeName(), boldFont));
110             paraGraph.add(Chunk.NEWLINE);
111             document.add(paraGraph);
112             PdfPTable pdfTable = new PdfPTable(3);
113             PdfPCell pdfPCell = new PdfPCell(new Paragraph("Circulation Location / Library Name"));
114             pdfPCell.setBorder(pdfPCell.NO_BORDER);
115             pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
116             pdfTable.addCell(pdfPCell);
117             pdfPCell = new PdfPCell(new Paragraph(":"));
118             pdfPCell.setBorder(pdfPCell.NO_BORDER);
119             pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
120             pdfTable.addCell(pdfPCell);
121             pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getCirculationDeskName())));
122             pdfPCell.setBorder(pdfPCell.NO_BORDER);
123             pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
124             pdfTable.addCell(pdfPCell);
125             pdfPCell = new PdfPCell(new Paragraph(new Chunk("Address")));
126             pdfPCell.setBorder(pdfPCell.NO_BORDER);
127             pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
128             pdfTable.addCell(pdfPCell);
129             pdfPCell = new PdfPCell(new Paragraph(":"));
130             pdfPCell.setBorder(pdfPCell.NO_BORDER);
131             pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
132             pdfTable.addCell(pdfPCell);
133             pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getCirculationDeskAddress())));
134             pdfPCell.setBorder(pdfPCell.NO_BORDER);
135             pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
136             pdfTable.addCell(pdfPCell);
137             pdfPCell = new PdfPCell(new Paragraph(new Chunk("Email")));
138             pdfPCell.setBorder(pdfPCell.NO_BORDER);
139             pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
140             pdfTable.addCell(pdfPCell);
141             pdfPCell = new PdfPCell(new Paragraph(":"));
142             pdfPCell.setBorder(pdfPCell.NO_BORDER);
143             pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
144             pdfTable.addCell(pdfPCell);
145             pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getCirculationDeskEmailAddress())));
146             pdfPCell.setBorder(pdfPCell.NO_BORDER);
147             pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
148             pdfTable.addCell(pdfPCell);
149             pdfPCell = new PdfPCell(new Paragraph(new Chunk("Phone #")));
150             pdfPCell.setBorder(pdfPCell.NO_BORDER);
151             pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
152             pdfTable.addCell(pdfPCell);
153             pdfPCell = new PdfPCell(new Paragraph(":"));
154             pdfPCell.setBorder(pdfPCell.NO_BORDER);
155             pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
156             pdfTable.addCell(pdfPCell);
157             pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getCirculationDeskPhoneNumber())));
158             pdfPCell.setBorder(pdfPCell.NO_BORDER);
159             pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
160             pdfTable.addCell(pdfPCell);
161             document.add(pdfTable);
162             paraGraph = new Paragraph();
163             paraGraph.add(Chunk.NEWLINE);
164             document.add(paraGraph);
165 
166             //Patron
167             paraGraph = new Paragraph();
168             paraGraph.add(new Chunk("Addressee", boldFont));
169             paraGraph.add(Chunk.NEWLINE);
170             document.add(paraGraph);
171             pdfTable = new PdfPTable(3);
172 
173             pdfTable.addCell(getPdfPCellInJustified("Borrower Name"));
174             pdfTable.addCell(getPdfPCellInLeft(":"));
175             pdfTable.addCell(getPdfPCellInJustified(noticeBo.getPatronName() != null ? noticeBo.getPatronName() : ""));
176 
177             pdfTable.addCell(getPdfPCellInJustified("Address"));
178             pdfTable.addCell(getPdfPCellInLeft(":"));
179             pdfTable.addCell(getPdfPCellInJustified((noticeBo.getPatronAddress() != null ? noticeBo.getPatronAddress() : "")));
180 
181             pdfTable.addCell(getPdfPCellInJustified("Email"));
182             pdfTable.addCell(getPdfPCellInLeft(":"));
183             pdfTable.addCell(getPdfPCellInJustified((noticeBo.getPatronEmailAddress() != null ? noticeBo.getPatronEmailAddress() : "")));
184 
185             pdfTable.addCell(getPdfPCellInJustified("Phone #"));
186             pdfTable.addCell(getPdfPCellInLeft(":"));
187             pdfTable.addCell(getPdfPCellInJustified((noticeBo.getPatronPhoneNumber() != null ? noticeBo.getPatronPhoneNumber() : "")));
188 
189             document.add(pdfTable);
190             paraGraph = new Paragraph();
191             paraGraph.add(Chunk.NEWLINE);
192             document.add(paraGraph);
193 
194             //Notice Type
195             paraGraph = new Paragraph();
196             paraGraph.add(new Chunk(noticeBo.getNoticeName(), boldFont));
197             paraGraph.setAlignment(Element.ALIGN_CENTER);
198             paraGraph.add(Chunk.NEWLINE);
199             document.add(paraGraph);
200 
201 
202             //Notice-specific text
203             paraGraph = new Paragraph();
204             paraGraph.add(new Chunk(noticeBo.getNoticeSpecificContent(), boldFont));
205             paraGraph.setAlignment(Element.ALIGN_CENTER);
206             paraGraph.add(Chunk.NEWLINE);
207             document.add(paraGraph);
208             //Title/item information
209             paraGraph = new Paragraph();
210             paraGraph.add(new Chunk("Title/item information", boldFont));
211             paraGraph.add(Chunk.NEWLINE);
212             document.add(paraGraph);
213             pdfTable = new PdfPTable(3);
214 
215 
216             pdfTable.addCell(getPdfPCellInJustified("Title"));
217             pdfTable.addCell(getPdfPCellInLeft(":"));
218             pdfTable.addCell(getPdfPCellInJustified((noticeBo.getTitle() == null ? "" : noticeBo.getTitle())));
219 
220             pdfTable.addCell(getPdfPCellInJustified("Author"));
221             pdfTable.addCell(getPdfPCellInLeft(":"));
222             pdfTable.addCell(getPdfPCellInJustified((noticeBo.getAuthor() == null ? "" : noticeBo.getAuthor())));
223 
224 
225             pdfTable.addCell(getPdfPCellInJustified("Volume/Issue/Copy # "));
226             pdfTable.addCell(getPdfPCellInLeft(":"));
227             if(!noticeBo.getNoticeName().equalsIgnoreCase(OLEConstants.NOTICE_RECALL)){
228                 pdfTable.addCell(getPdfPCellInJustified(noticeBo.getVolumeNumber() == null ? "" : noticeBo.getVolumeNumber()));
229             }else{
230                 pdfTable.addCell(getPdfPCellInJustified((noticeBo.getVolumeIssueCopyNumber() == null ? "" : noticeBo.getVolumeIssueCopyNumber())));
231             }
232 
233 
234             pdfTable.addCell(getPdfPCellInJustified("Library shelving location "));
235             pdfTable.addCell(getPdfPCellInLeft(":"));
236             pdfTable.addCell(getPdfPCellInJustified((noticeBo.getItemShelvingLocation() == null ? "" : noticeBo.getItemShelvingLocation())));
237 
238 
239             pdfTable.addCell(getPdfPCellInJustified("Call #"));
240             pdfTable.addCell(getPdfPCellInLeft(":"));
241             pdfTable.addCell(getPdfPCellInJustified((noticeBo.getItemCallNumber() == null ? "" : noticeBo.getItemCallNumber())));
242 
243 
244             pdfTable.addCell(getPdfPCellInJustified("Item barcode"));
245             pdfTable.addCell(getPdfPCellInLeft(":"));
246             pdfTable.addCell(getPdfPCellInJustified((noticeBo.getItemId() == null ? "" : noticeBo.getItemId())));
247 
248             document.add(pdfTable);
249             paraGraph = new Paragraph();
250             paraGraph.add(Chunk.NEWLINE);
251             document.add(paraGraph);
252 
253             //Information specific text
254   /*          paraGraph = new Paragraph();
255             paraGraph.add(new Chunk("Information specific text",boldFont));
256             paraGraph.add(Chunk.NEWLINE);
257             document.add(paraGraph);*/
258             if (noticeBo.getNoticeName().equals("Recall")) {
259                 pdfTable = new PdfPTable(3);
260                 pdfPCell = new PdfPCell(new Paragraph("Original Due Date"));
261                 pdfPCell.setBorder(pdfPCell.NO_BORDER);
262                 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
263                 pdfTable.addCell(pdfPCell);
264                 pdfPCell = new PdfPCell(new Paragraph(":"));
265                 pdfPCell.setBorder(pdfPCell.NO_BORDER);
266                 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
267                 pdfTable.addCell(pdfPCell);
268                 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getOriginalDueDate() == null ? "" : noticeBo.getOriginalDueDate().toString())));
269                 pdfPCell.setBorder(pdfPCell.NO_BORDER);
270                 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
271                 pdfTable.addCell(pdfPCell);
272                 pdfPCell = new PdfPCell(new Paragraph(new Chunk("New Due Date")));
273                 pdfPCell.setBorder(pdfPCell.NO_BORDER);
274                 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
275                 pdfTable.addCell(pdfPCell);
276                 pdfPCell = new PdfPCell(new Paragraph(":"));
277                 pdfPCell.setBorder(pdfPCell.NO_BORDER);
278                 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
279                 pdfTable.addCell(pdfPCell);
280                 pdfPCell = new PdfPCell(new Paragraph(new Chunk(noticeBo.getNewDueDate() == null ? "" : noticeBo.getNewDueDate().toString())));
281                 pdfPCell.setBorder(pdfPCell.NO_BORDER);
282                 pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
283                 pdfTable.addCell(pdfPCell);
284                 document.add(pdfTable);
285                 paraGraph = new Paragraph();
286                 paraGraph.add(Chunk.NEWLINE);
287                 document.add(paraGraph);
288             } else if (noticeBo.getNoticeName().equals("OnHold")) {
289                 pdfTable = new PdfPTable(3);
290 
291                 pdfTable.addCell(getPdfPCellInJustified("Pick Up Location"));
292                 pdfTable.addCell(getPdfPCellInLeft(":"));
293                 pdfTable.addCell(getPdfPCellInJustified((noticeBo.getPickUpLocation() != null ? noticeBo.getPickUpLocation() : "")));
294 
295                 pdfTable.addCell(getPdfPCellInJustified("Circulation Location / Library Name"));
296                 pdfTable.addCell(getPdfPCellInLeft(":"));
297                 pdfTable.addCell(getPdfPCellInJustified((noticeBo.getCirculationDeskName() != null ? noticeBo.getCirculationDeskName() : "")));
298 
299 
300                 pdfTable.addCell(getPdfPCellInJustified("Address"));
301                 pdfTable.addCell(getPdfPCellInLeft(":"));
302                 pdfTable.addCell(getPdfPCellInJustified((noticeBo.getCirculationDeskAddress() != null ? noticeBo.getCirculationDeskAddress() : "")));
303 
304                 pdfTable.addCell(getPdfPCellInJustified("Email"));
305                 pdfTable.addCell(getPdfPCellInLeft(":"));
306                 pdfTable.addCell(getPdfPCellInJustified((noticeBo.getCirculationDeskEmailAddress() != null ? noticeBo.getCirculationDeskEmailAddress() : "")));
307 
308                 pdfTable.addCell(getPdfPCellInJustified("Phone #"));
309                 pdfTable.addCell(getPdfPCellInLeft(":"));
310                 pdfTable.addCell(getPdfPCellInJustified((noticeBo.getCirculationDeskPhoneNumber() != null ? noticeBo.getCirculationDeskPhoneNumber() : "")));
311 
312                 document.add(pdfTable);
313                 paraGraph = new Paragraph();
314                 paraGraph.add(Chunk.NEWLINE);
315                 document.add(paraGraph);
316 
317                 pdfTable.addCell(getPdfPCellInJustified("Item Will Be Held until"));
318                 pdfTable.addCell(getPdfPCellInLeft(":"));
319                 pdfTable.addCell(getPdfPCellInJustified((noticeBo.getOnHoldDueDate() != null ? noticeBo.getOnHoldDueDate().toString() : "")));
320 
321                 document.add(pdfTable);
322                 paraGraph = new Paragraph();
323                 paraGraph.add(Chunk.NEWLINE);
324                 document.add(paraGraph);
325             } else if (noticeBo.getNoticeName().equals("OverdueNotice")) {
326                 pdfTable = new PdfPTable(3);
327 
328                 pdfTable.addCell(getPdfPCellInJustified("Item was due"));
329                 pdfTable.addCell(getPdfPCellInLeft(":"));
330                 pdfTable.addCell(getPdfPCellInJustified((noticeBo.getDueDate() != null ? noticeBo.getDueDate().toString() : "")));
331 
332                 document.add(pdfTable);
333                 document.add(getPdfParagraphNewLine());
334             }
335 
336             //My Account
337             /*    PdfContentByte cb = writer.getDirectContent();
338          cb.setLineWidth(1);
339          cb.moveTo(0, 245);
340          cb.lineTo(0 + document.getPageSize().width(), 245);
341          cb.stroke();
342          cb = writer.getDirectContent();
343          cb.setLineWidth(1);
344          cb.moveTo(0, 222);
345          cb.lineTo(0 + document.getPageSize().width(), 222);
346          cb.stroke();
347          paraGraph = new Paragraph();*/
348             /*paraGraph.add(new Chunk("My Account",boldFont));
349             paraGraph.add(Chunk.NEWLINE);*/
350             String url = ConfigContext.getCurrentContextConfig().getProperty("ole.fs.url.base");
351             //String myAccountURL = loanProcessor.getParameter(OLEConstants.MY_ACCOUNT_URL);
352             String myAccountURL = url+OLEConstants.OLE_MY_ACCOUNT_URL_CHANNEL+url+OLEConstants.OLE_MY_ACCOUNT_URL;
353             if (myAccountURL != null && !myAccountURL.trim().isEmpty()) {
354                 Font ver_15_normal = FontFactory.getFont("Times-Roman", 15, Font.BOLD,BaseColor.BLUE);
355                 ver_15_normal.setColor(BaseColor.BLUE);
356                 ver_15_normal.setStyle(Font.UNDERLINE);
357                 Anchor anchor = new Anchor("MyAccount", ver_15_normal);
358                 anchor.setName("My Account");
359                 anchor.setReference(myAccountURL);
360                 Paragraph newParaGraph = new Paragraph();
361                 newParaGraph.add(anchor);
362                 newParaGraph.setFont(ver_15_normal);
363                 newParaGraph.setAlignment(Element.ALIGN_CENTER);
364                 document.add(newParaGraph);
365             }
366             outputStream.flush();
367             document.close();
368             outputStream.close();
369             result = true;
370         } catch (Exception ex) {
371             LOG.error("Exception while creating pdf", ex);
372         }
373         return result;
374     }
375 
376     public void createSlip(OleDeliverRequestBo oleDeliverRequestBo, HttpServletResponse response) {
377         ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
378         OutputStream outputStream = null;
379         String directory = getLoanProcessor().getParameter("PDF_LOCATION");
380 
381         String fileName = "In Transit Routing slip" + oleDeliverRequestBo.getItemId();
382 
383         Document document = new Document(PageSize.A4);
384         try {
385             response.setContentType("application/pdf");
386             outputStream = new FileOutputStream(directory + "/" + fileName + ".pdf");
387             PdfWriter writer = PdfWriter.getInstance(document, outputStream);
388             Font boldFont = FontFactory.getFont("Times-Roman", 15, Font.BOLD);
389             Font ver_15_normal = FontFactory.getFont("VERDANA", 15, 0);
390             document.open();
391             document.newPage();
392             PdfPTable pdfTable = new PdfPTable(3);
393             Paragraph paraGraph = new Paragraph();
394             paraGraph.setAlignment(Element.ALIGN_CENTER);
395             paraGraph.add(new Chunk("Routing Slip In-Transit Per Staff Request", boldFont));
396             paraGraph.add(Chunk.NEWLINE);
397             paraGraph.add(Chunk.NEWLINE);
398             paraGraph.add(Chunk.NEWLINE);
399             pdfTable.addCell(getPdfPCellInJustified("Route To"));
400             pdfTable.addCell(getPdfPCellInLeft(":"));
401             pdfTable.addCell(getPdfPCellInJustified(oleDeliverRequestBo.getCirculationLocationId()));
402 
403             pdfTable.addCell(getPdfPCellInJustified("Requested By"));
404             pdfTable.addCell(getPdfPCellInLeft(":"));
405             pdfTable.addCell(getPdfPCellInJustified(oleDeliverRequestBo.getBorrowerId()));
406 
407 
408             pdfTable.addCell(getPdfPCellInJustified("Date/Time "));
409             pdfTable.addCell(getPdfPCellInLeft(":"));
410             pdfTable.addCell(getPdfPCellInJustified(oleDeliverRequestBo.getCreateDate().toString()));
411 
412             Map<String, String> operatorMap = new HashMap<String, String>();
413             operatorMap.put("operatorId", oleDeliverRequestBo.getOperatorCreateId());
414             operatorMap.put("defaultLocation", "true");
415             java.util.List<OleCirculationDeskDetail> circulationDeskDetailList = (java.util.List<OleCirculationDeskDetail>) KRADServiceLocator.getBusinessObjectService().findMatching(OleCirculationDeskDetail.class, operatorMap);
416             String locationName = "";
417             if (circulationDeskDetailList.size() > 0) {
418                 locationName = circulationDeskDetailList.get(0).getOleCirculationDesk().getOleCirculationDeskLocations().get(0).getCirculationDeskLocation();
419             }
420 
421 
422             pdfTable.addCell(getPdfPCellInJustified("Circulation Location"));
423             pdfTable.addCell(getPdfPCellInLeft(":"));
424             pdfTable.addCell(getPdfPCellInJustified(locationName));
425 
426 
427             pdfTable.addCell(getPdfPCellInJustified("Item Barcode"));
428             pdfTable.addCell(getPdfPCellInLeft(":"));
429             pdfTable.addCell(getPdfPCellInJustified(oleDeliverRequestBo.getItemId()));
430 
431             pdfTable.addCell(getPdfPCellInJustified("Title"));
432             pdfTable.addCell(getPdfPCellInLeft(":"));
433             pdfTable.addCell(getPdfPCellInJustified(oleDeliverRequestBo.getTitle()));
434 
435             pdfTable.addCell(getPdfPCellInJustified("Call Number"));
436             pdfTable.addCell(getPdfPCellInLeft(":"));
437             pdfTable.addCell(getPdfPCellInJustified(oleDeliverRequestBo.getCallNumber()));
438 
439             pdfTable.addCell(getPdfPCellInJustified("Copy Number"));
440             pdfTable.addCell(getPdfPCellInLeft(":"));
441             pdfTable.addCell(getPdfPCellInJustified(oleDeliverRequestBo.getCopyNumber()));
442 
443 
444             response.setContentType("application/pdf");
445             OutputStream os = response.getOutputStream();
446             PdfWriter.getInstance(document, os);
447             document.open();
448             document.add(paraGraph);
449             document.add(pdfTable);
450             document.close();
451             byteArrayOutputStream.flush();
452             byteArrayOutputStream.close();
453             os.flush();
454             os.close();
455         } catch (Exception e) {
456             LOG.error("Exception while creating slip", e);
457         }
458     }
459 
460     private PdfPCell getPdfPCellInJustified(String chunk) {
461         PdfPCell pdfPCell = new PdfPCell(new Paragraph(new Chunk(chunk)));
462         pdfPCell.setBorder(pdfPCell.NO_BORDER);
463         pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_JUSTIFIED);
464         return pdfPCell;
465     }
466 
467     private PdfPCell getPdfPCellInLeft(String chunk) {
468         PdfPCell pdfPCell = new PdfPCell(new Paragraph(new Chunk(chunk)));
469         pdfPCell.setBorder(pdfPCell.NO_BORDER);
470         pdfPCell.setHorizontalAlignment(pdfPCell.ALIGN_LEFT);
471         return pdfPCell;
472     }
473 
474 
475 }