List of usage examples for com.itextpdf.text Paragraph setFont
public void setFont(final Font font)
From source file:com.photon.phresco.service.docs.impl.DocumentUtil.java
License:Apache License
private static void updateDoc(List<ModuleGroup> modules, com.itextpdf.text.Document docu, PdfWriter writer, String moduleName) throws DocumentException, PhrescoException, IOException { Paragraph para = new Paragraph(); para.setAlignment(Element.ALIGN_CENTER); para.setFont(DocConstants.BODY_FONT); para.setFont(DocConstants.CATEGORY_FONT); para.add(moduleName);//from w ww .j av a 2 s . c o m addBlankLines(para, 2); docu.add(para); for (ModuleGroup tupleBean : modules) { para = new Paragraph(); para.setFont(DocConstants.CATEGORY_FONT); para.add(tupleBean.getName()); docu.add(para); Documentation document = tupleBean.getDoc(DocumentationType.DESCRIPTION); if (document != null) { if (!StringUtils.isEmpty(document.getUrl())) { PdfInput convertToPdf = DocConvertor.convertToPdf(document.getUrl()); if (convertToPdf != null) { DocumentUtil.addPages(convertToPdf.getInputStream(), writer, docu); } } else { para = new Paragraph(); para.setFont(DocConstants.BODY_FONT); para.add(document.getContent()); addBlankLines(para, 2); docu.add(para); } } } }
From source file:com.planning.project.controller.CreatePDF.java
public static Document createPDFActivity(String file, Long activityId) throws Exception { Document document = null;// w ww .j a va 2s . c om try { document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(file)); document.open(); addMetaData(document); addTitlePageProject(document); Paragraph created = new Paragraph(); created.setFont(TIME_ROMAN_SMALL); created.add(activityId.toString()); created.setAlignment(Element.ALIGN_RIGHT); document.add(created); document.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } return document; }
From source file:com.planning.project.controller.CreatePDF.java
private static void addTitlePage(Document document) throws DocumentException, IOException { Font font = new Font(BaseFont.createFont("D:/THSarabunNew.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)); font.setSize(24);/*from w w w.j av a 2s.co m*/ String imagepath = "src/main/webapp/resources/images/curt.gif"; Image img = Image.getInstance(imagepath); img.scaleToFit(70f, 70f); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM/dd/yyyy"); Paragraph created = new Paragraph(); created.setFont(TIME_ROMAN_SMALL); created.add("Report created on " + simpleDateFormat.format(new Date())); created.setAlignment(Element.ALIGN_RIGHT); Paragraph logo = new Paragraph(); logo.setFont(TIME_ROMAN_SMALL); logo.add(img); logo.setAlignment(Element.ALIGN_LEFT); document.add(created); document.add(logo); // Paragraph created = new Paragraph(); // created.setFont(TIME_ROMAN_SMALL); // created.add("Report created on " + simpleDateFormat.format(new // Date())); // created.setAlignment(Element.ALIGN_RIGHT); Paragraph paragraph = new Paragraph(); paragraph.setFont(font); paragraph.add("FormProject "); paragraph.setAlignment(Element.ALIGN_CENTER); document.add(paragraph); creteEmptyLine(created, 1); }
From source file:com.planning.project.controller.CreatePDF.java
private static void createTable(Document document) throws DocumentException, IOException { Font font = new Font(BaseFont.createFont("D:/THSarabunNew.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)); font.setSize(16);/*from www. jav a2 s . co m*/ Paragraph paragraph = new Paragraph(); paragraph.setFont(font); creteEmptyLine(paragraph, 2); document.add(paragraph); PdfPTable table = new PdfPTable(7); paragraph.add(""); PdfPCell c1 = new PdfPCell(new Phrase("asasas", font)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("/?", font)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("?", font)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); TbActivity ac = new TbActivity(); c1 = new PdfPCell(new Phrase("", font)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("", font)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("", font)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("", font)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); table.setHeaderRows(1); paragraph.add(""); for (int i = 0; i < 7; i++) { table.setWidthPercentage(100); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(paragraph); } document.add(table); }
From source file:com.planning.project.controller.CreatePDF.java
private static void createPagePDFFormProject(Document document, TbFormProject tbFormProject, List<TbActivity> activity, List<TbDetailSka> detailSka, List<TbDetailSm> detailSms, TbFormSubproject subProject) throws DocumentException, IOException { Font font = new Font(BaseFont.createFont("D:/THSarabunNew.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)); font.setSize(16);/* www .j a v a2s .com*/ int acNo = 0; Paragraph openning = new Paragraph(); Paragraph ska = new Paragraph(); Paragraph sms = new Paragraph(); Paragraph notice = new Paragraph(); Paragraph address = new Paragraph(); Paragraph readyTodo = new Paragraph(); readyTodo.setFont(font); address.setFont(font); ska.setFont(font); sms.setFont(font); notice.setFont(font); openning.setFont(font); openning.add(" : " + tbFormProject.getTbFaculty().getFacultyName()); creteEmptyLine(openning, 1); openning.add("?" + tbFormProject.getTbStrBud().getStrBudName()); creteEmptyLine(openning, 1); openning.add("? : " + tbFormProject.getTbPlan().getPlansName()); creteEmptyLine(openning, 1); openning.add("? : " + tbFormProject.getTbStrMin().getStrMinName()); creteEmptyLine(openning, 1); openning.add("? : " + tbFormProject.getTbMisUni().getMisUniName()); creteEmptyLine(openning, 1); openning.add(" : " + tbFormProject.getTbSubUni().getSubUniName()); creteEmptyLine(openning, 1); openning.add("? : " + tbFormProject.getTbProduct().getProductName()); creteEmptyLine(openning, 1); openning.add( "? : " + tbFormProject.getTbProjectname().getProjectnameName()); creteEmptyLine(openning, 1); openning.add("? : " + tbFormProject.getTbPerson().getPersonName() + " " + tbFormProject.getTbPerson().getPersonLastname()); creteEmptyLine(openning, 1); openning.add(" : " + tbFormProject.getTotal()); creteEmptyLine(openning, 1); openning.add("? : " + tbFormProject.getAllocateMoney()); creteEmptyLine(openning, 1); openning.add(" : " + (Long.parseLong(tbFormProject.getAllocateMoney()) - Long.parseLong(tbFormProject.getMoneyBalance()))); creteEmptyLine(openning, 1); openning.add(" : " + tbFormProject.getMoneyBalance()); creteLine(openning, 1); creteEmptyLine(openning, 1); for (TbActivity ac : activity) { acNo++; openning.add("??" + acNo + ":" + ac.getActivityName() + "?? : " + ac.getAddressName()); creteEmptyLine(openning, 1); openning.add("?? : " + ac.getStartdate() + "?? : " + ac.getEnddate()); creteEmptyLine(openning, 1); openning.add("? : " + ac.getAllocateMoney() + " : " + ac.getMoneyBalance()); creteEmptyLine(openning, 1); openning.add(" : " + (Long.parseLong(ac.getAllocateMoney()) - Long.parseLong(ac.getMoneyBalance()))); creteLine(openning, 1); creteEmptyLine(openning, 1); } ska.add(" ?? (?)"); creteEmptyLine(ska, 1); for (TbDetailSka de : detailSka) { ska.add(de.getTbSkaType().getSkaTypeName() + " : " + de.getTbSkaIndicatorsFac().getSkaIndicatorsFacName() + " : " + de.getTbSkaIndicatorsHouse().getSkaIndicatorsHouseName()); creteEmptyLine(ska, 1); } sms.add(" ??? ()"); creteEmptyLine(sms, 1); for (TbDetailSm sm : detailSms) { sms.add(sm.getTbSmsCategory().getSmsCategoryName() + " " + " " + sm.getTbSmsIndicator().getSmsIndicatorsName()); creteEmptyLine(sms, 1); } notice.add( " : ??????? ?????? "); creteEmptyLine(notice, 1); address.add("? : " + " : " + subProject.getTbAmphur().getAmphurTh() + " : " + subProject.getTbProvince().getProvinceTh()); creteEmptyLine(address, 1); readyTodo.add("?"); creteEmptyLine(readyTodo, 1); readyTodo.add("? : " + subProject.getTbApproPlaceType().getApproPlaceTypeName()); creteEmptyLine(readyTodo, 1); readyTodo.add("?/ : " + subProject.getTbApproPoint1().getApproPointName()); creteEmptyLine(readyTodo, 1); readyTodo.add("/? : " + subProject.getTbApproPoint2().getApproPointName()); creteEmptyLine(readyTodo, 1); readyTodo.add("?? : " + subProject.getTbApproProjectType().getApproProjectTypeName()); creteEmptyLine(readyTodo, 1); document.add(openning); document.add(ska); document.add(sms); document.add(notice); document.add(address); document.add(readyTodo); }
From source file:com.planning.project.controller.CreatePDF.java
private static void createPagePDFFormProject2(Document document, TbFormProject tbFormProject, List<TbActivity> activity, List<TbDetailSka> detailSka, List<TbDetailSm> detailSms, TbFormSubproject subProject) throws DocumentException, IOException { Font font = new Font(BaseFont.createFont("D:/THSarabunNew.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)); font.setSize(16);// w w w .j av a 2s .c o m Paragraph openning = new Paragraph(); openning.setFont(font); creteLine(openning, 1); openning.add("??? "); creteEmptyLine(openning, 1); openning.add("????"); creteEmptyLine(openning, 1); openning.add("??? : " + subProject.getTbMonth1().getMonthLong()); creteEmptyLine(openning, 1); openning.add( "? : " + subProject.getTbMonth2().getMonthLong()); creteEmptyLine(openning, 1); openning.add( "??????? : " + subProject.getTbMonth3().getMonthLong()); creteEmptyLine(openning, 1); openning.add("??"); creteEmptyLine(openning, 1); openning.add( "? ???? : " + subProject.getTbMonth4().getMonthLong()); creteEmptyLine(openning, 1); openning.add( "??? : " + subProject.getTbMonth5().getMonthLong()); creteEmptyLine(openning, 1); openning.add( "//????? : " + subProject.getTbMonth6().getMonthLong()); creteEmptyLine(openning, 1); openning.add( "??? : ( 3 ?) : " + subProject.getWorkflowPlanBudget()); creteLine(openning, 1); creteEmptyLine(openning, 1); document.add(openning); }
From source file:com.planning.project.controller.CreatePDF.java
private static void createPagePDFFormProject3(Document document, TbFormProject tbFormProject, List<TbActivity> activity, List<TbDetailSka> detailSka, List<TbDetailSm> detailSms, TbFormSubproject subProject) throws DocumentException, IOException { Font font = new Font(BaseFont.createFont("D:/THSarabunNew.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)); font.setSize(16);/*from w w w. j a v a2s.c om*/ Paragraph openning = new Paragraph(); openning.setFont(font); creteLine(openning, 1); creteEmptyLine(openning, 1); openning.add( "(?????)"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getResults()); creteEmptyLine(openning, 1); openning.add( "?/ ? ()"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getProblem()); creteEmptyLine(openning, 1); openning.add( "??/? ()"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getDevelopmentPlan()); creteEmptyLine(openning, 1); openning.add( "???"); creteEmptyLine(openning, 1); document.add(openning); openning.add( "?? (???? ? ? ??? ?? ?)"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskPolitics()); creteEmptyLine(openning, 1); openning.add( "????/?"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskDefPolitics()); creteLine(openning, 1); creteEmptyLine(openning, 1); openning.add( "??/? (??? ?/? /?? ?? ?)"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskPolicy()); creteEmptyLine(openning, 1); openning.add( "????/?"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskDefPolicy()); creteLine(openning, 1); creteEmptyLine(openning, 1); openning.add( "??? (? ??? ? ? ??)"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskWorkflow()); creteEmptyLine(openning, 1); openning.add( "????/?"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskDefWorkflow()); creteLine(openning, 1); creteEmptyLine(openning, 1); openning.add( "???? (? ?? ?????)"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskFinance()); creteEmptyLine(openning, 1); openning.add( "????/?"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskDefFinance()); creteLine(openning, 1); creteEmptyLine(openning, 1); openning.add( " (? ???)"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskTechnology()); creteEmptyLine(openning, 1); openning.add( "????/?"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskDefTechnology()); creteLine(openning, 1); creteEmptyLine(openning, 1); openning.add( "? (????? ?)"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskEnvironment()); creteEmptyLine(openning, 1); openning.add( "????/?"); creteEmptyLine(openning, 1); openning.add(": " + tbFormProject.getRiskDefEnvironment()); creteLine(openning, 1); creteEmptyLine(openning, 1); document.add(openning); }
From source file:com.planning.project.controller.CreatePDF.java
private static void addTitlePageProject(Document document) throws DocumentException, IOException { Font font = new Font(BaseFont.createFont("D:/THSarabunNew.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)); font.setSize(24);//from ww w .ja va 2 s . c o m String imagepath = "src/main/webapp/resources/images/logo.jpg"; Image img = Image.getInstance(imagepath); img.scaleToFit(70f, 70f); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM/dd/yyyy"); Paragraph created = new Paragraph(); created.setFont(TIME_ROMAN_SMALL); created.add("Report created on " + simpleDateFormat.format(new Date())); created.setAlignment(Element.ALIGN_RIGHT); Paragraph logo = new Paragraph(); logo.setFont(TIME_ROMAN_SMALL); logo.add(img); logo.setAlignment(Element.ALIGN_LEFT); document.add(created); document.add(logo); // Paragraph created = new Paragraph(); // created.setFont(TIME_ROMAN_SMALL); // created.add("Report created on " + simpleDateFormat.format(new // Date())); // created.setAlignment(Element.ALIGN_RIGHT); Paragraph paragraph = new Paragraph(); paragraph.setFont(font); paragraph.add( "??"); paragraph.setAlignment(Element.ALIGN_CENTER); document.add(paragraph); creteEmptyLine(created, 1); }
From source file:com.planning.project.controller.CreatePDF.java
private static void createPagePDFBudwork(Document document, TbDescriptionstatement tbDescriptionstatement) throws DocumentException, IOException { Font font = new Font(BaseFont.createFont("D:/THSarabunNew.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)); font.setSize(16);/*from www. jav a2s. com*/ Paragraph title = new Paragraph(); title.setFont(font); creteEmptyLine(title, 1); title.setFont(font); title.add(": " + tbDescriptionstatement.getTbBudget().getBudgetName()); creteEmptyLine(title, 1); title.add(": " + tbDescriptionstatement.getTbYear().getYearValue()); creteEmptyLine(title, 1); title.add(": " + tbDescriptionstatement.getTbFaculty().getFacultyName()); creteEmptyLine(title, 1); title.add( ": " + tbDescriptionstatement.getTbFaculty().getTbCampus().getCampusName()); creteEmptyLine(title, 1); title.add(" : " + tbDescriptionstatement.getTbProduct().getProductName()); creteEmptyLine(title, 1); title.add(": " + tbDescriptionstatement.getTbBudgetType().getBdTypeName()); creteEmptyLine(title, 1); title.add(": " + tbDescriptionstatement.getTotal() + " "); creteEmptyLine(title, 1); /* * title.add(": " + * tbDescriptionstatement.getAllocateMoney() + " "); * creteEmptyLine(title, 1); title.add(": " * + (Integer.parseInt(tbDescriptionstatement.getAllocateMoney()) - * Integer.parseInt(tbDescriptionstatement.getMoneyBalance())) + " " * ); creteEmptyLine(title, 1); title.add(": " + * tbDescriptionstatement.getMoneyBalance() + " "); * creteEmptyLine(title, 1); */ document.add(title); }
From source file:com.planning.project.controller.CreatePDF.java
private static void createHeadlistBudwork(Document document, String check) throws DocumentException, IOException { Font font = new Font(BaseFont.createFont("D:/THSarabunNew.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)); font.setSize(18);// ww w . j a va 2 s.co m Paragraph title = new Paragraph(); title.setFont(font); creteEmptyLine(title, 1); if (check == "1") { title.add("1. ?"); } else if (check == "2") { title.add("2. "); } else if (check == "3") { title.add("3. "); } else if (check == "4") { title.add("4. "); } creteLine(title, 1); creteEmptyLine(title, 1); document.add(title); }