List of usage examples for com.itextpdf.text.pdf BaseFont EMBEDDED
boolean EMBEDDED
To view the source code for com.itextpdf.text.pdf BaseFont EMBEDDED.
Click Source Link
From source file:com.planning.project.controller.CreatePDF.java
public static PdfPTable createtablePublicutility(List<TbPublicutility> tbPublicutilitys, String getSum) throws DocumentException, Exception { Font font = new Font(BaseFont.createFont("D:/THSarabunNew.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)); font.setSize(16);/*from www. j ava2 s. com*/ PdfPTable table = new PdfPTable(6); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell = new PdfPCell( new Phrase("4.1 ?", font)); cell.setColspan(6); table.addCell(cell); cell = new PdfPCell(new Phrase(" = " + getSum + " ", font)); cell.setColspan(6); table.addCell(cell); cell = new PdfPCell(new Phrase("", font)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("", font)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("", font)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("", font)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("", font)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("", font)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); int count = 0; for (TbPublicutility items : tbPublicutilitys) { count++; table.addCell(new PdfPCell(new Phrase(String.valueOf(count), font))); table.addCell(new PdfPCell(new Phrase(items.getPubEle(), font))); table.addCell(new PdfPCell(new Phrase(items.getPubWater(), font))); table.addCell(new PdfPCell(new Phrase(items.getPubTel(), font))); table.addCell(new PdfPCell(new Phrase(items.getPubEms(), font))); table.addCell(new PdfPCell(new Phrase(items.getPubOther(), font))); table.addCell(new PdfPCell(new Phrase(items.getPubSum(), font))); } return table; }
From source file:com.quix.aia.cn.imo.mapper.ApplicationFormPDFMaintenance.java
License:Open Source License
public static InterviewCandidateMaterial pdf(HttpServletRequest request, AddressBook addressbook) { // TODO Auto-generated method stub log.log(Level.INFO, "ApplicationFormPDFMaintenance --> pdf "); Document document = new Document(PageSize.A4, 50, 50, 50, 50); //Font myAdobeTypekit = FontFactory.getFont(request.getRealPath(File.separator)+"resources"+File.separator+"HDZB_35.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); try {// ww w. j a va 2 s. c o m //String fontPath = "C:/Windows/Fonts"; String fontPath = request.getRealPath("/") + "resources" + File.separator + "hxb-meixinti"; File f2 = new File(fontPath + "/hxb-meixinti.ttf"); BaseFont bf1 = null; if (f2.exists()) { bf1 = BaseFont.createFont(fontPath + "/hxb-meixinti.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); } else { f2 = new File(fontPath + "/hxb-meixinti.ttf"); if (f2.exists()) { System.out.println("File existed"); bf1 = BaseFont.createFont(fontPath + "hxb-meixinti.ttf", BaseFont.IDENTITY_V, BaseFont.EMBEDDED); } else { bf1 = BaseFont.createFont(FontManager.getFontPath(true) + "/hxb-meixinti.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); } } Font normalFontCH = new Font(bf1, 15); String fileName = request.getRealPath("/") + "resources" + File.separator + "upload" + File.separator; DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); Date d1 = new Date(); String time = (d1.getTime() + "").trim(); String str = df.format(new Date()) + time; PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(fileName + "ApplicationForm_" + str + ".pdf")); InterviewCandidateMaterial material = new InterviewCandidateMaterial(); material.setMaterialFileName("ApplicationForm_" + str + ".pdf"); material.setCandidateCode(Integer.parseInt(request.getParameter("candidateCode"))); material.setInterviewCode(Integer.parseInt(request.getParameter("interviewCode"))); // PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("E://applicatonForm2.pdf")); document.open(); addTitle(document, writer, "formHeaderTitle", "Application Form"); document = personalInformation(document, writer, addressbook, normalFontCH); document = familyInformation(document, writer, addressbook); document = workExperience(document, writer, addressbook); document = Education(document, writer, addressbook); document = personalCertification(document, writer, addressbook); document = ESingnature(document, writer, addressbook); document.close(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); File file = new File(fileName + "ApplicationForm_" + str + ".pdf"); FileInputStream fis = new FileInputStream(file); byte[] buf = new byte[1024]; for (int readNum; (readNum = fis.read(buf)) != -1;) { bos.write(buf, 0, readNum); //no doubt here is 0 } material.setFormContent(bos.toByteArray()); material.setCreatedDate(new Date()); material.setMaterialDescrption("AppicationForm"); // applicationForm.setFormContent(bos.toByteArray()); return material; } catch (Exception e) { log.log(Level.INFO, "ApplicationFormPDFMaintenance --> pdf --> Exception " + e.getMessage()); e.printStackTrace(); e.printStackTrace(); LogsMaintenance logsMain = new LogsMaintenance(); StringWriter errors = new StringWriter(); e.printStackTrace(new PrintWriter(errors)); logsMain.insertLogs("ApplicationFormPDFMaintenance", Level.SEVERE + "", errors.toString()); } return null; }
From source file:com.softwaremagico.tm.pdf.complete.FadingSunsTheme.java
License:Open Source License
public static BaseFont getFooterFont() { if (footerFont == null) { Font font = FontFactory.getFont("/" + TITLE_FONT_NAME, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 0.5f, Font.NORMAL, BaseColor.BLACK); footerFont = font.getBaseFont(); }/*from ww w .j ava2 s . co m*/ return footerFont; }
From source file:com.softwaremagico.tm.pdf.complete.FadingSunsTheme.java
License:Open Source License
public static BaseFont getLineFont() { if (lineFont == null) { Font font = FontFactory.getFont("/" + LINE_FONT_NAME, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 0.8f, Font.NORMAL, BaseColor.BLACK); lineFont = font.getBaseFont();//ww w . j ava 2 s . c o m } return lineFont; }
From source file:com.softwaremagico.tm.pdf.complete.FadingSunsTheme.java
License:Open Source License
public static BaseFont getLineItalicFont() { if (lineItalicFont == null) { Font font = FontFactory.getFont("/" + LINE_FONT_ITALIC_NAME, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 0.8f, Font.ITALIC, BaseColor.BLACK); lineItalicFont = font.getBaseFont(); }/*w w w .ja va 2s. c o m*/ return lineItalicFont; }
From source file:com.softwaremagico.tm.pdf.complete.FadingSunsTheme.java
License:Open Source License
public static BaseFont getLineFontBold() { if (lineBoldFont == null) { Font font = FontFactory.getFont("/" + LINE_BOLD_FONT_NAME, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 0.8f, Font.BOLD, BaseColor.BLACK); lineBoldFont = font.getBaseFont(); }/*from ww w.j a v a 2 s.co m*/ return lineBoldFont; }
From source file:com.softwaremagico.tm.pdf.complete.FadingSunsTheme.java
License:Open Source License
public static BaseFont getTitleFont() { if (titleFont == null) { Font font = FontFactory.getFont("/" + TITLE_FONT_NAME, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 0.8f, Font.NORMAL, BaseColor.BLACK); titleFont = font.getBaseFont();/*from w w w . j a v a2 s. c om*/ } return titleFont; }
From source file:com.softwaremagico.tm.pdf.complete.FadingSunsTheme.java
License:Open Source License
public static BaseFont getSubtitleFont() { if (tableSubtitleFont == null) { Font font = FontFactory.getFont("/" + TABLE_SUBTITLE_FONT_NAME, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 0.8f, Font.ITALIC, BaseColor.BLACK); tableSubtitleFont = font.getBaseFont(); }// w ww .j a va 2 s . c o m return tableSubtitleFont; }
From source file:com.softwaremagico.tm.pdf.complete.FadingSunsTheme.java
License:Open Source License
public static BaseFont getHandwrittingFont() { if (handwrittingFont == null) { Font font = FontFactory.getFont("/" + HANDWRITTING_FONT_NAME, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 0.8f, Font.NORMAL, BaseColor.BLACK); handwrittingFont = font.getBaseFont(); }//from w ww .j a v a 2 s. c om return handwrittingFont; }
From source file:com.swayam.bhasha.engine.io.writers.impl.PDFGenerator.java
License:Apache License
private Paragraph getParagraph(Para para) throws DocumentException, IOException, DocGenerationException { int align = para.getAlignment(); int pdfAlign; switch (align) { case Para.CENTER: pdfAlign = Paragraph.ALIGN_CENTER; break;// ww w .j a va2 s . c o m case Para.RIGHT: pdfAlign = Paragraph.ALIGN_RIGHT; break; case Para.JUSTIFIED: pdfAlign = Paragraph.ALIGN_JUSTIFIED; break; case Para.LEFT: default: pdfAlign = Paragraph.ALIGN_LEFT; break; } List<ParaText> paraTextList = para.getParaTextList(); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(pdfAlign); for (ParaText paraText : paraTextList) { int fontStyle = Font.NORMAL; if (paraText.isBold()) { fontStyle |= Font.BOLD; } if (paraText.isUnderline()) { fontStyle |= Font.UNDERLINE; } if (paraText.isItalic()) { fontStyle |= Font.ITALIC; } Font font = FontFactory.getFont(paraText.getFontFamily(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED, paraText.getFontSize(), fontStyle, new BaseColor(paraText.getColor().getRGB())); // its very important to set the leading every time the font is set // otherwise, the chunks/phrases overlap. // paragraph.setLeading(font.getSize() * 1.5f); paragraph.add(new Phrase(paraText.getText(), font)); } return paragraph; }